mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
## About the changes
Ref:
https://docs.getunleash.io/reference/deploy/configuring-unleash#further-customization
> **eventHook** (`function(event, data)`) - (_deprecated in Unleash 4.3_
in favor of the [Webhook addon](../addons/webhook.md)) If provided, this
function will be invoked whenever a feature is mutated. The possible
values for `event` are `'feature-created'`, `'feature-archived'` and
`'feature-revived'`. The `data` argument contains information about the
mutation. Its fields are `type` (string) - the event type (same as
`event`); `createdBy` (string) - the user who performed the mutation;
`data` - the contents of the change. The contents in `data` differs
based on the event type; For `'feature-archived'` and
`'feature-revived'`, the only field will be `name` - the name of the
feature. For `'feature-created'` the data follows a schema defined in
the code
[here](7b7f0b84e8/src/lib/schema/feature-schema.ts (L77)
).
See an [api here](/reference/api/legacy/unleash/admin/events).
Related to: https://github.com/Unleash/unleash/issues/1265
41 lines
813 B
TypeScript
41 lines
813 B
TypeScript
export function parseEnvVarNumber(
|
|
envVar: string | undefined,
|
|
defaultVal: number,
|
|
): number {
|
|
if (!envVar) {
|
|
return defaultVal;
|
|
}
|
|
const parsed = Number.parseInt(envVar, 10);
|
|
|
|
if (Number.isNaN(parsed)) {
|
|
return defaultVal;
|
|
}
|
|
|
|
return parsed;
|
|
}
|
|
|
|
export function parseEnvVarBoolean(
|
|
envVar: string | undefined,
|
|
defaultVal: boolean,
|
|
): boolean {
|
|
if (envVar) {
|
|
return envVar === 'true' || envVar === '1' || envVar === 't';
|
|
}
|
|
|
|
return defaultVal;
|
|
}
|
|
|
|
export function parseEnvVarStrings(
|
|
envVar: string | undefined,
|
|
defaultVal: string[],
|
|
): string[] {
|
|
if (typeof envVar === 'string') {
|
|
return envVar
|
|
.split(',')
|
|
.map((item) => item.trim())
|
|
.filter(Boolean);
|
|
}
|
|
|
|
return defaultVal;
|
|
}
|