|
|
@@ -15,7 +15,8 @@ import {
|
|
|
generateUnavailableWhenMaintenanceModeMiddleware, generateUnavailableWhenMaintenanceModeMiddlewareForApi,
|
|
|
} from '../middlewares/unavailable-when-maintenance-mode';
|
|
|
|
|
|
-import { attachmentRoutesFactory } from './attachment';
|
|
|
+import * as attachment from './attachment';
|
|
|
+import { routesFactory as attachmentApiRoutesFactory } from './attachment/api';
|
|
|
import * as forgotPassword from './forgot-password';
|
|
|
import nextFactory from './next';
|
|
|
import * as userActivation from './user-activation';
|
|
|
@@ -44,7 +45,7 @@ module.exports = function(crowi, app) {
|
|
|
const loginPassport = require('./login-passport')(crowi, app);
|
|
|
const me = require('./me')(crowi, app);
|
|
|
const admin = require('./admin')(crowi, app);
|
|
|
- const attachment = attachmentRoutesFactory(crowi);
|
|
|
+ const attachmentApi = attachmentApiRoutesFactory(crowi).api;
|
|
|
const comment = require('./comment')(crowi, app);
|
|
|
const tag = require('./tag')(crowi, app);
|
|
|
const search = require('./search')(crowi, app);
|
|
|
@@ -110,7 +111,7 @@ module.exports = function(crowi, app) {
|
|
|
app.post('/_api/admin/import/qiita' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.importDataFromQiita);
|
|
|
app.post('/_api/admin/import/testQiitaAPI' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.testQiitaAPI);
|
|
|
|
|
|
- app.get('/attachment/brand-logo' , certifyBrandLogo, loginRequired, attachment.api.getBrandLogo);
|
|
|
+ app.get('/attachment/brand-logo' , certifyBrandLogo, loginRequired, attachmentApi.getBrandLogo);
|
|
|
|
|
|
/*
|
|
|
* Routes below are unavailable when maintenance mode
|
|
|
@@ -144,11 +145,11 @@ module.exports = function(crowi, app) {
|
|
|
apiV1Router.post('/comments.update' , comment.api.validators.add(), accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, addActivity, comment.api.update);
|
|
|
apiV1Router.post('/comments.remove' , accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, addActivity, comment.api.remove);
|
|
|
|
|
|
- apiV1Router.post('/attachments.add' , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly , excludeReadOnlyUser, addActivity ,attachment.api.add);
|
|
|
- apiV1Router.post('/attachments.uploadProfileImage' , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly , excludeReadOnlyUser, attachment.api.uploadProfileImage);
|
|
|
- apiV1Router.post('/attachments.remove' , accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, addActivity ,attachment.api.remove);
|
|
|
- apiV1Router.post('/attachments.removeProfileImage' , accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, attachment.api.removeProfileImage);
|
|
|
- apiV1Router.get('/attachments.limit' , accessTokenParser , loginRequiredStrictly, attachment.api.limit);
|
|
|
+ apiV1Router.post('/attachments.add' , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly , excludeReadOnlyUser, addActivity , attachmentApi.add);
|
|
|
+ apiV1Router.post('/attachments.uploadProfileImage' , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly , excludeReadOnlyUser, attachmentApi.uploadProfileImage);
|
|
|
+ apiV1Router.post('/attachments.remove' , accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, addActivity ,attachmentApi.remove);
|
|
|
+ apiV1Router.post('/attachments.removeProfileImage' , accessTokenParser , loginRequiredStrictly , excludeReadOnlyUser, attachmentApi.removeProfileImage);
|
|
|
+ apiV1Router.get('/attachments.limit' , accessTokenParser , loginRequiredStrictly, attachmentApi.limit);
|
|
|
|
|
|
// API v1
|
|
|
app.use('/_api', unavailableWhenMaintenanceModeForApi, apiV1Router);
|
|
|
@@ -157,9 +158,9 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
app.get('/me' , loginRequiredStrictly, next.delegateToNext);
|
|
|
app.get('/me/*' , loginRequiredStrictly, next.delegateToNext);
|
|
|
- app.get('/attachment/:id([0-9a-z]{24})' , certifySharedPageAttachmentMiddleware , loginRequired, attachment.api.get);
|
|
|
- app.get('/attachment/profile/:id([0-9a-z]{24})' , loginRequired, attachment.api.get);
|
|
|
- app.get('/download/:id([0-9a-z]{24})' , certifySharedPageAttachmentMiddleware, loginRequired, attachment.api.download);
|
|
|
+ app.get('/attachment/:id([0-9a-z]{24})' , certifySharedPageAttachmentMiddleware , loginRequired, attachment.validateGetRequest, attachmentApi.get);
|
|
|
+ app.get('/attachment/profile/:id([0-9a-z]{24})' , loginRequired, attachment.validateGetRequest, attachmentApi.get);
|
|
|
+ app.get('/download/:id([0-9a-z]{24})' , certifySharedPageAttachmentMiddleware, loginRequired, attachment.validateGetRequest, attachmentApi.download);
|
|
|
|
|
|
app.get('/_search' , loginRequired, next.delegateToNext);
|
|
|
|