Wired up mock Mentions Admin API (#16134)

refs https://github.com/TryGhost/Team/issues/2416

This doesn't even return a Mention in the correct format at the moment,
but it's just to get an endpoint there, behind a flag and returning data
so that we can start playing with the API and having it hooked up the
the Admin.

The next step will be fleshing this out further and defining the
services and repository to back it, as well as updating the Admin so that
we can fetch mentions to display in the UI
This commit is contained in:
Fabien 'egg' O'Carroll 2023-01-17 12:39:32 +07:00 committed by GitHub
parent e55405691a
commit a8a279d667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 0 deletions

View File

@ -292,6 +292,7 @@ async function initServices({config}) {
const audienceFeedback = require('./server/services/audience-feedback');
const emailSuppressionList = require('./server/services/email-suppression-list');
const emailService = require('./server/services/email-service');
const mentionsService = require('./server/services/mentions');
const urlUtils = require('./shared/url-utils');
@ -305,6 +306,7 @@ async function initServices({config}) {
await Promise.all([
memberAttribution.init(),
mentionsService.init(),
staffService.init(),
members.init(),
tiers.init(),

View File

@ -57,6 +57,10 @@ module.exports = {
return apiFramework.pipeline(require('./posts'), localUtils);
},
get mentions() {
return apiFramework.pipeline(require('./mentions'), localUtils);
},
get invites() {
return apiFramework.pipeline(require('./invites'), localUtils);
},

View File

@ -0,0 +1,19 @@
const mentions = require('../../services/mentions');
module.exports = {
docName: 'mentions',
browse: {
options: [
'filter',
'fields',
'limit',
'order',
'page',
'debug'
],
permissions: false,
query(frame) {
return mentions.controller.browse(frame);
}
}
};

View File

@ -0,0 +1,24 @@
module.exports = class MentionController {
async init() {}
/**
* @param {import('@tryghost/api-framework').Frame} frame
* @returns {Promise<Page<Mention>>}
*/
async browse(/*frame*/) {
return {
data: [{
thing: true
}],
meta: {
pagination: {
page: 1,
limit: 'all',
pages: 1,
total: 1,
next: null,
prev: null
}
}
};
}
};

View File

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

View File

@ -0,0 +1,8 @@
const MentionController = require('./MentionController');
module.exports = {
controller: new MentionController(),
async init() {
this.controller.init();
}
};

View File

@ -5,6 +5,7 @@ const apiMw = require('../../middleware');
const mw = require('./middleware');
const shared = require('../../../shared');
const labs = require('../../../../../shared/labs');
module.exports = function apiRoutes() {
const router = express.Router('admin api');
@ -31,6 +32,8 @@ module.exports = function apiRoutes() {
router.put('/posts/:id', mw.authAdminApi, http(api.posts.edit));
router.del('/posts/:id', mw.authAdminApi, http(api.posts.destroy));
router.get('/mentions', labs.enabledMiddleware('webmentions'), mw.authAdminApi, http(api.mentions.browse));
router.put('/comments/:id', mw.authAdminApi, http(api.comments.edit));
// ## Pages