mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* pass API port and protocol from config to REST playground * ENV for hidding RPC links in nav bar * tweak styles of SwaggerUI for dark color scheme
33 lines
837 B
TypeScript
33 lines
837 B
TypeScript
import stripTrailingSlash from 'lib/stripTrailingSlash';
|
|
|
|
import { getEnvValue } from './utils';
|
|
|
|
const apiHost = getEnvValue('NEXT_PUBLIC_API_HOST');
|
|
const apiSchema = getEnvValue('NEXT_PUBLIC_API_PROTOCOL') || 'https';
|
|
const apiPort = getEnvValue('NEXT_PUBLIC_API_PORT');
|
|
const apiEndpoint = [
|
|
apiSchema || 'https',
|
|
'://',
|
|
apiHost,
|
|
apiPort && ':' + apiPort,
|
|
].filter(Boolean).join('');
|
|
|
|
const socketSchema = getEnvValue('NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL') || 'wss';
|
|
const socketEndpoint = [
|
|
socketSchema,
|
|
'://',
|
|
apiHost,
|
|
apiPort && ':' + apiPort,
|
|
].filter(Boolean).join('');
|
|
|
|
const api = Object.freeze({
|
|
host: apiHost,
|
|
protocol: apiSchema,
|
|
port: apiPort,
|
|
endpoint: apiEndpoint,
|
|
socket: socketEndpoint,
|
|
basePath: stripTrailingSlash(getEnvValue('NEXT_PUBLIC_API_BASE_PATH') || ''),
|
|
});
|
|
|
|
export default api;
|