mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
abda6e6338
closes #10773 - The refactoring is a substitute for `urlService.utils` used previously throughout the codebase and now extracted into the separate module in Ghost-SDK - Added url-utils stubbing utility for test suites - Some tests had to be refactored to avoid double mocks (when url's are being reset inside of rested 'describe' groups)
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
const debug = require('ghost-ignition').debug('web:api:default:app');
|
|
const express = require('express');
|
|
const urlUtils = require('../../lib/url-utils');
|
|
const errorHandler = require('../shared/middlewares/error-handler');
|
|
const membersService = require('../../services/members');
|
|
|
|
const labs = require('../shared/middlewares/labs');
|
|
|
|
module.exports = function setupApiApp() {
|
|
debug('Parent API setup start');
|
|
const apiApp = express();
|
|
|
|
// Mount different API versions
|
|
apiApp.use(urlUtils.getVersionPath({version: 'v0.1'}), require('./v0.1/app')());
|
|
apiApp.use(urlUtils.getVersionPath({version: 'v2', type: 'content'}), require('./v2/content/app')());
|
|
apiApp.use(urlUtils.getVersionPath({version: 'v2', type: 'admin'}), require('./v2/admin/app')());
|
|
apiApp.use(urlUtils.getVersionPath({version: 'v2', type: 'members'}), labs.members, membersService.api.apiRouter);
|
|
|
|
// Error handling for requests to non-existent API versions
|
|
apiApp.use(errorHandler.resourceNotFound);
|
|
apiApp.use(errorHandler.handleJSONResponse);
|
|
|
|
debug('Parent API setup end');
|
|
return apiApp;
|
|
};
|