This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHgNode.ts
45 lines (39 loc) · 1.88 KB
/
HgNode.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2022-2023. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.
import { RequestClientImpl } from "../core/RequestClientImpl";
import { NodeRequestClient } from "./requestClient/node/NodeRequestClient";
import { LogLevel } from "../core/types/LogLevel";
import { LogService } from "../core/LogService";
import { RequestClientAdapter } from "../core/requestClient/RequestClientAdapter";
import { NodeChildProcessService } from "./NodeChildProcessService";
import { SystemService } from "../core/SystemService";
import { AutowireService } from "../core/cmd/main/services/AutowireService";
import { AutowireServiceImpl } from "../core/cmd/main/services/AutowireServiceImpl";
const LOG = LogService.createLogger('HgNode');
export class HgNode {
public static setLogLevel (level: LogLevel) {
LOG.setLogLevel(level);
}
/**
* This method will initialize our libraries using frontend implementations.
*
* Right now it will call `RequestClientImpl.setClient()` with a standard NodeJS
* implementation. It has a dependency to NodeJS's http and https modules.
*
* @param requestClient The request client adapter to be used by default
* @param autowireService The global autowire service
*/
public static initialize (
requestClient ?: RequestClientAdapter | undefined,
autowireService ?: AutowireService | undefined,
) : void {
if (!requestClient) {
const HTTP = require('http');
const HTTPS = require('https');
requestClient = NodeRequestClient.create(HTTP, HTTPS);
}
RequestClientImpl.setClient(requestClient);
SystemService.initialize( NodeChildProcessService.create() );
// DefaultValue.initialize( NodeDefaultValueFactoryImpl.create() );
AutowireServiceImpl.setAutowireService( autowireService ?? AutowireServiceImpl.create() );
}
}