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:
parent
1dd83e1a0f
commit
e60ec64454
5 changed files with 47 additions and 0 deletions
12
core/server/services/comments/index.js
Normal file
12
core/server/services/comments/index.js
Normal 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();
|
7
core/server/services/comments/service.js
Normal file
7
core/server/services/comments/service.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
class CommentsService {
|
||||
constructor({models}) {
|
||||
this.models = models;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CommentsService;
|
26
core/server/web/comments/app.js
Normal file
26
core/server/web/comments/app.js
Normal 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;
|
||||
};
|
1
core/server/web/comments/index.js
Normal file
1
core/server/web/comments/index.js
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require('./app');
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue