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

cors-ts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-ts - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

dist/index.d.ts

@@ -26,3 +26,3 @@ /// <reference types="node" />

declare type CorsNextFunc = (err?: any) => any;
declare function cors<T extends CorsRequest = CorsRequest, Res extends CorsRes = CorsRes, Next extends CorsNextFunc = CorsNextFunc>(options?: CorsOptions | CorsOptionsDelegate<T> | undefined): (req: T, res: Res, next: Next) => void;
export declare function cors<T extends CorsRequest = CorsRequest, Res extends CorsRes = CorsRes, Next extends CorsNextFunc = CorsNextFunc>(options?: CorsOptions | CorsOptionsDelegate<T> | undefined): (req: T, res: Res, next: Next) => void;
export default cors;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cors = void 0;
function cors(options) {

@@ -221,2 +222,3 @@ if (options === void 0) { options = {}; }

}
exports.cors = cors;
exports.default = cors;
{
"name": "cors-ts",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cors package with type definitions",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"prepare": "npm run build",
"build": "rimraf dist && tsc -p tsconfig.json --removeComments --outDir dist"
"build": "rimraf dist && tsc"
},

@@ -16,0 +16,0 @@ "keywords": [

# Cors package with Typescript types
### Install
```
npm install cors-ts
```
or
```
yarn add cors-ts
```
### Usage
(see [Cors](https://www.npmjs.com/package/cors) Documentation for more information)
##### CommonJS
```js
//@ts-check
const express = require('express')
const { cors } = require('cors-ts')
const app = express()
const PORT = process.env.PORT || 4000
//Parameters are Optional
app.use(
cors({
origin: '*',
credentials: true,
})
)
app.listen(PORT, function () {
console.log(`CORS-enabled web server listening on port ${PORT}`)
})
```
##### ES6
```ts
//@ts-check
import express from 'express'
import cors from 'cors-ts'
const app = express()
const PORT = process.env.PORT || 4000
//Parameters are Optional
app.use(
cors({
origin: 'http://example.com',
optionsSuccessStatus: 200,
})
)
app.listen(PORT, function () {
console.log(`CORS-enabled web server listening on port ${PORT}`)
})
```
### Credits
Troy Goode ([Original Package](https://www.npmjs.com/package/cors)
Creator)
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