mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 22:12:02 +02:00
Initial commit
This commit is contained in:
25
node_modules/server/router/error.js
generated
vendored
Normal file
25
node_modules/server/router/error.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
const join = require('../src/join');
|
||||
const parse = require('./parse');
|
||||
const params = require('./path-to-regexp-wrap')();
|
||||
|
||||
module.exports = (...all) => {
|
||||
// Extracted or otherwise it'd shift once per call; also more performant
|
||||
const { path, middle } = parse(all);
|
||||
const match = params(path || '');
|
||||
|
||||
const generic = () => {};
|
||||
generic.error = async ctx => {
|
||||
|
||||
// Only do this if the correct path
|
||||
ctx.error.code = ctx.error.code || '';
|
||||
ctx.error.params = match(ctx.error.code);
|
||||
|
||||
// Add an extra-allowing initial matching
|
||||
if (!ctx.error.params && ctx.error.code.slice(0, path.length) !== path) return;
|
||||
|
||||
const ret = await middle[0](ctx);
|
||||
delete ctx.error;
|
||||
return ret;
|
||||
};
|
||||
return generic;
|
||||
};
|
Reference in New Issue
Block a user