Cookies for Routex.
Install:
yarn add @routex/cookies
# or
npm add @routex/cookies
Setup your app:
const { Routex, TextBody } = require("routex");
const cookies = require("@routex/cookies");
const port = process.env.PORT || 3000;
const app = new Routex();
app.use(cookies());
app.get("/", (ctx) => {
// Get cookie
const name = ctx.cookies.get("name");
if (!name) {
// Set cookie
ctx.cookies.set("name", "john");
}
// Remove cookie
ctx.cookies.remove("name");
ctx.body = new TextBody("Set name cookie");
});
app.listen(port).then(() => console.log(`Listening on ${port}`));
We support all currently active and maintained Node LTS versions, include current Node versions.
Please file feature requests and bugs at the issue tracker.