mirror of
https://github.com/Foltik/Shimapan
synced 2024-12-04 11:24:32 -05:00
14 lines
372 B
JavaScript
14 lines
372 B
JavaScript
const verify = require('./verify.js');
|
|
|
|
// Verifies the entire request query is well formed
|
|
const verifyQuery = expected => 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;
|