Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

routexjs/routex-cookies

Repository files navigation

Routex Cookies npm Travis CI Codecov

Cookies for Routex.

Documentation - GitHub

Example

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}`));

Support

We support all currently active and maintained Node LTS versions, include current Node versions.

Please file feature requests and bugs at the issue tracker.