test-this-package-today
Version:
Event Inc is a fully managed event bus lets you send and receive data across mission-critical cloud apps, databases and warehouses.
42 lines (33 loc) • 775 B
text/typescript
interface ClientConfig {
environment?: 'sandbox' | 'production';
baseUrl?: string;
}
export class Client {
private secret: string;
private configs: ClientConfig;
constructor(secret: string, configs: ClientConfig = {}) {
this.secret = secret;
this.configs = configs;
}
/**
* Not for use outside the SDK lib
*/
get _clientInfo() {
return {
secret: this.secret,
configs: this.configs,
};
}
get _url() {
if (this.configs.baseUrl) {
return this.configs.baseUrl;
}
if (this.configs.environment === 'production') {
return 'https://api.event.dev/internal';
}
return 'https://sandbox-api.event.dev/internal';
}
}
export const createClient = (secret: string, configs: ClientConfig = {}) => {
return new Client(secret, configs);
};