2021-06-28 16:27:22 +03:00
|
|
|
const debug = require('@tryghost/debug')('web:backend');
|
|
|
|
const express = require('../../../shared/express');
|
2022-03-09 12:15:12 +03:00
|
|
|
const {BASE_API_PATH} = require('../../../shared/url-utils');
|
2021-06-28 16:27:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @returns {import('express').RequestHandler}
|
|
|
|
*/
|
|
|
|
module.exports = () => {
|
|
|
|
debug('BackendApp setup start');
|
|
|
|
// BACKEND
|
|
|
|
// Wrap the admin and API apps into a single express app for use with vhost
|
|
|
|
const backendApp = express('backend');
|
2021-12-01 18:56:29 +03:00
|
|
|
|
2022-03-09 12:15:12 +03:00
|
|
|
backendApp.lazyUse(BASE_API_PATH, require('../api'));
|
2021-10-11 13:06:03 +03:00
|
|
|
backendApp.lazyUse('/ghost/oauth', require('../oauth'));
|
|
|
|
backendApp.lazyUse('/ghost/.well-known', require('../well-known'));
|
2021-12-01 18:56:29 +03:00
|
|
|
|
2021-06-28 16:27:22 +03:00
|
|
|
backendApp.use('/ghost', require('../../services/auth/session').createSessionFromToken, require('../admin')());
|
|
|
|
|
|
|
|
return backendApp;
|
|
|
|
};
|