@arunvaradharajalu/common.cookies
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@arunvaradharajalu/common.cookies

npm version GitHub issues GitHub license

Overview

This package provides a Cookie Implementation class to handle setting, retrieving, and clearing cookies, including signed cookies, in an Express application.

Installation

To install the package, run the following command:

npm install @arunvaradharajalu/common.cookies

Usage

Importing the Cookie Implementation

import { CookieImpl } from '@arunvaradharajalu/common.cookies';

Setting a Cookie

const cookieImpl = new CookieImpl();
cookieImpl.setCookies(response, { name: Cookies.appnameCookieName, value: 'cookie_value' });

Setting a Signed Cookie

cookieImpl.setSignedCookies(response, { name: SignedCookies.lifeverseChristmasEventAuthToken, value: 'signed_cookie_value' });

Retrieving Cookies

const cookies = cookieImpl.getCookies(request);
console.log(cookies.appnameCookieName);

Retrieving Signed Cookies

const signedCookies = cookieImpl.getSignedCookies(request);
console.log(signedCookies.lifeverseChristmasEventAuthToken);

Clearing a Cookie

cookieImpl.clear(response, Cookies.appnameCookieName);

Types

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

Tests can be run using:

npm run test

Test results will be available in an HTML format using the jest-html-reporter.

License

This project is licensed under the ISC License.

Issues

For any issues or bug reports, please visit the GitHub Issues Page.

Author

Arun Varadharajalu

Package Sidebar

Install

npm i @arunvaradharajalu/common.cookies

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

11.9 kB

Total Files

13

Last publish

Collaborators

  • arunvaradharajalu