mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Moved version-match mw into api app
- Moved version-match 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
adde1fa01c
commit
41c3b4e92b
@ -3,6 +3,7 @@ const boolParser = require('express-query-boolean');
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const shared = require('../../../shared');
|
||||
const mw = require('../../middleware');
|
||||
const routes = require('./routes');
|
||||
const sentry = require('../../../../sentry');
|
||||
|
||||
@ -25,7 +26,7 @@ module.exports = function setupApiApp() {
|
||||
|
||||
// Check version matches for API requests, depends on res.locals.safeVersion being set
|
||||
// Therefore must come after themeHandler.ghostLocals, for now
|
||||
apiApp.use(shared.middlewares.api.versionMatch);
|
||||
apiApp.use(mw.versionMatch);
|
||||
|
||||
// Admin API shouldn't be cached
|
||||
apiApp.use(shared.middlewares.cacheControl('private'));
|
||||
|
3
core/server/web/api/middleware/index.js
Normal file
3
core/server/web/api/middleware/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
versionMatch: require('./version-match')
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
const semver = require('semver');
|
||||
const errors = require('@tryghost/errors');
|
||||
const {i18n} = require('../../../../lib/common');
|
||||
const {i18n} = require('../../../lib/common');
|
||||
|
||||
function checkVersionMatch(req, res, next) {
|
||||
const clientVersion = req.get('X-Ghost-Version');
|
@ -3,6 +3,7 @@ const boolParser = require('express-query-boolean');
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const shared = require('../../../shared');
|
||||
const mw = require('../../middleware');
|
||||
const routes = require('./routes');
|
||||
const sentry = require('../../../../sentry');
|
||||
|
||||
@ -25,7 +26,7 @@ module.exports = function setupApiApp() {
|
||||
|
||||
// Check version matches for API requests, depends on res.locals.safeVersion being set
|
||||
// Therefore must come after themeHandler.ghostLocals, for now
|
||||
apiApp.use(shared.middlewares.api.versionMatch);
|
||||
apiApp.use(mw.versionMatch);
|
||||
|
||||
// Admin API shouldn't be cached
|
||||
apiApp.use(shared.middlewares.cacheControl('private'));
|
||||
|
@ -5,9 +5,5 @@ module.exports = {
|
||||
|
||||
get spamPrevention() {
|
||||
return require('./spam-prevention');
|
||||
},
|
||||
|
||||
get versionMatch() {
|
||||
return require('./version-match');
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
var should = require('should'),
|
||||
sinon = require('sinon'),
|
||||
versionMatch = require('../../../../../core/server/web/shared/middlewares/api/version-match');
|
||||
versionMatch = require('../../../../../core/server/web/api/middleware/version-match');
|
||||
|
||||
describe('Version Mismatch', function () {
|
||||
var req, res, getStub, nextStub;
|
Loading…
Reference in New Issue
Block a user