Skip to content

Commit

Permalink
Added alias for non-versioned API endpoints
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
naz committed Mar 3, 2022
1 parent cd1183c commit da0dee5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/server/web/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-api/admin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-api/content/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da0dee5

Please sign in to comment.