Comparing version 0.5.2 to 0.5.3
@@ -9,2 +9,3 @@ const { format } = require('util'); | ||
msg = msg || err; | ||
let handler = typeof args[0] == 'function' ? args.shift() : false; | ||
@@ -11,0 +12,0 @@ let e = errors[err](format(msg, ...args)); |
@@ -32,6 +32,6 @@ const path = require('path'); | ||
app.expose(shared);\n | ||
app.route(({ post, get, del, head, patch, put }) => {\n\n\t});\n | ||
app.on('error', function(req, res, err, send){\n\n\t});\n | ||
app.beforeStart = async function(){\n\n\t};\n | ||
app.afterStop = async function(){\n\n\t};\n | ||
app.route(({ post, get, del, head, patch, put }) => {\n\n });\n | ||
app.on('error', function(input, err, send){\n\n });\n | ||
app.beforeStart = async function(){\n\n };\n | ||
app.afterStop = async function(){\n\n };\n | ||
return app; | ||
@@ -46,7 +46,7 @@ }\n`; | ||
function generateRunFile({ confPath, confType }, projDir, projName){ | ||
let cps = confPath ? `,\n\tconfPath: '${confPath}'` : ''; | ||
let cts = confType ? `,\n\tconfType: '${confType}'` : ''; | ||
let cps = confPath ? `,\n confPath: '${confPath}'` : ''; | ||
let cts = confType ? `,\n confType: '${confType}'` : ''; | ||
let src = `#!node\n | ||
const { run } = require('nodecaf'); | ||
run({\n\tinit: require('../lib/main')${cps}${cts}\n});\n`; | ||
run({\n init: require('../lib/main')${cps}${cts}\n});\n`; | ||
@@ -81,4 +81,4 @@ fs.mkdirSync(projDir + '/bin/'); | ||
if(!('nodecaf' in (pkgInfo.dependencies || []))) | ||
console.log('Install nodecaf localy with:\n\t\tnpm i nodecaf'); | ||
console.log('Install your app run binary with:\n\t\tnpm link'); | ||
console.log('Install nodecaf localy with:\n npm i nodecaf'); | ||
console.log('Install your app run binary with:\n npm link'); | ||
}; |
{ | ||
"name": "nodecaf", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Nodecaf is an HTTP API framework running Express behind the scenes and providing some generally necessary functionality to speed up your development.", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -217,2 +217,9 @@ //const wtf = require('wtfnode'); | ||
it('Should not fail when calling close sucessively', async () => { | ||
let app = new AppServer(); | ||
await app.start(); | ||
await app.stop(); | ||
assert.doesNotReject( app.stop() ); | ||
}); | ||
}); | ||
@@ -605,4 +612,37 @@ | ||
it('Should show default message for REST errors thrown as strings', async () => { | ||
let app = new AppServer(); | ||
app.route(function({ post }){ | ||
post('/bar', ({ error }) => { | ||
error('NotFound'); | ||
}); | ||
}); | ||
await app.start(); | ||
let m = JSON.parse((await post('http://localhost:80/bar')).body).message; | ||
assert.strictEqual(m, 'NotFound'); | ||
await app.stop(); | ||
}); | ||
it('Should execute user error handler even if headers were already sent', async () => { | ||
let app = new AppServer(); | ||
app.route(function({ post }){ | ||
post('/bar', ({ res }) => { | ||
res.end(); | ||
throw new Error(); | ||
}); | ||
}); | ||
let gotHere = false; | ||
app.on('error', function(){ | ||
gotHere = true; | ||
}); | ||
await app.start(); | ||
await post('http://localhost:80/bar'); | ||
await app.stop(); | ||
assert(gotHere); | ||
}); | ||
}); | ||
//after(() => wtf.dump()); |
Sorry, the diff of this file is not supported yet
49228
990