Sha256: 8575a351ac96736ec4d5c17aa5c195341612913ea18d8eaae9529a790509b63a

Contents?: true

Size: 1.29 KB

Versions: 21

Compression:

Stored size: 1.29 KB

Contents

// @ts-check

const { request: httpRequest } = require('http');
const { request: httpsRequest } = require('https');
const { baseURL, apiKey, exists } = require('./settings');

/**
 * Loads AppMap data from UUID.
 *
 * @param {string} uuid
 * @returns {Promise<AppMapData>}
 */
const getAppMap = async (uuid) => {
  if (!exists) {
    throw new Error(`AppMap client is not configured`);
  }

  return new Promise((resolve, reject) => {
    const getScenarioURL = new URL([baseURL, 'api/appmaps', uuid].join('/'));
    const requestFunction =
      getScenarioURL.protocol === 'https:' ? httpsRequest : httpRequest;
    const req = requestFunction(
      getScenarioURL,
      {
        headers: {
          Authorization: `Bearer ${apiKey}`,
          Accept: 'application/json',
        },
      },
      // eslint-disable-next-line consistent-return
      (res) => {
        if (res.statusCode >= 300) {
          return reject(res.statusCode);
        }
        let data = '';
        res.setEncoding('utf8');
        res.on('data', (chunk) => {
          data += chunk;
        });
        res.on('end', () => {
          resolve(JSON.parse(data));
        });
      }
    );

    req.on('error', (e) => {
      reject(e);
    });

    // Write data to request body
    req.end();
  });
};

module.exports = getAppMap;

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.72.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.72.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.71.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.70.2 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.70.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.70.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.69.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.68.2 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.68.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.68.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.67.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.67.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.66.2 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.66.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.66.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.65.1 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.65.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.64.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js
appmap-0.63.0 ./node_modules/@appland/appmap/src/appland/getAppMap.js