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:
parent
b5155e280e
commit
f9974a91a9
6 changed files with 41 additions and 0 deletions
|
@ -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');
|
||||
}
|
||||
|
|
20
core/server/api/v2/site.js
Normal file
20
core/server/api/v2/site.js
Normal 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;
|
|
@ -93,5 +93,9 @@ module.exports = {
|
|||
|
||||
get actions() {
|
||||
return require('./actions');
|
||||
},
|
||||
|
||||
get site() {
|
||||
return require('./site');
|
||||
}
|
||||
};
|
||||
|
|
9
core/server/api/v2/utils/serializers/output/site.js
Normal file
9
core/server/api/v2/utils/serializers/output/site.js
Normal 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;
|
||||
}
|
||||
};
|
|
@ -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'],
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue