Servie Cookie Store
Cookie storage and manipulation for Servie.
Installation
npm install servie-cookie-store --save
Usage
;
Constructor
The Cookie
constructor accepts the Servie Request
and Response
objects. It optionally accepts a keys object for signing the cookie payloads. This object MUST have encode(data)
and decode(data)
methods, compatible with keysign and keycrypt. You SHOULD sign cookies when you want to avoid client-side tampering of requests.
;
Methods
get(key)
retrieves the cookie bykey
name, returningundefined
when not found or invalidset(res, key, data, options?)
sets the cookie with optional cookie optionsdelete(res, key, options?)
deletes the cookie by settingmaxAge
into past with optional cookie optionsstringify(key, data, options?)
creates aSet-Cookie
header with optional cookie optionsencode(value)
stringifies a JavaScript valuedecode(value)
parses the cookie string into JavaScript
TypeScript
This project is written using TypeScript and publishes the definitions directly to NPM.
License
Apache 2.0