mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
da0dee548c
refs https://github.com/TryGhost/Toolbox/issues/169 - Before next major version release we need to prepare for removal of API versioning. - This change allows unversioned API requests to work under following endpoints: - /ghost/api/admin - /ghost/api/content - This change should allow further preparation of the API clients (SDKs, Integrations, etc.) to non-versioned APIs in Ghost instances in ^5.0.0 - Changed default e2e test targets to non-versioned API. It's a trial, to have working examples. In the future all tests should switch to use only non-versioned endpoints.
37 lines
1.7 KiB
JavaScript
37 lines
1.7 KiB
JavaScript
const debug = require('@tryghost/debug')('web:api:default:app');
|
|
const config = require('../../../shared/config');
|
|
const express = require('../../../shared/express');
|
|
const urlUtils = require('../../../shared/url-utils');
|
|
const sentry = require('../../../shared/sentry');
|
|
const errorHandler = require('@tryghost/mw-error-handler');
|
|
|
|
module.exports = function setupApiApp() {
|
|
debug('Parent API setup start');
|
|
const apiApp = express('api');
|
|
|
|
if (config.get('server:testmode')) {
|
|
apiApp.use(require('./testmode')());
|
|
}
|
|
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v2', type: 'content'}), require('./v2/content/app'));
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v2', type: 'admin'}), require('./v2/admin/app'));
|
|
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v3', type: 'content'}), require('./v3/content/app'));
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v3', type: 'admin'}), require('./v3/admin/app'));
|
|
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v4', type: 'content'}), require('./canary/content/app'));
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'v4', type: 'admin'}), require('./canary/admin/app'));
|
|
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'content'}), require('./canary/content/app'));
|
|
apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'admin'}), require('./canary/admin/app'));
|
|
|
|
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(errorHandler.handleJSONResponse(sentry));
|
|
|
|
debug('Parent API setup end');
|
|
return apiApp;
|
|
};
|