api.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334
  1. const config = require('../config.js')
  2. const routes = require('express').Router()
  3. const uploadController = require('../controllers/uploadController')
  4. const albumsController = require('../controllers/albumsController')
  5. const tokenController = require('../controllers/tokenController')
  6. routes.get ('/check', (req, res, next) => {
  7. return res.json({
  8. private: config.private,
  9. maxFileSize: config.uploads.maxSize
  10. })
  11. })
  12. routes.get ('/uploads', (req, res, next) => uploadController.list(req, res))
  13. routes.get ('/uploads/:page', (req, res, next) => uploadController.list(req, res))
  14. routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next))
  15. routes.post ('/upload/delete', (req, res, next) => uploadController.delete(req, res, next))
  16. routes.post ('/upload/:albumid', (req, res, next) => uploadController.upload(req, res, next))
  17. routes.get ('/album/:id', (req, res, next) => uploadController.list(req, res, next))
  18. routes.get ('/album/:id/:page', (req, res, next) => uploadController.list(req, res, next))
  19. routes.get ('/albums', (req, res, next) => albumsController.list(req, res, next))
  20. routes.get ('/albums/:sidebar', (req, res, next) => albumsController.list(req, res, next))
  21. routes.post ('/albums', (req, res, next) => albumsController.create(req, res, next))
  22. routes.post ('/albums/delete', (req, res, next) => albumsController.delete(req, res, next))
  23. routes.post ('/albums/rename', (req, res, next) => albumsController.rename(req, res, next))
  24. routes.get ('/albums/test', (req, res, next) => albumsController.test(req, res, next))
  25. routes.get ('/tokens', (req, res, next) => tokenController.list(req, res))
  26. routes.post ('/tokens/verify', (req, res, next) => tokenController.verify(req, res))
  27. routes.post ('/tokens/change', (req, res, next) => tokenController.change(req, res))
  28. module.exports = routes