Express Utilities
Various helpful middleware that I keep rewriting for every single project
Installation
npm install express-utilities
Usage
Requiring Parameters on Requests
'use strict'; const requireParams = ;const parser = ;const app = ; app; app; app;
Error Handling
Given that my target was initially Ember, errors will currently be returned as follows:
Handling Types
Sometimes you need to specify a type so that you don't have to do a bunch of work in each endpoint to coerce a value and you can do that using this same method.
Given the endpoint:
app;
And the request:
POST /data?active=true
req.query.active
would be true
(rather than 'true'
), age would be 19
(rather than '19'
) so long
as the provided values are actually able to be converted i.e. not NaN or something other than 1/0/true/false
in the case of a boolean
.