mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-05 01:40:21 +03:00
Moved upload mw into api app
- Moved upload mw from shared to api as it is not shared (except within the API) - This file is only used in one part of the app, this updates the code structure to reflect this - This is one of many similar changes needed to make it easier to refactor to the existing setup
This commit is contained in:
parent
05cf4f495d
commit
36b42505ea
@ -5,9 +5,6 @@ const mw = require('./middleware');
|
|||||||
|
|
||||||
const shared = require('../../../shared');
|
const shared = require('../../../shared');
|
||||||
|
|
||||||
// Handling uploads & imports
|
|
||||||
const upload = shared.middlewares.upload;
|
|
||||||
|
|
||||||
module.exports = function apiRoutes() {
|
module.exports = function apiRoutes() {
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@ -55,7 +52,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/settings/routes/yaml', mw.authAdminApi, http(apiCanary.settings.download));
|
router.get('/settings/routes/yaml', mw.authAdminApi, http(apiCanary.settings.download));
|
||||||
router.post('/settings/routes/yaml',
|
router.post('/settings/routes/yaml',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('routes'),
|
apiMw.upload.single('routes'),
|
||||||
shared.middlewares.validation.upload({type: 'routes'}),
|
shared.middlewares.validation.upload({type: 'routes'}),
|
||||||
http(apiCanary.settings.upload)
|
http(apiCanary.settings.upload)
|
||||||
);
|
);
|
||||||
@ -92,7 +89,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.post('/members/csv',
|
router.post('/members/csv',
|
||||||
shared.middlewares.labs.members,
|
shared.middlewares.labs.members,
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('membersfile'),
|
apiMw.upload.single('membersfile'),
|
||||||
shared.middlewares.validation.upload({type: 'members'}),
|
shared.middlewares.validation.upload({type: 'members'}),
|
||||||
http(apiCanary.members.importCSV)
|
http(apiCanary.members.importCSV)
|
||||||
);
|
);
|
||||||
@ -127,7 +124,7 @@ module.exports = function apiRoutes() {
|
|||||||
|
|
||||||
router.post('/themes/upload',
|
router.post('/themes/upload',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('file'),
|
apiMw.upload.single('file'),
|
||||||
shared.middlewares.validation.upload({type: 'themes'}),
|
shared.middlewares.validation.upload({type: 'themes'}),
|
||||||
http(apiCanary.themes.upload)
|
http(apiCanary.themes.upload)
|
||||||
);
|
);
|
||||||
@ -151,7 +148,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/db', mw.authAdminApi, http(apiCanary.db.exportContent));
|
router.get('/db', mw.authAdminApi, http(apiCanary.db.exportContent));
|
||||||
router.post('/db',
|
router.post('/db',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('importfile'),
|
apiMw.upload.single('importfile'),
|
||||||
shared.middlewares.validation.upload({type: 'db'}),
|
shared.middlewares.validation.upload({type: 'db'}),
|
||||||
http(apiCanary.db.importContent)
|
http(apiCanary.db.importContent)
|
||||||
);
|
);
|
||||||
@ -197,7 +194,7 @@ module.exports = function apiRoutes() {
|
|||||||
// ## Images
|
// ## Images
|
||||||
router.post('/images/upload',
|
router.post('/images/upload',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('file'),
|
apiMw.upload.single('file'),
|
||||||
shared.middlewares.validation.upload({type: 'images'}),
|
shared.middlewares.validation.upload({type: 'images'}),
|
||||||
shared.middlewares.image.normalize,
|
shared.middlewares.image.normalize,
|
||||||
http(apiCanary.images.upload)
|
http(apiCanary.images.upload)
|
||||||
@ -213,7 +210,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/redirects/json', mw.authAdminApi, http(apiCanary.redirects.download));
|
router.get('/redirects/json', mw.authAdminApi, http(apiCanary.redirects.download));
|
||||||
router.post('/redirects/json',
|
router.post('/redirects/json',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('redirects'),
|
apiMw.upload.single('redirects'),
|
||||||
shared.middlewares.validation.upload({type: 'redirects'}),
|
shared.middlewares.validation.upload({type: 'redirects'}),
|
||||||
http(apiCanary.redirects.upload)
|
http(apiCanary.redirects.upload)
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
cors: require('./cors'),
|
cors: require('./cors'),
|
||||||
updateUserLastSeen: require('./update-user-last-seen'),
|
updateUserLastSeen: require('./update-user-last-seen'),
|
||||||
|
upload: require('./upload'),
|
||||||
versionMatch: require('./version-match')
|
versionMatch: require('./version-match')
|
||||||
};
|
};
|
||||||
|
@ -5,9 +5,6 @@ const apiMw = require('../../middleware');
|
|||||||
|
|
||||||
const shared = require('../../../shared');
|
const shared = require('../../../shared');
|
||||||
|
|
||||||
// Handling uploads & imports
|
|
||||||
const upload = shared.middlewares.upload;
|
|
||||||
|
|
||||||
module.exports = function apiRoutes() {
|
module.exports = function apiRoutes() {
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@ -55,7 +52,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/settings/routes/yaml', mw.authAdminApi, http(apiv2.settings.download));
|
router.get('/settings/routes/yaml', mw.authAdminApi, http(apiv2.settings.download));
|
||||||
router.post('/settings/routes/yaml',
|
router.post('/settings/routes/yaml',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('routes'),
|
apiMw.upload.single('routes'),
|
||||||
shared.middlewares.validation.upload({type: 'routes'}),
|
shared.middlewares.validation.upload({type: 'routes'}),
|
||||||
http(apiv2.settings.upload)
|
http(apiv2.settings.upload)
|
||||||
);
|
);
|
||||||
@ -100,7 +97,7 @@ module.exports = function apiRoutes() {
|
|||||||
|
|
||||||
router.post('/themes/upload',
|
router.post('/themes/upload',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('file'),
|
apiMw.upload.single('file'),
|
||||||
shared.middlewares.validation.upload({type: 'themes'}),
|
shared.middlewares.validation.upload({type: 'themes'}),
|
||||||
http(apiv2.themes.upload)
|
http(apiv2.themes.upload)
|
||||||
);
|
);
|
||||||
@ -124,7 +121,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/db', mw.authAdminApi, http(apiv2.db.exportContent));
|
router.get('/db', mw.authAdminApi, http(apiv2.db.exportContent));
|
||||||
router.post('/db',
|
router.post('/db',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('importfile'),
|
apiMw.upload.single('importfile'),
|
||||||
shared.middlewares.validation.upload({type: 'db'}),
|
shared.middlewares.validation.upload({type: 'db'}),
|
||||||
http(apiv2.db.importContent)
|
http(apiv2.db.importContent)
|
||||||
);
|
);
|
||||||
@ -167,7 +164,7 @@ module.exports = function apiRoutes() {
|
|||||||
// ## Images
|
// ## Images
|
||||||
router.post('/images/upload',
|
router.post('/images/upload',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('file'),
|
apiMw.upload.single('file'),
|
||||||
shared.middlewares.validation.upload({type: 'images'}),
|
shared.middlewares.validation.upload({type: 'images'}),
|
||||||
shared.middlewares.image.normalize,
|
shared.middlewares.image.normalize,
|
||||||
http(apiv2.images.upload)
|
http(apiv2.images.upload)
|
||||||
@ -183,7 +180,7 @@ module.exports = function apiRoutes() {
|
|||||||
router.get('/redirects/json', mw.authAdminApi, http(apiv2.redirects.download));
|
router.get('/redirects/json', mw.authAdminApi, http(apiv2.redirects.download));
|
||||||
router.post('/redirects/json',
|
router.post('/redirects/json',
|
||||||
mw.authAdminApi,
|
mw.authAdminApi,
|
||||||
upload.single('redirects'),
|
apiMw.upload.single('redirects'),
|
||||||
shared.middlewares.validation.upload({type: 'redirects'}),
|
shared.middlewares.validation.upload({type: 'redirects'}),
|
||||||
http(apiv2.redirects.upload)
|
http(apiv2.redirects.upload)
|
||||||
);
|
);
|
||||||
|
@ -15,10 +15,6 @@ module.exports = {
|
|||||||
return require('./brute');
|
return require('./brute');
|
||||||
},
|
},
|
||||||
|
|
||||||
get upload() {
|
|
||||||
return require('./upload');
|
|
||||||
},
|
|
||||||
|
|
||||||
get cacheControl() {
|
get cacheControl() {
|
||||||
return require('./cache-control');
|
return require('./cache-control');
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user