Comparing version 1.0.0 to 1.1.0
18
index.js
@@ -27,2 +27,10 @@ /* jshint esnext:true, node:true */ | ||
function parseFName(fname) { | ||
var arr = fname.split('.'); | ||
return { | ||
verb: arr[0].toLowerCase(), | ||
status: arr[1] ? Number(arr[1]) : null | ||
}; | ||
} | ||
function bindProcessors(paths){ | ||
@@ -37,2 +45,3 @@ var currentPath = path.join(root, paths.join('/')); | ||
var parsed = path.parse(dir); | ||
switch(parsed.ext){ | ||
@@ -51,6 +60,11 @@ case '.json': | ||
var parsedName = parseFName(parsed.name); | ||
var respCb = function emocksHandle(req, res){ | ||
if(headers){ | ||
if (headers) { | ||
res.set(headers); | ||
} | ||
if (parsedName.status) { | ||
res.status(parsedName.status); | ||
} | ||
res.sendFile(currentPathFile); | ||
@@ -63,3 +77,3 @@ }; | ||
} | ||
router[parsed.name.toLowerCase()](routes, respCb); | ||
router[parsedName.verb](routes, respCb); | ||
break; | ||
@@ -66,0 +80,0 @@ } |
{ | ||
"name": "emocks", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Mock server based on expressjs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
10584
210