params.js 430 B

1234567891011121314151617
  1. const config = require('../config');
  2. const storage = require('../storage');
  3. module.exports = function(req, res) {
  4. const max = req.user ? config.max_downloads : config.anon_max_downloads;
  5. const dlimit = req.body.dlimit;
  6. if (!dlimit || dlimit > max) {
  7. return res.sendStatus(400);
  8. }
  9. try {
  10. storage.setField(req.params.id, 'dlimit', dlimit);
  11. res.sendStatus(200);
  12. } catch (e) {
  13. res.sendStatus(404);
  14. }
  15. };