windmill-utils-internal
Version:
Internal utility functions for Windmill
36 lines (35 loc) • 904 B
JavaScript
const getEnv = (key) => {
return process.env[key];
};
const baseUrl = getEnv("BASE_INTERNAL_URL") ?? getEnv("BASE_URL") ?? "http://localhost:8000";
const baseUrlApi = (baseUrl ?? '') + "/api";
export class Interceptors {
_fns;
constructor() {
this._fns = [];
}
eject(fn) {
const index = this._fns.indexOf(fn);
if (index !== -1) {
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)];
}
}
use(fn) {
this._fns = [...this._fns, fn];
}
}
export const OpenAPI = {
BASE: baseUrlApi,
CREDENTIALS: 'include',
ENCODE_PATH: undefined,
HEADERS: undefined,
PASSWORD: undefined,
TOKEN: getEnv("WM_TOKEN"),
USERNAME: undefined,
VERSION: '1.601.1',
WITH_CREDENTIALS: true,
interceptors: {
request: new Interceptors(),
response: new Interceptors(),
},
};