Skip to content

Commit a0c4d35

Browse files
committed
Reverted "🔥 Dropped support for "host" parameter in Admin API SDK"
reverts 931c845. refs https://github.com/TryGhost/Toolbox/issues/348 - Dropping the parameter would be breaking changes and would need a major release. That would be done after recent bugfixes come in and are released as a part of a minor bump
1 parent 3ad61a9 commit a0c4d35

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎packages/admin-api/lib/admin-api.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const resolveAPIPrefix = (version) => {
4444
* @param {String|Boolean} [options.userAgent] - flag controlling if the 'User-Agent' header should be sent with a request
4545
* @param {Function} [options.makeRequest]
4646
* @param {Function} [options.generateToken]
47+
* @param {String} [options.host] Deprecated
4748
*/
4849
module.exports = function GhostAdminAPI(options) {
4950
if (this instanceof GhostAdminAPI) {
@@ -77,6 +78,20 @@ module.exports = function GhostAdminAPI(options) {
7778

7879
const config = Object.assign({}, defaultConfig, options);
7980

81+
//
82+
/**
83+
* host parameter is deprecated
84+
* @deprecated use "url" instead
85+
* @example new GhostAdminAPI({host: '...'})
86+
*/
87+
if (config.host) {
88+
// eslint-disable-next-line
89+
console.warn(`${packageName}: The 'host' parameter is deprecated, please use 'url' instead`);
90+
if (!config.url) {
91+
config.url = config.host;
92+
}
93+
}
94+
8095
if (config.version === undefined) {
8196
throw new Error(`${packageName} Config Missing: 'version' is required. E.g. ${supportedVersions.join(',')}`);
8297
}

0 commit comments

Comments
 (0)