Skip to content

Commit 732f97a

Browse files
authored
De-aliased api versions in codebase (#10375)
closes #10357
1 parent 48d6e72 commit 732f97a

File tree

8 files changed

+9
-16
lines changed

8 files changed

+9
-16
lines changed

core/server/api/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const config = require('../config');
21
module.exports = require('./v0.1');
32
module.exports['v0.1'] = require('./v0.1');
43
module.exports.v2 = require('./v2');
5-
module.exports.active = require(`./${config.get('api:versions:active')}`);

core/server/config/overrides.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@
6969
"api": {
7070
"versions": {
7171
"all": ["v0.1", "v2"],
72-
"active": "v2",
73-
"stable": "",
74-
"deprecated": "v0.1",
7572
"v2": {
7673
"admin": "v2/admin",
7774
"content": "v2/content",

core/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function initialiseServices() {
4444
scheduling.init({
4545
schedulerUrl: config.get('scheduling').schedulerUrl,
4646
active: config.get('scheduling').active,
47-
apiUrl: urlService.utils.urlFor('api', {version: 'deprecated', versionType: 'content'}, true),
47+
apiUrl: urlService.utils.urlFor('api', {version: 'v0.1', versionType: 'content'}, true),
4848
internalPath: config.get('paths').internalSchedulingPath,
4949
contentPath: config.getContentPath('scheduling')
5050
})

core/server/services/url/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function getApiPath(options) {
2828
*/
2929
function getVersionPath(options) {
3030
const apiVersions = config.get('api:versions');
31-
let requestedVersion = options.version || 'deprecated';
31+
let requestedVersion = options.version || 'v0.1';
3232
let requestedVersionType = options.type || 'content';
3333
let versionData = apiVersions[requestedVersion];
3434
if (typeof versionData === 'string') {
@@ -330,7 +330,7 @@ function urlFor(context, data, absolute) {
330330
}
331331
} else if (context === 'api') {
332332
urlPath = getAdminUrl() || getBlogUrl();
333-
let apiPath = getApiPath({version: 'deprecated', type: 'content'});
333+
let apiPath = getApiPath({version: 'v0.1', type: 'content'});
334334
// CASE: with or without protocol? If your blog url (or admin url) is configured to http, it's still possible that e.g. nginx allows both https+http.
335335
// So it depends how you serve your blog. The main focus here is to avoid cors problems.
336336
// @TODO: rename cors

core/server/update-check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const crypto = require('crypto'),
2727
_ = require('lodash'),
2828
url = require('url'),
2929
debug = require('ghost-ignition').debug('update-check'),
30-
api = require('./api').active,
30+
api = require('./api').v2,
3131
config = require('./config'),
3232
urlService = require('./services/url'),
3333
common = require('./lib/common'),

core/server/web/shared/middlewares/serve-public-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function servePublicFile(file, type, maxAge) {
2626

2727
if (type === 'text/xsl' || type === 'text/plain' || type === 'application/javascript') {
2828
buf = buf.toString().replace(blogRegex, urlService.utils.urlFor('home', true).replace(/\/$/, ''));
29-
buf = buf.toString().replace(apiRegex, urlService.utils.urlFor('api', {cors: true, version: 'deprecated', versionType: 'content'}, true));
29+
buf = buf.toString().replace(apiRegex, urlService.utils.urlFor('api', {cors: true, version: 'v0.1', versionType: 'content'}, true));
3030
}
3131
content = {
3232
headers: {

core/test/integration/update_check_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const uuid = require('uuid');
88
const testUtils = require('../utils');
99
const configUtils = require('../utils/configUtils');
1010
const packageInfo = require('../../../package');
11-
const api = require('../../server/api').active;
11+
const api = require('../../server/api').v2;
1212

1313
const sandbox = sinon.sandbox.create();
1414

core/test/unit/services/url/utils_spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,13 @@ describe('Url', function () {
438438
urlService.utils.urlFor('admin', true).should.equal('http://something.com/blog/ghost/');
439439
});
440440

441-
['deprecated', 'active', 'v0.1', 'v2'].forEach((apiVersion) => {
441+
['v0.1', 'v2'].forEach((apiVersion) => {
442442
function getApiPath(options) {
443443
const baseAPIPath = '/ghost/api/';
444444

445445
switch (options.version) {
446-
case 'deprecated':
447446
case 'v0.1':
448447
return `${baseAPIPath}v0.1/`;
449-
case 'active':
450448
case 'v2':
451449
if (options.versionType === 'admin') {
452450
return `${baseAPIPath}v2/admin/`;
@@ -601,15 +599,15 @@ describe('Url', function () {
601599
url: 'https://my-ghost-blog.com'
602600
});
603601

604-
urlService.utils.urlFor('api', {cors: true, version: "active", versionType: 'content'}, true).should.eql('https://my-ghost-blog.com/ghost/api/v2/content/');
602+
urlService.utils.urlFor('api', {cors: true, version: "v2", versionType: 'content'}, true).should.eql('https://my-ghost-blog.com/ghost/api/v2/content/');
605603
});
606604

607605
it('api: with active version and admin true, blog url is https: should return active admin api path', function () {
608606
configUtils.set({
609607
url: 'https://my-ghost-blog.com'
610608
});
611609

612-
urlService.utils.urlFor('api', {cors: true, version: "active", versionType: 'admin'}, true).should.eql('https://my-ghost-blog.com/ghost/api/v2/admin/');
610+
urlService.utils.urlFor('api', {cors: true, version: "v2", versionType: 'admin'}, true).should.eql('https://my-ghost-blog.com/ghost/api/v2/admin/');
613611
});
614612
});
615613

0 commit comments

Comments
 (0)