Comparing version 0.2.0 to 0.3.0
15
index.js
@@ -1,4 +0,2 @@ | ||
'use strict' | ||
class Cors { | ||
module.exports = MiddlewareBase => class Cors extends MiddlewareBase { | ||
description () { | ||
@@ -21,10 +19,9 @@ return 'Cross-Origin Resource Sharing options.' | ||
options = options || {} | ||
const corsOptions = {} | ||
if (options.corsOrigin) corsOptions.corsOrigin = options.corsOrigin | ||
if (options.corsAllowMethods) corsOptions.corsAllowMethods = options.corsAllowMethods | ||
this.emit('verbose', 'middleware.cors.config', corsOptions) | ||
const kcors = require('kcors') | ||
return kcors({ | ||
origin: options.corsOrigin, | ||
allowMethods: options.corsAllowMethods | ||
}) | ||
return kcors(corsOptions) | ||
} | ||
} | ||
module.exports = Cors |
{ | ||
"name": "lws-cors", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "lws-cors", | ||
@@ -19,4 +19,7 @@ "repository": "https://github.com/lwsjs/cors.git", | ||
"dependencies": { | ||
"kcors": "^2.2.1" | ||
"kcors": "^2.2.1", | ||
"lws": "^1.0.0-pre2.1", | ||
"req-then": "^0.6.2", | ||
"test-runner": "^0.4.0" | ||
} | ||
} |
@@ -7,4 +7,8 @@ [![view on npm](https://img.shields.io/npm/v/lws-cors.svg)](https://www.npmjs.org/package/lws-cors) | ||
# cors | ||
# lws-cors | ||
See https://github.com/koajs/cors. | ||
lws middleware to configure Cross-Origin Resource Sharing rules. For usage instructions, see [here](https://github.com/lwsjs/local-web-server/wiki/How-to-configure-Cross-Origin-Resource-Sharing-(CORS)). | ||
* * * | ||
© 2017 Lloyd Brookes <75pound@gmail.com>. |
14
test.js
@@ -1,6 +0,14 @@ | ||
var test = require('tape') | ||
var lib = require('../') | ||
const TestRunner = require('test-runner') | ||
const Cors = require('./') | ||
const Lws = require('lws') | ||
const request = require('req-then') | ||
test('first', function (t) { | ||
const runner = new TestRunner() | ||
runner.test('simple', async function () { | ||
const port = 8000 + this.index | ||
const lws = new Lws() | ||
const server = lws.create({ port, stack: Cors }) | ||
const response = await request(`http://localhost:${port}/`) | ||
server.close() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18966
7
38
13
4
+ Addedlws@^1.0.0-pre2.1
+ Addedreq-then@^0.6.2
+ Addedtest-runner@^0.4.0
+ Addedaccepts@1.3.8(transitive)
+ Addedansi-escape-sequences@4.1.0(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedarray-back@1.0.42.0.03.1.0(transitive)
+ Addedasync-limiter@1.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbyte-size@5.0.1(transitive)
+ Addedcache-content-type@1.0.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcli-commands@0.4.0(transitive)
+ Addedco@4.6.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcommand-line-args@4.0.75.2.1(transitive)
+ Addedcommand-line-commands@2.0.1(transitive)
+ Addedcommand-line-usage@4.1.05.0.5(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookies@0.9.1(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddeep-equal@1.0.1(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddefer-promise@1.0.2(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddepd@1.1.22.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfile-set@1.1.2(transitive)
+ Addedfind-replace@1.0.33.0.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhttp-assert@1.5.0(transitive)
+ Addedhttp-errors@1.8.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-wsl@1.1.0(transitive)
+ Addedkeygrip@1.1.0(transitive)
+ Addedkoa@2.15.3(transitive)
+ Addedkoa-compose@4.2.0(transitive)
+ Addedkoa-convert@2.0.0(transitive)
+ Addedload-module@1.0.0(transitive)
+ Addedlodash.assignwith@4.2.0(transitive)
+ Addedlodash.camelcase@4.3.0(transitive)
+ Addedlodash.padend@4.6.1(transitive)
+ Addedlodash.pick@4.4.0(transitive)
+ Addedlws@1.3.2(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednode-version-matches@1.0.1(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedonly@0.0.2(transitive)
+ Addedopn@5.5.0(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedreduce-flatten@1.0.12.0.0(transitive)
+ Addedreq-then@0.6.4(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedstream-read-all@0.1.2(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtable-layout@0.4.5(transitive)
+ Addedtest-runner@0.4.1(transitive)
+ Addedtest-value@2.1.0(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtsscmp@1.0.6(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedtypical@2.6.13.0.24.0.0(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedwalk-back@3.0.1(transitive)
+ Addedwordwrapjs@3.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedws@5.2.4(transitive)
+ Addedylru@1.4.0(transitive)