Decreased coupling of frontend routing to server api

refs https://github.com/TryGhost/Team/issues/527
refs https://github.com/TryGhost/Ghost/issues/10790

- Frontent has to have as few as possible coupling points with the Ghost Server API. By design that point has been a "proxy.api" property that will become more and more constraint in the future based to limit the surface of frontend interaction with servers's API
- Removing `.../server/api` requires in favor of using a proxy decreases direct coupling
This commit is contained in:
Naz 2021-07-15 18:56:18 +04:00 committed by naz
parent 566615f014
commit d1b569075f
4 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ const helpers = require('../helpers');
module.exports = function previewController(req, res, next) {
debug('previewController');
const api = require('../../../../server/api')[res.locals.apiVersion];
const api = require('../../proxy').api[res.locals.apiVersion];
const params = {
uuid: req.params.uuid,

View File

@ -4,7 +4,7 @@ const debug = require('@tryghost/debug')('services:routing:controllers:static');
const helpers = require('../helpers');
function processQuery(query, locals) {
const api = require('../../../../server/api')[locals.apiVersion];
const api = require('../../proxy').api[locals.apiVersion];
query = _.cloneDeep(query);
// CASE: If you define a single data key for a static route (e.g. data: page.team), this static route will represent

View File

@ -14,7 +14,7 @@ const routeMatch = require('path-match')();
function entryLookup(postUrl, routerOptions, locals) {
debug(postUrl);
const api = require('../../../../server/api')[locals.apiVersion];
const api = require('../../proxy').api[locals.apiVersion];
const targetPath = url.parse(postUrl).path;
const permalinks = routerOptions.permalinks;
let isEditURL = false;

View File

@ -45,7 +45,7 @@ defaultPostQuery.options = defaultQueryOptions.options;
* @returns {Promise}
*/
function processQuery(query, slugParam, locals) {
const api = require('../../../../server/api')[locals.apiVersion];
const api = require('../../proxy').api[locals.apiVersion];
query = _.cloneDeep(query);