refactor: add missing helpers.tryRoute

isekai-main
Barış Soner Uşaklı 3 years ago
parent 8b8fe39303
commit d4da98404c

@ -3,27 +3,28 @@
const express = require('express');
const uploadsController = require('../controllers/uploads');
const helpers = require('./helpers');
module.exports = function (app, middleware, controllers) {
const router = express.Router();
app.use('/api', router);
router.get('/config', middleware.applyCSRF, middleware.authenticateRequest, controllers.api.getConfig);
router.get('/config', middleware.applyCSRF, middleware.authenticateRequest, helpers.tryRoute(controllers.api.getConfig));
router.get('/self', controllers.user.getCurrentUser);
router.get('/user/uid/:uid', middleware.canViewUsers, controllers.user.getUserByUID);
router.get('/user/username/:username', middleware.canViewUsers, controllers.user.getUserByUsername);
router.get('/user/email/:email', middleware.canViewUsers, controllers.user.getUserByEmail);
router.get('/self', helpers.tryRoute(controllers.user.getCurrentUser));
router.get('/user/uid/:uid', middleware.canViewUsers, helpers.tryRoute(controllers.user.getUserByUID));
router.get('/user/username/:username', middleware.canViewUsers, helpers.tryRoute(controllers.user.getUserByUsername));
router.get('/user/email/:email', middleware.canViewUsers, helpers.tryRoute(controllers.user.getUserByEmail));
router.get('/user/uid/:userslug/export/posts', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, controllers.user.exportPosts);
router.get('/user/uid/:userslug/export/uploads', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, controllers.user.exportUploads);
router.get('/user/uid/:userslug/export/profile', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, controllers.user.exportProfile);
router.get('/user/uid/:userslug/export/posts', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, helpers.tryRoute(controllers.user.exportPosts));
router.get('/user/uid/:userslug/export/uploads', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, helpers.tryRoute(controllers.user.exportUploads));
router.get('/user/uid/:userslug/export/profile', middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.checkAccountPermissions, middleware.exposeUid, helpers.tryRoute(controllers.user.exportProfile));
router.get('/categories/:cid/moderators', controllers.api.getModerators);
router.get('/recent/posts/:term?', controllers.posts.getRecentPosts);
router.get('/unread/total', middleware.authenticateRequest, middleware.ensureLoggedIn, controllers.unread.unreadTotal);
router.get('/topic/teaser/:topic_id', controllers.topics.teaser);
router.get('/topic/pagination/:topic_id', controllers.topics.pagination);
router.get('/categories/:cid/moderators', helpers.tryRoute(controllers.api.getModerators));
router.get('/recent/posts/:term?', helpers.tryRoute(controllers.posts.getRecentPosts));
router.get('/unread/total', middleware.authenticateRequest, middleware.ensureLoggedIn, helpers.tryRoute(controllers.unread.unreadTotal));
router.get('/topic/teaser/:topic_id', helpers.tryRoute(controllers.topics.teaser));
router.get('/topic/pagination/:topic_id', helpers.tryRoute(controllers.topics.pagination));
const multipart = require('connect-multiparty');
const multipartMiddleware = multipart();
@ -35,6 +36,14 @@ module.exports = function (app, middleware, controllers) {
middleware.applyCSRF,
];
router.post('/post/upload', middlewares, uploadsController.uploadPost);
router.post('/user/:userslug/uploadpicture', middlewares.concat([middleware.exposeUid, middleware.authenticateRequest, middleware.ensureLoggedIn, middleware.canViewUsers, middleware.checkAccountPermissions]), controllers.accounts.edit.uploadPicture);
router.post('/post/upload', middlewares, helpers.tryRoute(uploadsController.uploadPost));
router.post('/user/:userslug/uploadpicture',
middlewares.concat([
middleware.exposeUid,
middleware.authenticateRequest,
middleware.ensureLoggedIn,
middleware.canViewUsers,
middleware.checkAccountPermissions,
]),
helpers.tryRoute(controllers.accounts.edit.uploadPicture));
};

Loading…
Cancel
Save