routes.js 781 B

1234567891011121314151617181920
  1. const config = require('../config.js')
  2. const routes = require('express').Router()
  3. const uploadController = require('../controllers/uploadController')
  4. const galleryController = require('../controllers/galleryController')
  5. routes.get ('/info', (req, res, next) => {
  6. if(!config.privacy.public)
  7. if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('not-authorized')
  8. return res.json({
  9. maxFileSize: config.uploads.maxsize.slice(0, -2),
  10. urlPrefix: config.uploads.prefix
  11. })
  12. })
  13. routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next))
  14. routes.get ('/gallery', (req, res, next) => galleryController.list(req, res, next))
  15. routes.get ('/gallery/test', (req, res, next) => galleryController.test(req, res, next))
  16. module.exports = routes