@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
25 lines (19 loc) • 649 B
text/typescript
// @TODO
// 1- handle multiple protocols automatically
// 2- destroy it once the sdk is destroyed
import https from 'https';
import { find } from '../../utils/lang';
import { ISettings } from '../../types';
const agent = new https.Agent({
keepAlive: true,
keepAliveMsecs: 1500
});
export function getOptions(settings: ISettings) {
// User provided options take precedence
if (settings.sync.requestOptions) return settings.sync.requestOptions;
// If some URL is not HTTPS, we don't use the agent, to let the SDK connect to HTTP endpoints
if (find(settings.urls, url => !url.startsWith('https:'))) return;
return {
agent
};
}