quick and dirty api boilerplate
|
|
há 4 anos atrás | |
|---|---|---|
| src | há 4 anos atrás | |
| .eslintrc.cjs | há 4 anos atrás | |
| .gitignore | há 4 anos atrás | |
| .nvmrc | há 4 anos atrás | |
| .prettierrc | há 4 anos atrás | |
| README.md | há 4 anos atrás | |
| package-lock.json | há 4 anos atrás | |
| package.json | há 4 anos atrás |
Quick and dirty API boilerplate, using:
There are many limitations to this configuration, it is intended as a debugging/prototyping tool.
Import start from easy-api.js, call like so:
start(
routes[],
host = '127.0.0.1',
port = 8080,
dbOpts{},
serverOpts{}
)
Objects are stored in redis by calculating the sha256 hash, hex digest from a
"path" array for convenience (e.g. ["users", req.params.userName, "stats",
"visits"]).
Routes are defined as simple factories, passed a db wrapper, yup and log instance as an object ({db, yup, log}) and expected to return:
get/api/hello/:nameIf a route passes a schema, the request will be validated against it:
req.paramsreq.data