0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added public /site endpoint to Admin API v2

no issue
This commit is contained in:
kirrg001 2019-02-24 14:15:09 +01:00 committed by Katharina Irrgang
parent b5155e280e
commit f9974a91a9
6 changed files with 41 additions and 0 deletions

View file

@ -123,6 +123,10 @@ module.exports = {
return shared.pipeline(require('./actions'), localUtils);
},
get site() {
return shared.pipeline(require('./site'), localUtils);
},
get serializers() {
return require('./utils/serializers');
}

View file

@ -0,0 +1,20 @@
const ghostVersion = require('../../lib/ghost-version');
const settingsCache = require('../../services/settings/cache');
const urlService = require('../../services/url');
const site = {
docName: 'site',
read: {
permissions: false,
query() {
return {
title: settingsCache.get('title'),
url: urlService.utils.urlFor('home', true),
version: ghostVersion.safe
};
}
}
};
module.exports = site;

View file

@ -93,5 +93,9 @@ module.exports = {
get actions() {
return require('./actions');
},
get site() {
return require('./site');
}
};

View file

@ -0,0 +1,9 @@
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:output:site');
module.exports = {
read(data, apiConfig, frame) {
debug('read');
frame.response = data;
}
};

View file

@ -11,6 +11,7 @@ const notImplemented = function (req, res, next) {
// @NOTE: integrations have limited access for now
const whitelisted = {
// @NOTE: stable
site: ['GET'],
posts: ['GET', 'PUT', 'DELETE', 'POST'],
pages: ['GET', 'PUT', 'DELETE', 'POST'],
tags: ['GET', 'PUT', 'DELETE', 'POST'],

View file

@ -20,6 +20,9 @@ module.exports = function apiRoutes() {
const http = apiImpl => apiv2.http(apiImpl, 'admin');
// ## Public
router.get('/site', http(apiv2.site.read));
// ## Configuration
router.get('/configuration', http(apiv2.configuration.read));
router.get('/configuration/:key', mw.authAdminApi, http(apiv2.configuration.read));