Comparing version 7.0.6 to 7.1.0
@@ -7,3 +7,2 @@ #!/usr/bin/env node | ||
// Packages | ||
const asyncToGen = require('async-to-gen/register') | ||
const updateNotifier = require('update-notifier') | ||
@@ -59,2 +58,3 @@ const nodeVersion = require('node-version') | ||
if (!isAsyncSupported()) { | ||
const asyncToGen = require('async-to-gen/register') | ||
// Support for keywords "async" and "await" | ||
@@ -64,4 +64,7 @@ const pathSep = process.platform === 'win32' ? '\\\\' : '/' | ||
// This is required to make transpilation work on Windows | ||
const fileDirectoryPath = path.parse(file).dir.split(path.sep).join(pathSep) | ||
asyncToGen({ | ||
includes: new RegExp(`.*${directoryName}?${pathSep}(lib|bin)|${file}.*`), | ||
includes: new RegExp(`.*${directoryName}?${pathSep}(lib|bin)|${fileDirectoryPath}.*`), | ||
excludes: null, | ||
@@ -68,0 +71,0 @@ sourceMaps: false |
@@ -8,10 +8,10 @@ // Native | ||
const isStream = require('isstream') | ||
const Q = require('q') | ||
const Promise = require('bluebird') | ||
const {resolve} = Promise | ||
const DEV = process.env.NODE_ENV === 'development' | ||
const TESTING = process.env.NODE_ENV === 'test' | ||
const serve = fn => server(Q.async(function * (req, res) { | ||
yield exports.run(req, res, fn) | ||
})) | ||
const serve = fn => server((req, res) => exports.run(req, res, fn)) | ||
@@ -24,19 +24,16 @@ module.exports = exports = serve | ||
exports.run = Q.async(function * (req, res, fn) { | ||
try { | ||
const val = yield fn(req, res) | ||
exports.run = (req, res, fn) => | ||
resolve(fn(req, res)) | ||
.then(val => { | ||
if (val === null) { | ||
send(res, 204, null) | ||
} | ||
if (val === null) { | ||
send(res, 204, null) | ||
} | ||
// Return a undefined-null value -> send | ||
if (undefined !== val) { | ||
send(res, res.statusCode || 200, val) | ||
} | ||
}) | ||
.catch(err => sendError(req, res, err)) | ||
// Return a undefined-null value -> send | ||
if (undefined !== val) { | ||
send(res, res.statusCode || 200, val) | ||
} | ||
} catch (err) { | ||
sendError(req, res, err) | ||
} | ||
}) | ||
// maps requests to buffered raw bodies so that | ||
@@ -129,5 +126,5 @@ // multiple calls to `json` work as expected | ||
function sendError(req, res, {statusCode, message, stack}) { | ||
function sendError(req, res, {statusCode, status, message, stack}) { | ||
if (statusCode) { | ||
send(res, statusCode, DEV ? stack : message) | ||
send(res, statusCode || status, DEV ? stack : message) | ||
} else { | ||
@@ -134,0 +131,0 @@ send(res, 500, DEV ? stack : 'Internal Server Error') |
{ | ||
"name": "micro", | ||
"version": "7.0.6", | ||
"version": "7.1.0", | ||
"description": "Asynchronous HTTP microservices", | ||
@@ -47,5 +47,5 @@ "main": "./lib/server.js", | ||
"devDependencies": { | ||
"ava": "0.18.1", | ||
"husky": "0.13.1", | ||
"request": "2.74.0", | ||
"ava": "0.18.2", | ||
"husky": "0.13.2", | ||
"request": "2.80.0", | ||
"request-promise": "4.1.1", | ||
@@ -55,7 +55,8 @@ "resumer": "0.0.0", | ||
"then-sleep": "1.0.1", | ||
"xo": "0.17.0" | ||
"xo": "0.17.1" | ||
}, | ||
"dependencies": { | ||
"args": "2.2.4", | ||
"args": "2.3.0", | ||
"async-to-gen": "1.3.2", | ||
"bluebird": "3.5.0", | ||
"boxen": "1.0.0", | ||
@@ -65,3 +66,3 @@ "chalk": "1.1.3", | ||
"detect-port": "1.1.0", | ||
"ip": "1.1.4", | ||
"ip": "1.1.5", | ||
"is-async-supported": "1.2.0", | ||
@@ -71,6 +72,5 @@ "isstream": "0.1.2", | ||
"node-version": "1.0.0", | ||
"q": "1.4.1", | ||
"raw-body": "2.2.0", | ||
"update-notifier": "1.0.3" | ||
"update-notifier": "2.1.0" | ||
} | ||
} |
21482
267
+ Addedbluebird@3.5.0
+ Addedargs@2.3.0(transitive)
+ Addedbluebird@3.5.0(transitive)
+ Addedcamelcase@4.0.0(transitive)
+ Addedconfigstore@3.1.5(transitive)
+ Addedcrypto-random-string@1.0.0(transitive)
+ Addeddot-prop@4.2.1(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedgot@6.7.1(transitive)
+ Addedip@1.1.5(transitive)
+ Addedlatest-version@3.1.0(transitive)
+ Addedlazy-req@2.0.0(transitive)
+ Addedloud-rejection@1.3.0(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedminimist@1.2.0(transitive)
+ Addedpackage-json@4.0.1(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpkginfo@0.4.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsignal-exit@2.1.2(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedunique-string@1.0.0(transitive)
+ Addedunzip-response@2.0.1(transitive)
+ Addedupdate-notifier@2.1.0(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedxdg-basedir@3.0.0(transitive)
- Removedq@1.4.1
- Removedargs@2.2.4(transitive)
- Removedboxen@0.6.0(transitive)
- Removedcamelcase@2.1.14.1.0(transitive)
- Removedconfigstore@2.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddot-prop@3.0.0(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfilled-array@1.1.0(transitive)
- Removedgot@5.7.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedip@1.1.4(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlatest-version@2.0.0(transitive)
- Removedlazy-req@1.1.0(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednode-status-codes@1.0.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedpackage-json@2.4.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedpkginfo@0.4.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedq@1.4.1(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedslide@1.1.6(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtimed-out@3.1.3(transitive)
- Removedunzip-response@1.0.2(transitive)
- Removedupdate-notifier@1.0.3(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@2.0.3(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)
- Removedxdg-basedir@2.0.0(transitive)
Updatedargs@2.3.0
Updatedip@1.1.5
Updatedupdate-notifier@2.1.0