A collection of handy utility functions and middleware compatible with meseret.
To install, inside a meseret project:
yarn add meseret-utils
# or, using npm:
# npm i meseret-utils --save
Then, we'll need to run the configuration/setup function (called configureMeseretUtils
) at our app's entry like:
// maybe, your index.ts
import { ServerApp } from 'meseret'
import { configureMeseretUtils } from 'meseret-utils'
import { serverAppConfig } from './path/to/your/server-app-config'
export const serverApp = new ServerApp(serverAppConfig)
configureMeseretUtils({
serverApp
})
serverApp.start().catch(console.error)
-
C.R.U.D.: a collection of functions (
add
,get
,list
,search
,edit
andremove
) that perform read and write operations on MongoDB collections (as modelled by mongoose); these functions include extensive error handling, and highly customizable querying and action plugging. -
email: an easy way to send an email.
-
Grid: a nice abstraction of GridFS, the large-file-size-capable storage system inside MongoDB.
-
KoaController: a controller super-class that works hand-in-hand with our handle middleware.
-
KoaError: an extension of
Error
(with support for errorcode
and HTTPstatus
) that is compatible with koa and ourhandle
middleware. -
password: a pair of functions that assist in an account's password reset process.
-
PhotoGrid: coming soon, in the next few feature releases.
-
transact: an abstraction to quickly support MongoDB's session-based multi-document ACID-compatible transactions; this requires MongoDB 4 .
-
handle: a koa middleware that implicitly calls our
transact
function on ourkoa-controller
methods and nicely handles ourkoa-error
throws. -
sslRedirect: a koa middleware that redirects all HTTP requests to HTTPS in "production" environments (unless other environments are passed to it).
- KeyModel: a mongoose data model used in our
password
reset functions to store unique keys (tokens).
- ObjectId: a shortcut for the type
mongoose.Schema.Types.ObjectId | string
.
Proudly, made with ♥ in Addis Ababa.
MIT License © 2019 Kaleab S. Melkie