From da0dee548c8322e5bb50c0005558ca1845f55037 Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 3 Mar 2022 12:20:03 +0700 Subject: [PATCH] Added alias for non-versioned API endpoints refs https://github.com/TryGhost/Toolbox/issues/169 - Before next major version release we need to prepare for removal of API versioning. - This change allows unversioned API requests to work under following endpoints: - /ghost/api/admin - /ghost/api/content - This change should allow further preparation of the API clients (SDKs, Integrations, etc.) to non-versioned APIs in Ghost instances in ^5.0.0 - Changed default e2e test targets to non-versioned API. It's a trial, to have working examples. In the future all tests should switch to use only non-versioned endpoints. --- core/server/web/api/app.js | 3 +++ test/e2e-api/admin/utils.js | 2 +- test/e2e-api/content/utils.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/server/web/api/app.js b/core/server/web/api/app.js index 13006b2011e..6f49b9db5ef 100644 --- a/core/server/web/api/app.js +++ b/core/server/web/api/app.js @@ -25,6 +25,9 @@ module.exports = function setupApiApp() { apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'content'}), require('./canary/content/app')); apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'admin'}), require('./canary/admin/app')); + apiApp.lazyUse('/content/', require('./canary/content/app')); + apiApp.lazyUse('/admin/', require('./canary/admin/app')); + // Error handling for requests to non-existent API versions apiApp.use(errorHandler.resourceNotFound); apiApp.use(errorHandler.handleJSONResponse(sentry)); diff --git a/test/e2e-api/admin/utils.js b/test/e2e-api/admin/utils.js index 86a3dfb4463..4706bfa4302 100644 --- a/test/e2e-api/admin/utils.js +++ b/test/e2e-api/admin/utils.js @@ -7,7 +7,7 @@ const testUtils = require('../../utils'); // the commit introducing this comment. const schema = require('../../../core/server/data/schema').tables; -const API_URL = '/ghost/api/canary/admin/'; +const API_URL = '/ghost/api/admin/'; const expectedProperties = { // API top level diff --git a/test/e2e-api/content/utils.js b/test/e2e-api/content/utils.js index aefdeba2828..f7164225274 100644 --- a/test/e2e-api/content/utils.js +++ b/test/e2e-api/content/utils.js @@ -2,7 +2,7 @@ const url = require('url'); const _ = require('lodash'); const testUtils = require('../../utils'); -const API_URL = '/ghost/api/canary/content/'; +const API_URL = '/ghost/api/content/'; const expectedProperties = { // API top level