Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chubbyts/chubbyts-cors

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chubbyts/chubbyts-cors

A CORS middleware for @chubbyts/chubbyts-http-types.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
208
increased by65.08%
Maintainers
1
Weekly downloads
 
Created
Source

chubbyts-cors

CI Coverage Status Infection MSI npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A CORS middleware for @chubbyts/chubbyts-http-types.

Apply toLowerCase() to each related request header name before pass the request to this middleware.

Requirements

Installation

Through NPM as @chubbyts/chubbyts-cors.

npm i @chubbyts/chubbyts-cors@^1.2.1

Usage

import { createCorsMiddleware } from '@chubbyts/chubbyts-cors/dist/middleware';
import {
  createAllowOriginRegex,
  createHeadersNegotiator,
  createMethodNegotiator,
  createOriginNegotiator,
} from '@chubbyts/chubbyts-cors/dist/negotiation';
import { createResponseFactory } from '@chubbyts/chubbyts-http/dist/message-factory';
import { Method } from '@chubbyts/chubbyts-http-types/dist/message';

const corsMiddleware = createCorsMiddleware(
  createResponseFactory(),
  createOriginNegotiator([createAllowOriginRegex(/^https?\:\/\/localhost(\:\d+)?$/)]),
  createMethodNegotiator([Method.GET, Method.POST, Method.PUT, Method.DELETE]),
  createHeadersNegotiator(['Content-Type', 'Accept']),
);

(async () => {
  const response = await corsMiddleware(request, handler);
})();

2023 Dominik Zogg

FAQs

Package last updated on 26 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc