spirit-common
Common http middleware setup for spirit.
It's purpose is to reduce boilerplate and avoid middleware ordering confusion.
Usage
const defaults = defaultsconst site = // returns a middleware with a lot of common http middleware supported spiritnode // use middleware with spirit node adapter
This sets up and provides body parsing, session, as well as other common middleware.
NOTE: By default it stores cookies in memory, to change, pass in a configuration object:
The secret used for cookies is auto-generated on startup, to use your own you can pass it in as an option too:
Aside from changing the session secret and store option, most other options are safe to leave alone.
If you wanted to disable a middleware used by defaults
then pass in false
as it's option, for example to turn off the console logger and session support:
A list of middlewares used:
log: true/false proxy: true/false ifmod: true/false body: json: ... // body-parser .json urlencoded: ... // body-parser .urlencoded session: ... // express-session
For the 'body' and 'session' middleware, it uses the npm modules body-parser and express-session. So the same options can be passed in.
There is also a "api" configuration:
Which loads every middleware from the "site" configuration except session support.