mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs: https://github.com/TryGhost/Toolbox/issues/229 - we are getting rid of the concept of having multiple api versions in a single ghost install - removed all the code for multiple api versions & left canary wired up, but without the version in the URL - TODO: reorganise the folders so there's no canary folder when we're closer to shipping we need to minimise the pain of merging changes across from main for now
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
const debug = require('@tryghost/debug')('web:api:default:app');
|
|
const config = require('../../../shared/config');
|
|
const express = require('../../../shared/express');
|
|
const sentry = require('../../../shared/sentry');
|
|
const errorHandler = require('@tryghost/mw-error-handler');
|
|
const versionMissmatchHandler = require('@tryghost/mw-api-version-mismatch');
|
|
const {APIVersionCompatibilityServiceInstance} = require('../../services/api-version-compatibility');
|
|
|
|
module.exports = function setupApiApp() {
|
|
debug('Parent API setup start');
|
|
const apiApp = express('api');
|
|
|
|
if (config.get('server:testmode')) {
|
|
apiApp.use(require('./testmode')());
|
|
}
|
|
|
|
apiApp.lazyUse('/content/', require('./canary/content/app'));
|
|
apiApp.lazyUse('/admin/', require('./canary/admin/app'));
|
|
|
|
// Error handling for requests to non-existent API versions
|
|
apiApp.use(errorHandler.resourceNotFound);
|
|
apiApp.use(versionMissmatchHandler(APIVersionCompatibilityServiceInstance));
|
|
apiApp.use(errorHandler.handleJSONResponse(sentry));
|
|
|
|
debug('Parent API setup end');
|
|
return apiApp;
|
|
};
|