1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-09-20 19:06:35 -04:00
shimapan/app/util/verifyQuery.js

14 lines
372 B
JavaScript
Raw Normal View History

const verify = require('./verify.js');
// Verifies the entire request query is well formed
2019-01-02 14:27:20 -05:00
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});
}
2019-01-02 14:27:20 -05:00
};
module.exports = verifyQuery;