This package provides a Cookie Implementation class to handle setting, retrieving, and clearing cookies, including signed cookies, in an Express application.
To install the package, run the following command:
npm install @arunvaradharajalu/common.cookies
import { CookieImpl } from '@arunvaradharajalu/common.cookies';
const cookieImpl = new CookieImpl();
cookieImpl.setCookies(response, { name: Cookies.appnameCookieName, value: 'cookie_value' });
cookieImpl.setSignedCookies(response, { name: SignedCookies.lifeverseChristmasEventAuthToken, value: 'signed_cookie_value' });
const cookies = cookieImpl.getCookies(request);
console.log(cookies.appnameCookieName);
const signedCookies = cookieImpl.getSignedCookies(request);
console.log(signedCookies.lifeverseChristmasEventAuthToken);
cookieImpl.clear(response, Cookies.appnameCookieName);
The package includes types for cookies and signed cookies:
-
Cookies
: Enum for standard cookies. -
SignedCookies
: Enum for signed cookies. -
CookieInput
: Interface for passing cookie name and value. -
SignedCookieInput
: Interface for passing signed cookie name and value.
Tests can be run using:
npm run test
Test results will be available in an HTML format using the jest-html-reporter.
This project is licensed under the ISC License.
For any issues or bug reports, please visit the GitHub Issues Page.
Arun Varadharajalu