warp-proxy
Advanced tools
Comparing version 1.3.5 to 1.4.0
@@ -9,2 +9,7 @@ const chalk = require('chalk'); | ||
const headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Methods': 'OPTIONS, POST, GET, PUT, DELETE', | ||
}; | ||
const run = ({port, directory, fileExt = 'json', keepExtensions = true, slowMode = false}) => { | ||
@@ -15,2 +20,8 @@ const invoke = slowMode ? withTimer : immediately; | ||
const files = (req, res) => { | ||
if (req.method === 'OPTIONS') { | ||
res.writeHead(204, headers); | ||
res.end(); | ||
return; | ||
} | ||
const urlFile = req.url.split('/').splice(-1).pop() || `index.${fileExt}`; | ||
@@ -29,2 +40,4 @@ const urlFileExt = urlFile.indexOf('.') > -1 ? urlFile.split('.').splice(-1).pop() : null; | ||
const paintedStatus = paintStatus(status); | ||
res.writeHead(status, headers); | ||
if (exist) { | ||
@@ -31,0 +44,0 @@ const stream = fs.createReadStream(filePath); |
{ | ||
"name": "warp-proxy", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "Proxy requests or return mocks from local files instead", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
105647
198