Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "uquik", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "uQuik HTTP(S) framework", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"wrk": "wrk -t4 -c2500 -d60s -R62000 http://127.0.0.1:5000", | ||
"wrk": "wrk -t4 -c2500 -d60s http://127.0.0.1:5000", | ||
"wrk-post": "wrk -s examples/post.lua -t4 -c2500 -d60s -R31000 http://127.0.0.1:5000" | ||
@@ -15,0 +15,0 @@ }, |
@@ -63,3 +63,3 @@ const uWebSockets = require('uWebSockets.js') | ||
this.handlers = new Map([ | ||
['on_not_found', null], | ||
['on_not_found', (request, response) => response.status(404).send()], | ||
['on_error', (request, response, error) => { | ||
@@ -154,2 +154,6 @@ if (process.env.NODE_ENV === 'development') console.log(error) | ||
listen (port, host = '127.0.0.1') { | ||
// Adding not found handler (404) | ||
this.any('/*', (request, response) => this.handlers.get('on_not_found')(request, response)) | ||
this.routes_locked = true | ||
return new Promise((resolve, reject) => | ||
@@ -227,16 +231,3 @@ this.uws_instance.listen(host, port, (listenSocket) => { | ||
// Store not_found handler and bind it as a catchall route | ||
if (this.handlers.get('on_not_found') === null) { | ||
this.handlers.set('on_not_found', handler) | ||
return setTimeout( | ||
(reference) => { | ||
reference.any('/*', (request, response) => reference.handlers.get('on_not_found')(request, response)) | ||
reference.routes_locked = true | ||
}, | ||
0, | ||
this | ||
) | ||
} | ||
// Do not allow user to re-register not found handler | ||
throw new Error('A Not Found handler has already been registered.') | ||
this.handlers.set('on_not_found', handler) | ||
} | ||
@@ -243,0 +234,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
421159
17500