UNPKG

@twurple/api-call

Version:

A light wrapper around the Twitch API.

22 lines (21 loc) 754 B
/** @internal */ export function getTwitchApiUrl(url, type, mockServerPort) { switch (type) { case 'helix': { const unprefixedUrl = url.replace(/^\//, ''); if (mockServerPort) { if (unprefixedUrl === 'eventsub/subscriptions') { return `http://localhost:${mockServerPort}/${unprefixedUrl}`; } return `http://localhost:${mockServerPort}/mock/${unprefixedUrl}`; } return `https://api.twitch.tv/helix/${unprefixedUrl}`; } case 'auth': return `https://id.twitch.tv/oauth2/${url.replace(/^\//, '')}`; case 'custom': return url; default: return url; // wat } }