Comparing version 1.0.31 to 1.0.32
{ | ||
"name": "server", | ||
"version": "1.0.31", | ||
"version": "1.0.32", | ||
"description": "A modern and powerful server for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://serverjs.io/", |
@@ -17,4 +17,5 @@ const run = require('server/test/run'); | ||
it('just logs it if the headers were already sent', async () => { | ||
const simple = () => { throw new Error('Hello Error'); }; | ||
it('is not called if the previous one finishes', async () => { | ||
let called = false; | ||
const simple = () => { called = true; }; | ||
const out = {}; | ||
@@ -24,3 +25,3 @@ const res = await run({ raw: true, log: storeLog(out) }, () => 'Hello world', simple).get('/'); | ||
expect(res.body).toBe('Hello world'); | ||
expect(out.log).toMatch('Hello Error'); | ||
expect(called).toBe(false); | ||
}); | ||
@@ -27,0 +28,0 @@ |
@@ -5,5 +5,5 @@ // Integration - test the router within the whole server functionality | ||
const { get, post, put, del, sub, error } = server.router; | ||
const { status } = server.reply; | ||
// Mock middlewares and data: | ||
@@ -32,2 +32,13 @@ const question = { answer: 42 }; | ||
it('can skip a request', async () => { | ||
let called = false; | ||
const notCalled = ctx => { | ||
called = true; | ||
}; | ||
const mid = get('/', () => status(200).send('Done'), notCalled); | ||
await run(mid).get('/'); | ||
expect(called).toBe(false); | ||
}); | ||
it('can do a POST request', async () => { | ||
@@ -34,0 +45,0 @@ const mid = post('/', ctx => ctx.data); |
@@ -31,2 +31,4 @@ const load = require('loadware'); | ||
try { | ||
if (ctx.req.solved) return; | ||
// DO NOT MERGE; the else is relevant only for ctx.error | ||
@@ -37,4 +39,7 @@ if (ctx.error) { | ||
assert(mid.error instanceof Function, 'Error handler should be a function'); | ||
let ret = await mid.error(ctx); | ||
const ret = await mid.error(ctx); | ||
await processReturn(ctx, ret); | ||
if (ctx.res.headersSent) { | ||
ctx.req.solved = true; | ||
} | ||
} | ||
@@ -44,4 +49,7 @@ } | ||
else { | ||
let ret = await mid(ctx); | ||
const ret = await mid(ctx); | ||
await processReturn(ctx, ret); | ||
if (ctx.res.headersSent) { | ||
ctx.req.solved = true; | ||
} | ||
} | ||
@@ -48,0 +56,0 @@ } catch (err) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
788674
4004
99
0
0
0
1