Comparing version 1.0.0 to 1.1.0
43
index.js
@@ -1,12 +0,11 @@ | ||
const http = require('http') | ||
const methods = ['get', 'delete', 'patch', 'post', 'put', 'head', 'options'] | ||
const extensions = { | ||
const exts = { | ||
request: {}, | ||
response: require('./libs/response-extensions') | ||
} | ||
const URL = require('url') | ||
const URL = require('fast-url-parser') | ||
const reqHandler = require('./libs/middleware-chain') | ||
module.exports = (options = {}) => { | ||
const server = options.server || http.createServer() | ||
const server = options.server || require('http').createServer() | ||
server.on('request', (req, res) => { | ||
@@ -57,4 +56,4 @@ app.handler(req, res) | ||
handler: (req, res) => { | ||
for (const method of Object.keys(extensions.response)) { | ||
res[method] = extensions.response[method](req, res) | ||
for (const method of Object.keys(exts.response)) { | ||
res[method] = exts.response[method](req, res) | ||
} | ||
@@ -67,19 +66,18 @@ const url = URL.parse(req.url) | ||
// calling middlewares | ||
require('./libs/middleware-chain')( | ||
[ | ||
...middlewares.slice(0), | ||
{ | ||
context: {}, | ||
handler: (req, res, next) => { | ||
const route = `[${req.method.toUpperCase()}]${req.path}` | ||
res.on('response', () => { | ||
next() | ||
}) | ||
reqHandler([ | ||
...middlewares.slice(0), | ||
{ | ||
context: {}, | ||
handler: (req, res, next) => { | ||
const route = `[${req.method.toUpperCase()}]${req.path}` | ||
res.on('response', () => { | ||
next() | ||
}) | ||
if (wayfarer(route, req, res) === 404) res.send(404) | ||
} | ||
if (wayfarer(route, req, res) === 404) res.send(404) | ||
} | ||
], | ||
req, | ||
res | ||
} | ||
], | ||
req, | ||
res | ||
)() | ||
@@ -103,2 +101,3 @@ }, | ||
} | ||
methods.forEach((method) => { | ||
@@ -105,0 +104,0 @@ app[method] = (path, handler, ctx) => app.route(method, path, handler, ctx) |
{ | ||
"name": "restana", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Super fast and minimalist web framework for building REST micro-services.", | ||
@@ -36,3 +36,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"wayfarer": "6.x.x" | ||
"fast-url-parser": "^1.1.3", | ||
"wayfarer": "^6.6.4" | ||
}, | ||
@@ -42,7 +43,7 @@ "devDependencies": { | ||
"mocha": "3.x.x", | ||
"morgan": "1.x.x", | ||
"morgan": "^1.9.0", | ||
"standard": "^11.0.1", | ||
"supertest": "3.x.x", | ||
"winston": "2.x.x" | ||
"winston": "^2.4.2" | ||
} | ||
} |
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
9585
2
161
+ Addedfast-url-parser@^1.1.3
+ Addedfast-url-parser@1.1.3(transitive)
+ Addedpunycode@1.4.1(transitive)
Updatedwayfarer@^6.6.4