0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Added WIP frontend comments app

refs https://github.com/TryGhost/Team/issues/1664
This commit is contained in:
Kevin Ansfield 2022-07-05 10:48:09 +02:00 committed by Simon Backx
parent 1dd83e1a0f
commit e60ec64454
5 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,12 @@
const CommentsService = require('./service');
const models = require('../models');
class CommentsServiceWrapper {
init() {
this.api = new CommentsService({
models
});
}
}
module.exports = new CommentsServiceWrapper();

View file

@ -0,0 +1,7 @@
class CommentsService {
constructor({models}) {
this.models = models;
}
}
module.exports = CommentsService;

View file

@ -0,0 +1,26 @@
const debug = require('@tryghost/debug')('comments');
const errorHandler = require('@tryghost/mw-error-handler');
const cors = require('cors');
const express = require('../../../shared/express');
const urlUtils = require('../../../shared/url-utils');
const sentry = require('../../../shared/sentry');
module.exports = function setupCommentsApp() {
debug('Comments App setup start');
const commentsApp = express('comments');
// Support CORS for requests from the frontend
const siteUrl = new URL(urlUtils.getSiteUrl());
commentsApp.use(cors(siteUrl.origin));
// Routing
commentsApp.get('/api/comments');
// API error handling
commentsApp.use('/api', errorHandler.resourceNotFound);
commentsApp.use('/api', errorHandler.handleJSONResponse(sentry));
debug('Comments App setup end');
return commentsApp;
};

View file

@ -0,0 +1 @@
module.exports = require('./app');

View file

@ -18,6 +18,7 @@ module.exports = (routerConfig) => {
frontendApp.use(shared.middleware.urlRedirects.frontendSSLRedirect);
frontendApp.lazyUse('/members', require('../members'));
frontendApp.lazyUse('/comments', require('../comments'));
frontendApp.use('/', require('../../../frontend/web')(routerConfig));
return frontendApp;