Ghost/core/server/web/api/index.js
Fabien O'Carroll 48923ac327
Wired members service up to api and app (#10262)
* Updated auth service members middleware

refs #10213

* Wired up members api router to the ghost api endpoints

refs #10213

* Created members app for the static pages

refs #10213

* Wired up the members app

refs #10213
2018-12-11 15:18:07 +07:00

27 lines
1.1 KiB
JavaScript

const debug = require('ghost-ignition').debug('web:api:default:app');
const express = require('express');
const urlUtils = require('../../services/url/utils');
const errorHandler = require('../shared/middlewares/error-handler');
const membersService = require('../../services/members');
const labs = require('../../services/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')());
if (labs.isSet('members')) {
apiApp.use(urlUtils.getVersionPath({version: 'v2', type: '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;
};