Sha256: 0af69d5b22b19fc50c49754f57d780f15f9266a51f9295c7fdd30bb0289136ff
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
// @ts-check const { request: httpRequest } = require('http'); const { request: httpsRequest } = require('https'); const { baseURL, apiKey, exists } = require('./settings'); /** @typedef {import('../diff/types').AppMapListItem} AppMapListItem */ /** * Lists AppMaps in a mapset. * * @param {number} mapset * @returns {Promise<AppMapListItem[]>} */ const listAppMaps = async (mapset) => { if (!exists) { throw new Error(`AppMap client is not configured`); } return new Promise((resolve, reject) => { const listAppMapsURL = new URL([baseURL, 'api/appmaps'].join('/')); listAppMapsURL.searchParams.append('mapsets[]', mapset.toString()); const requestFunction = listAppMapsURL.protocol === 'https:' ? httpsRequest : httpRequest; const req = requestFunction( listAppMapsURL, { 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 = listAppMaps;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appmap-0.62.1 | ./node_modules/@appland/cli/src/appland/listAppMaps.js |