Comparing version 0.2.3 to 0.2.4
@@ -11,2 +11,3 @@ var express = require('express'), | ||
"allowedDomains": ["*"], | ||
"allowedHeaders": ["Content-Type"], | ||
"webServices": {} | ||
@@ -236,5 +237,7 @@ }; | ||
apiMocker.corsMiddleware = function(req, res, next) { | ||
var allowedHeaders = apiMocker.options.allowedHeaders.join(','); | ||
res.header('Access-Control-Allow-Origin', apiMocker.options.allowedDomains); | ||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); | ||
res.header('Access-Control-Allow-Headers', 'Content-Type'); | ||
res.header('Access-Control-Allow-Headers', allowedHeaders); | ||
@@ -241,0 +244,0 @@ next(); |
{ | ||
"name": "apimocker", | ||
"description": "Simple HTTP server that returns mock service API responses to your front end.", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"engines": {"node": ">=0.10.0"}, | ||
@@ -6,0 +6,0 @@ "author": "Greg Stroup <gstroup@gmail.com>", |
@@ -54,2 +54,3 @@ # apimocker | ||
* Allowed domains can be set to restrict CORS requests to certain domains. | ||
* Allowed headers can be set. (Default is to set "access-control-allow-headers: Content-Type" if not specified in config file.) | ||
* Services can be configured to return different responses, depending on a request parameter. | ||
@@ -65,2 +66,3 @@ | ||
"allowedDomains": ["abc.com"], | ||
"allowedHeaders": ["Content-Type", "my-custom-header"], | ||
"webServices": { | ||
@@ -137,8 +139,10 @@ "first": { | ||
## Versions | ||
### 0.2.4 | ||
Allows configuration of the "access-control-allow-headers" HTTP header. | ||
### 0.2.3 | ||
Now allows HTTP status code to be set for each response. Config file format also allows configuration of different responses based on http verb. | ||
### 0.1.8 | ||
New "switch" feature added, allowing different responses based on a request parameter. | ||
### 0.1.6 | ||
New config file format was introduced, allowing for custom content-types and more fine grained control over services. | ||
### 0.1.8 | ||
New "switch" feature added, allowing different responses based on a request parameter. | ||
### 0.2.3 | ||
Now allows HTTP status code to be set for each response. Config file format also allows configuration of different responses based on http verb. | ||
@@ -145,0 +149,0 @@ ## Contributors |
@@ -7,2 +7,3 @@ { | ||
"allowedDomains": ["abc"], | ||
"allowedHeaders": ["Content-Type", "my-custom-header"], | ||
"webServices": { | ||
@@ -9,0 +10,0 @@ "first": { |
@@ -162,2 +162,7 @@ /* global describe, it, before */ | ||
it('allows headers as specified in config file', function(done) { | ||
var reqOptions = httpReqOptions("/first"); | ||
verifyResponseHeaders(reqOptions, {'access-control-allow-headers': 'Content-Type,my-custom-header'}, done); | ||
}); | ||
it('returns correct file for switch param in json request', function(done) { | ||
@@ -164,0 +169,0 @@ var postData = '{"customerId": 1234}', |
@@ -9,3 +9,2 @@ /* global describe, it, beforeEach, afterEach, after */ | ||
fs = require("fs"), | ||
express, | ||
assert = chai.assert, | ||
@@ -40,2 +39,3 @@ expect = chai.expect, | ||
"allowedDomains": ["abc"], | ||
"allowedHeaders": ["my-custom1", "my-custom2"], | ||
"webServices": { | ||
@@ -69,2 +69,3 @@ "first": { | ||
expect(mocker.options.allowedDomains[0]).to.equal("*"); | ||
expect(mocker.options.allowedHeaders[0]).to.equal("Content-Type"); | ||
expect(mocker.options.quiet).to.equal(undefined); | ||
@@ -128,2 +129,4 @@ }); | ||
expect(mocker.options.allowedDomains[0]).to.equal(testConfig.allowedDomains[0]); | ||
expect(mocker.options.allowedHeaders[0]).to.equal("my-custom1"); | ||
expect(mocker.options.allowedHeaders[1]).to.equal("my-custom2"); | ||
expect(mocker.options.webServices).to.deep.equal(testConfig.webServices); | ||
@@ -130,0 +133,0 @@ expect(mocker.options.quiet).to.equal(true); |
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
38629
819
152