-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathutils.ts
More file actions
21 lines (18 loc) · 866 Bytes
/
utils.ts
File metadata and controls
21 lines (18 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import type { Client, EvaluationContext } from '@openfeature/server-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
type FrameworkMetadataClient = Client & {
setFrameworkMetadata?: (framework: 'nest') => Client;
};
/**
* Returns a domain scoped or the default OpenFeature client with the given context.
* @param {string} domain The domain of the OpenFeature client.
* @param {EvaluationContext} context The evaluation context of the client.
* @returns {Client} The OpenFeature client.
*/
export function getClientForEvaluation(domain?: string, context?: EvaluationContext) {
return setNestFrameworkMetadata(domain ? OpenFeature.getClient(domain, context) : OpenFeature.getClient(context));
}
function setNestFrameworkMetadata(client: Client): Client {
(client as FrameworkMetadataClient).setFrameworkMetadata?.('nest');
return client;
}