Comparing version 0.7.5 to 0.7.6
@@ -8,2 +8,7 @@ # Nodecaf Changelog | ||
## [v0.7.6] - 2019-07-24 | ||
### Added | ||
- setting to permissively allow CORS on all routes | ||
## [v0.7.5] - 2019-07-23 | ||
@@ -191,1 +196,2 @@ | ||
[v0.7.5]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.5 | ||
[v0.7.6]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.7.6 |
const os = require('os'); | ||
const fs = require('fs'); | ||
const cors = require('cors'); | ||
const http = require('http'); | ||
@@ -93,2 +94,4 @@ const https = require('https'); | ||
this.express.use(compression()); | ||
if(this.settings.cors) | ||
this.express.use(cors()); | ||
this.express.use(logRequest.bind(this)); | ||
@@ -95,0 +98,0 @@ callback.bind(this)(this.routerFuncs); |
{ | ||
"name": "nodecaf", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "Nodecaf is an Express framework for developing REST APIs in a quick and convenient manner.", | ||
@@ -41,2 +41,3 @@ "main": "lib/main.js", | ||
"compression": "^1.7.4", | ||
"cors": "^2.8.5", | ||
"eclipt": "^0.1.2", | ||
@@ -43,0 +44,0 @@ "ejs": "^2.6.2", |
@@ -17,2 +17,3 @@ # [Nodecaf](https://gitlab.com/GCSBOSS/nodecaf) | ||
database connections). | ||
- Shortcut for [permissive CORS](#cors) on all routes. | ||
- [HTTPS capability](#https). | ||
@@ -386,2 +387,11 @@ - Functions to [describe your API](#api-description) making your code the main | ||
### CORS | ||
Nodecaf provides a setting to enable permissive CORS on all routes. Defaults to | ||
disabled. In your conf file: | ||
```js | ||
cors = true | ||
``` | ||
### HTTPS | ||
@@ -388,0 +398,0 @@ |
@@ -464,2 +464,21 @@ //const wtf = require('wtfnode'); | ||
describe('CORS', () => { | ||
it('Should send permissive CORS headers when setup so [cors]', async () => { | ||
let app = new AppServer(); | ||
app.settings.cors = true; | ||
app.api(function({ get }){ | ||
get('/foobar', ({ res }) => res.end() ); | ||
}); | ||
await app.start(); | ||
const { assert } = await base.get('foobar', { 'Origin': 'http://outsider.com' }); | ||
assert.status.is(200); | ||
assert.headers.match('access-control-allow-origin', '*'); | ||
const { assert: { headers } } = await base.options('foobar', { 'Origin': 'http://outsider.com' }); | ||
headers.match('access-control-allow-methods', 'GET,HEAD,PUT,PATCH,POST,DELETE'); | ||
await app.stop(); | ||
}); | ||
}); | ||
describe('Accept setter', () => { | ||
@@ -466,0 +485,0 @@ const { accept } = require('../lib/parse-types'); |
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
97474
1674
535
11
+ Addedcors@^2.8.5
+ Addedcors@2.8.5(transitive)
+ Addedobject-assign@4.1.1(transitive)