api.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const authController = require('../controllers/authController')
  7. routes.get ('/check', (req, res, next) => {
  8. return res.json({
  9. private: config.private,
  10. maxFileSize: config.uploads.maxSize
  11. })
  12. })
  13. routes.post ('/login', (req, res, next) => authController.verify(req, res, next))
  14. routes.post ('/register', (req, res, next) => authController.register(req, res, next))
  15. routes.post ('/password/change', (req, res, next) => authController.changePassword(req, res, next))
  16. routes.get ('/uploads', (req, res, next) => uploadController.list(req, res))
  17. routes.get ('/uploads/:page', (req, res, next) => uploadController.list(req, res))
  18. routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next))
  19. routes.post ('/upload/delete', (req, res, next) => uploadController.delete(req, res, next))
  20. routes.post ('/upload/:albumid', (req, res, next) => uploadController.upload(req, res, next))
  21. routes.get ('/album/get/:identifier', (req, res, next) => albumsController.get(req, res, next))
  22. routes.get ('/album/:id', (req, res, next) => uploadController.list(req, res, next))
  23. routes.get ('/album/:id/:page', (req, res, next) => uploadController.list(req, res, next))
  24. routes.get ('/albums', (req, res, next) => albumsController.list(req, res, next))
  25. routes.get ('/albums/:sidebar', (req, res, next) => albumsController.list(req, res, next))
  26. routes.post ('/albums', (req, res, next) => albumsController.create(req, res, next))
  27. routes.post ('/albums/delete', (req, res, next) => albumsController.delete(req, res, next))
  28. routes.post ('/albums/rename', (req, res, next) => albumsController.rename(req, res, next))
  29. routes.get ('/albums/test', (req, res, next) => albumsController.test(req, res, next))
  30. routes.get ('/tokens', (req, res, next) => tokenController.list(req, res))
  31. routes.post ('/tokens/verify', (req, res, next) => tokenController.verify(req, res))
  32. routes.post ('/tokens/change', (req, res, next) => tokenController.change(req, res))
  33. module.exports = routes