felid-cookie
A Felid plugin that provides support for cookies.
Install
npm install felid-cookie
or
yarn add felid-cookie
Usage
const Felid = const cookie = const app = app app
Options
- secret String: The default secret key for cookies signature. If a non-empty secret has been set, the cookie will be signed.
- unsign Boolean: Unsign the request cookies automatically if a secret key is given. You can manually unsign the cookie by invoking
request.unsign()
if this option is set tofalse
. Default isfalse
. - parseOptions Object: The options for cookie.parse().
- decorator Object: Customize the decorator names. Default is:
reqGetCookie: 'cookies' unsignCookie: 'unsign' resSetCookie: 'cookie' resSetCookies: 'cookies'
For more options, please check cookie.
Some has default values:
- httpOnly: true
Api
- request.cookies: The parsed request cookies.
- request.unsign(key: String, secret?: String): Unsign the given cookie pair. The secret passed here will override the plugin secret.
- response.cookie(key: String, value: String, options?: Object): Set a single cookie pair. The options passed here will override the plugin options.
- response.cookies(cookies: Object, options?: Object): Set a set of cookie pairs. The options passed here will override the plugin options.