1.5.0 • Published 4 months ago
@uswitch/koa-cookie v1.5.0
koa-cookie
Cookie parser middleware for koa. Can also be used with koa-router.
Install
npm install @uswitch/koa-cookie --save
Example
import Koa from 'koa';
import cookie from '@uswitch/koa-cookie';
const app = Koa();
app.use(cookie());
app.use(async function (ctx, next) {
const cookies = ctx.cookie;
/*
if cookies sent are of the form: 'name=abc; age=20; token = xyz;'
Then ctx.cookie is an object of the form:
{
name: 'abc',
age: '20',
token: 'xyz'
}
*/
});
Example with koa-router
var app = require('koa')();
var cookie = require('@uswitch/koa-cookie');
var router = require('koa-router')();
router.use(cookie.default());
router.get('/', async (context) => {
const cookies = context.cookie;
/*
if cookies sent are of the form: 'name=abc; age=20; token = xyz;'
Then ctx.cookie is an object of the form:
{
name: 'abc',
age: '20',
token: 'xyz'
}
*/
});
app
.use(router.routes())
.use(router.allowedMethods());
1.5.0
4 months ago
1.4.5
2 years ago
1.4.4
2 years ago
1.4.3
2 years ago
1.4.11
2 years ago
1.4.8
2 years ago
1.4.2
3 years ago
1.4.1
3 years ago
1.2.8
3 years ago
1.2.5
3 years ago
1.4.0
3 years ago
1.2.9
3 years ago
1.2.13
3 years ago
1.2.10
3 years ago
1.2.11
3 years ago
1.2.14
3 years ago
1.2.3
4 years ago
1.2.2
4 years ago
1.2.1
4 years ago
1.2.0
4 years ago
1.3.0
4 years ago
1.1.0
4 years ago
1.0.8
4 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.2
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago