UNPKG

steadybit

Version:

Command-line interface to interact with the Steadybit API

43 lines 2.02 kB
"use strict"; // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2022 Steadybit GmbH var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.toUrl = toUrl; exports.getHeaders = getHeaders; const config_1 = require("../config"); // Prefer to load at runtime directly from the package.json to simplify // the TypeScript build. Without this, we would have to make the build // more complicated to adapt the root dir accordingly. // eslint-disable-next-line const packageJson = require('../../package.json'); function toUrl(path, queryParameters) { return __awaiter(this, void 0, void 0, function* () { const config = yield (0, config_1.getConfiguration)(); let url = `${config.baseUrl}${path}`; if (queryParameters) { url = `${url}?${new URLSearchParams(queryParameters).toString()}`; } return url; }); } function getHeaders() { return __awaiter(this, void 0, void 0, function* () { const config = yield (0, config_1.getConfiguration)(); return { Authorization: `accessToken ${config.apiAccessToken}`, 'Content-Type': 'application/json', Accept: 'application/json, */*', 'User-Agent': `${packageJson.name}@${packageJson.version}`, }; }); } //# sourceMappingURL=common.js.map