A simple file sharing site with an easy to use API and online panel.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
409B

  1. const verify = require('./verify.js');
  2. const wrap = require('./wrap.js');
  3. // Verifies the entire request body is well formed
  4. const verifyBody = expected => wrap(async (req, res, next) => {
  5. try {
  6. await Promise.all(expected.map(e => verify(req.body[e.name], e)));
  7. next();
  8. } catch(err) {
  9. res.status(err.code).json({message: err.message});
  10. }
  11. });
  12. module.exports = verifyBody;