Comparing version 0.4.0 to 0.5.0
@@ -13,10 +13,6 @@ /** | ||
query: request.query || {}, | ||
statusCode: 200, | ||
}); | ||
const getEmpty = () => ({ | ||
headers: {}, | ||
body: {}, | ||
params: {}, | ||
query: {}, | ||
}); | ||
const getEmpty = () => extractFromRequest({}); | ||
@@ -23,0 +19,0 @@ module.exports = { |
@@ -15,10 +15,10 @@ /** | ||
return async (container) => { | ||
const { body } = await request(container)[method](buildedUrl); | ||
const { body, statusCode } = await request(container)[method](buildedUrl); | ||
const containerMap = fromJS(container); | ||
if (!key) { | ||
return containerMap.mergeDeep(fromJS({ body })).toJS(); | ||
return containerMap.mergeDeep(fromJS({ body, statusCode })).toJS(); | ||
} | ||
return containerMap.mergeDeep(fromJS({ body: { [key]: body } })).toJS(); | ||
return containerMap.mergeDeep(fromJS({ body: { [key]: body }, statusCode })).toJS(); | ||
}; | ||
}; |
{ | ||
"name": "nodegate", | ||
"description": "API gateway made simple, fast and easy to configure.", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"author": "Julien Martin <martin.julien82@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -11,3 +11,3 @@ /** | ||
const express = require('express'); | ||
const { execute } = require('../entities/pipeline'); | ||
const { execute } = require('../entities/route'); | ||
const { getConfiguration } = require('../services/configuration'); | ||
@@ -32,2 +32,9 @@ | ||
const toArray = (value) => { | ||
if (!Array.isArray(value)) { | ||
return [value]; | ||
} | ||
return value; | ||
}; | ||
const nodegate = () => { | ||
@@ -43,18 +50,10 @@ const expressApp = buildExpressApp(); | ||
app.beforeEach = (modifiers) => { | ||
let modifiersToAdd = modifiers; | ||
if (!Array.isArray(modifiers)) { | ||
modifiersToAdd = [modifiers]; | ||
} | ||
modifiersToAdd.forEach(modifier => beforeEach.push(modifier)); | ||
toArray(modifiers).forEach(modifier => beforeEach.push(modifier)); | ||
}; | ||
app.route = (routes) => { | ||
let routesToAdd = routes; | ||
if (!Array.isArray(routes)) { | ||
routesToAdd = [routes]; | ||
} | ||
routesToAdd.forEach((route) => { | ||
toArray(routes).forEach((route) => { | ||
expressApp[route.method.toLowerCase()]( | ||
route.path, | ||
execute(route.pipeline, beforeEach), | ||
execute(route, beforeEach), | ||
); | ||
@@ -61,0 +60,0 @@ }); |
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
15396
16
341