-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration.ts
More file actions
30 lines (25 loc) · 1.14 KB
/
registration.ts
File metadata and controls
30 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { CertManagementHook } from "./cert-management.js";
import { ErrorCleanerHook } from "./error-cleaner.js";
import { TokenManagementHook } from "./token-management.js";
import { SDKIdentifierHook } from "./sdk-identifier.js";
import type { Hooks } from "./types.js";
/*
* This file is only ever generated once on the first generation and then is free to be modified.
* Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
* in this file or in separate files in the hooks folder.
*/
export function initHooks(hooks: Hooks) {
// Register cert management (TLS with undici Agent)
const certHook = new CertManagementHook();
hooks.registerSDKInitHook(certHook);
// Register token management hooks
const tokenHook = new TokenManagementHook();
hooks.registerBeforeRequestHook(tokenHook);
hooks.registerAfterSuccessHook(tokenHook);
// Register error cleaning hook
const errorCleanerHook = new ErrorCleanerHook();
hooks.registerAfterErrorHook(errorCleanerHook);
// Register SDK identifier hook
const sdkIdentifierHook = new SDKIdentifierHook();
hooks.registerBeforeRequestHook(sdkIdentifierHook);
}