angular-mock-record
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "angular-mock-record", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "An angular / protractor framework that mocks and records requests. Requests can be manually mocked or recorded like VCR.", | ||
@@ -5,0 +5,0 @@ "main": "server.js", |
@@ -9,7 +9,9 @@ class Http { | ||
get(req) { | ||
return new Promise((resolve, reject) => { | ||
this.http.get( | ||
{ | ||
json: true, | ||
url: this.config.domain + req.url | ||
url: this.config.domain + req.url, | ||
jar: true, | ||
headers: this.setRequestHeaders(req.headers) | ||
}, (error, response, body) => { | ||
@@ -31,2 +33,12 @@ | ||
setRequestHeaders(requestHeaders) { | ||
let out = {}; | ||
this.config.request_headers.forEach(header => { | ||
out[header] = requestHeaders[header]; | ||
}); | ||
return out; | ||
} | ||
setCorsHeaders(req, res) { | ||
@@ -33,0 +45,0 @@ res.header('Access-Control-Allow-Origin', req.headers.origin); |
@@ -15,5 +15,10 @@ const express = require('express'); | ||
this.app.use((req, res) => { | ||
req.url = this.rewritePathToMocks(req.url); | ||
this.requestHandler.handle(req, res); | ||
}); | ||
} | ||
rewritePathToMocks(url) { | ||
return url.replace(config.proxied_mock_server_route, ''); | ||
} | ||
} | ||
@@ -20,0 +25,0 @@ |
12084
370