mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-16 01:28:07 -05:00
15 lines
413 B
JavaScript
15 lines
413 B
JavaScript
|
const verify = require('./verify.js');
|
||
|
const wrap = require('./wrap.js');
|
||
|
|
||
|
// Verifies the entire request query is well formed
|
||
|
const verifyQuery = expected => wrap(async (req, res, next) => {
|
||
|
try {
|
||
|
await Promise.all(expected.map(e => verify(req.query[e.name], e)));
|
||
|
next();
|
||
|
} catch(err) {
|
||
|
res.status(err.code).json({message: err.message});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = verifyQuery;
|