@webtypen/webframez-core 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ConsoleApplication = void 0;
13
+ /// <reference types="node" />
13
14
  const Config_1 = require("./Config");
14
15
  const ConsoleOutputHelper_1 = require("./Commands/ConsoleOutputHelper");
15
16
  const QueueWorkerCommand_1 = require("./Commands/QueueWorkerCommand");
@@ -43,6 +44,9 @@ class ConsoleApplication {
43
44
  Config_1.Config.register(key, options.config[key]);
44
45
  }
45
46
  }
47
+ // if (options && options.signoz) {
48
+ // void SigNozTelemetry.init(options.signoz);
49
+ // }
46
50
  if (options && options.datatables) {
47
51
  DatatableRegistry_1.DatatableRegistry.registerMany(options.datatables);
48
52
  }
File without changes
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ // import { NodeSDK } from "@opentelemetry/sdk-node";
3
+ // import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
4
+ // import { Resource } from "@opentelemetry/resources";
5
+ // import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
6
+ // import { ParentBasedSampler, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
7
+ // import { Config } from "../Config";
8
+ // export interface SigNozOptions {
9
+ // enabled?: boolean;
10
+ // serviceName?: string;
11
+ // endpoint?: string;
12
+ // apiKey?: string;
13
+ // headers?: Record<string, string>;
14
+ // environment?: string;
15
+ // resourceAttributes?: Record<string, unknown>;
16
+ // samplingRatio?: number;
17
+ // instrumentations?: any[];
18
+ // autoInstrumentations?: boolean;
19
+ // autoInstrumentationConfig?: Record<string, unknown>;
20
+ // logInitialization?: boolean;
21
+ // }
22
+ // export class SigNozTelemetry {
23
+ // private static sdk: NodeSDK | null = null;
24
+ // private static initPromise: Promise<void> | null = null;
25
+ // private static shutdownRegistered = false;
26
+ // private static readonly missingDependencies = new Set<string>();
27
+ // private static readonly shutdownListener = () => {
28
+ // void SigNozTelemetry.shutdown();
29
+ // };
30
+ // static async init(options?: SigNozOptions): Promise<void> {
31
+ // if (!options || options.enabled === false) {
32
+ // return;
33
+ // }
34
+ // if (this.sdk) {
35
+ // return;
36
+ // }
37
+ // if (this.initPromise) {
38
+ // await this.initPromise;
39
+ // return;
40
+ // }
41
+ // console.log("signoz init 1");
42
+ // const initialization = (async () => {
43
+ // try {
44
+ // await this.initialize(options);
45
+ // } catch (error) {
46
+ // this.logWarn("[SigNoz] Initialization failed:", error);
47
+ // }
48
+ // })();
49
+ // console.log("signoz init 2");
50
+ // this.initPromise = initialization;
51
+ // try {
52
+ // await initialization;
53
+ // } finally {
54
+ // this.initPromise = null;
55
+ // }
56
+ // console.log("signoz init finish");
57
+ // }
58
+ // private static async initialize(options: SigNozOptions): Promise<void> {
59
+ // console.log("signoz initialize 1");
60
+ // const serviceName =
61
+ // options.serviceName ||
62
+ // (Config.get("application.serviceName") as string) ||
63
+ // (Config.get("application.name") as string) ||
64
+ // this.getEnv("SIGNOZ_SERVICE_NAME") ||
65
+ // this.getEnv("OTEL_SERVICE_NAME") ||
66
+ // "webframez-service";
67
+ // const environment =
68
+ // options.environment ||
69
+ // (Config.get("application.environment") as string) ||
70
+ // this.getEnv("SIGNOZ_ENVIRONMENT") ||
71
+ // this.getEnv("NODE_ENV") ||
72
+ // "development";
73
+ // const traceEndpoint = this.ensureEndpoint(
74
+ // options.endpoint ||
75
+ // this.getEnv("SIGNOZ_ENDPOINT") ||
76
+ // this.getEnv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") ||
77
+ // this.getEnv("OTEL_EXPORTER_OTLP_ENDPOINT"),
78
+ // "http://localhost:4318",
79
+ // "/v1/traces"
80
+ // );
81
+ // console.log("signoz initialize 2");
82
+ // const headers = { ...(options.headers || {}) };
83
+ // const apiKey = options.apiKey || this.getEnv("SIGNOZ_API_KEY");
84
+ // if (apiKey && !headers["signoz-access-token"]) {
85
+ // headers["signoz-access-token"] = apiKey;
86
+ // }
87
+ // const resourceAttributes: Record<string, unknown> = {
88
+ // [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
89
+ // [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: environment,
90
+ // };
91
+ // if (options.resourceAttributes) {
92
+ // Object.assign(resourceAttributes, options.resourceAttributes);
93
+ // }
94
+ // console.log("signoz initialize 3");
95
+ // const resource = new Resource(resourceAttributes);
96
+ // let instrumentations = options.instrumentations ? [...options.instrumentations] : [];
97
+ // if (instrumentations.length === 0 && options.autoInstrumentations !== false) {
98
+ // const autoInstrumentation = this.loadAutoInstrumentations(options.autoInstrumentationConfig || {});
99
+ // if (autoInstrumentation) {
100
+ // instrumentations = [autoInstrumentation];
101
+ // }
102
+ // }
103
+ // console.log("signoz initialize 4");
104
+ // let traceSampler: ParentBasedSampler | undefined;
105
+ // if (typeof options.samplingRatio === "number") {
106
+ // const ratio = Math.min(Math.max(options.samplingRatio, 0), 1);
107
+ // traceSampler = new ParentBasedSampler({
108
+ // root: new TraceIdRatioBasedSampler(ratio),
109
+ // });
110
+ // }
111
+ // console.log("signoz initialize 5");
112
+ // const traceExporter = new OTLPTraceExporter({
113
+ // url: traceEndpoint,
114
+ // headers,
115
+ // });
116
+ // const sdkOptions: {
117
+ // resource: Resource;
118
+ // traceExporter: OTLPTraceExporter;
119
+ // instrumentations?: any[];
120
+ // traceSampler?: ParentBasedSampler;
121
+ // } = {
122
+ // resource,
123
+ // traceExporter,
124
+ // };
125
+ // if (instrumentations.length > 0) {
126
+ // sdkOptions.instrumentations = instrumentations;
127
+ // }
128
+ // if (traceSampler) {
129
+ // sdkOptions.traceSampler = traceSampler;
130
+ // }
131
+ // console.log("signoz initialize 6");
132
+ // this.sdk = new NodeSDK(sdkOptions as any);
133
+ // await this.sdk.start();
134
+ // if (options.logInitialization !== false) {
135
+ // this.logInfo(`[SigNoz] Telemetry enabled (service="${serviceName}", endpoint="${traceEndpoint}")`);
136
+ // }
137
+ // console.log("signoz initialize 7");
138
+ // this.registerShutdownHooks();
139
+ // console.log("signoz initialize 8");
140
+ // }
141
+ // static async shutdown(): Promise<void> {
142
+ // if (!this.sdk) {
143
+ // return;
144
+ // }
145
+ // const sdkToShutdown = this.sdk;
146
+ // this.sdk = null;
147
+ // try {
148
+ // await sdkToShutdown.shutdown();
149
+ // } catch (error) {
150
+ // this.logWarn("[SigNoz] Shutdown failed:", error);
151
+ // }
152
+ // }
153
+ // private static ensureEndpoint(value: string | undefined, fallbackHost: string, defaultPath: string): string {
154
+ // const base = value && value.trim() !== "" ? value.trim() : fallbackHost;
155
+ // if (base.includes("/v1/") || base.endsWith(defaultPath)) {
156
+ // return base;
157
+ // }
158
+ // return `${base.replace(/\/$/, "")}${defaultPath}`;
159
+ // }
160
+ // private static warnMissingDependency(name: string) {
161
+ // if (this.missingDependencies.has(name)) {
162
+ // return;
163
+ // }
164
+ // this.missingDependencies.add(name);
165
+ // this.logWarn(`[SigNoz] Optional package "${name}" not found. Install it to enable the related feature.`);
166
+ // }
167
+ // private static loadAutoInstrumentations(config: Record<string, unknown>): any | null {
168
+ // if (typeof require !== "function") {
169
+ // return null;
170
+ // }
171
+ // try {
172
+ // // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
173
+ // const module = require("@opentelemetry/auto-instrumentations-node");
174
+ // if (module && typeof module.getNodeAutoInstrumentations === "function") {
175
+ // return module.getNodeAutoInstrumentations(config);
176
+ // }
177
+ // this.warnMissingDependency("@opentelemetry/auto-instrumentations-node");
178
+ // return null;
179
+ // } catch (error: any) {
180
+ // if (error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND")) {
181
+ // this.warnMissingDependency("@opentelemetry/auto-instrumentations-node");
182
+ // return null;
183
+ // }
184
+ // throw error;
185
+ // }
186
+ // }
187
+ // private static registerShutdownHooks() {
188
+ // if (this.shutdownRegistered) {
189
+ // return;
190
+ // }
191
+ // const nodeProcess = this.getProcess();
192
+ // if (!nodeProcess) {
193
+ // return;
194
+ // }
195
+ // nodeProcess.once("beforeExit", this.shutdownListener);
196
+ // nodeProcess.once("exit", this.shutdownListener);
197
+ // this.shutdownRegistered = true;
198
+ // }
199
+ // private static getProcess(): any {
200
+ // if (typeof globalThis === "undefined") {
201
+ // return undefined;
202
+ // }
203
+ // const candidate = (globalThis as any).process;
204
+ // if (candidate && typeof candidate.once === "function") {
205
+ // return candidate;
206
+ // }
207
+ // return undefined;
208
+ // }
209
+ // private static getEnv(key: string): string | undefined {
210
+ // const nodeProcess = this.getProcess();
211
+ // if (!nodeProcess || !nodeProcess.env) {
212
+ // return undefined;
213
+ // }
214
+ // const value = nodeProcess.env[key];
215
+ // return typeof value === "string" ? value : undefined;
216
+ // }
217
+ // private static getConsole(): any {
218
+ // if (typeof globalThis === "undefined") {
219
+ // return undefined;
220
+ // }
221
+ // return (globalThis as any).console;
222
+ // }
223
+ // private static logInfo(...args: unknown[]) {
224
+ // const target = this.getConsole();
225
+ // if (target && typeof target.info === "function") {
226
+ // target.info(...args);
227
+ // }
228
+ // }
229
+ // private static logWarn(...args: unknown[]) {
230
+ // const target = this.getConsole();
231
+ // if (target && typeof target.warn === "function") {
232
+ // target.warn(...args);
233
+ // }
234
+ // }
235
+ // }
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WebApplication = void 0;
7
+ /// <reference types="node" />
7
8
  const http_1 = __importDefault(require("http"));
8
9
  const Config_1 = require("./Config");
9
10
  const Router_1 = require("./Router/Router");
10
11
  const QueueJobsRegisty_1 = require("./Queue/QueueJobsRegisty");
11
12
  const DatatableRegistry_1 = require("./Datatable/DatatableRegistry");
12
13
  const ModulesLoader_1 = require("./Modules/ModulesLoader");
14
+ // import { SigNozTelemetry } from "./Telemetry/SigNozTelemetry";
13
15
  class WebApplication {
14
16
  constructor() {
15
17
  this.modulesLoader = null;
@@ -23,6 +25,9 @@ class WebApplication {
23
25
  Config_1.Config.register(key, options.config[key]);
24
26
  }
25
27
  }
28
+ // if (options && options.signoz) {
29
+ // void SigNozTelemetry.init(options.signoz);
30
+ // }
26
31
  this.modulesLoader = new ModulesLoader_1.ModulesLoader();
27
32
  this.modulesLoader.load(options && options.modules ? options.modules : []);
28
33
  if (options && options.kernel) {
@@ -46,10 +51,16 @@ class WebApplication {
46
51
  this.server = http_1.default.createServer((req, res) => {
47
52
  Router_1.Router.handleRequest(req, res);
48
53
  });
54
+ // this.server.on("close", () => {
55
+ // void SigNozTelemetry.shutdown();
56
+ // });
49
57
  this.server.listen(port, () => {
50
- console.log("Server started and listening on port " +
51
- port +
52
- (options && options.basename ? " (Basename: " + options && options.basename + ")" : ""));
58
+ const runtimeConsole = typeof globalThis !== "undefined" ? globalThis.console : undefined;
59
+ if (runtimeConsole && typeof runtimeConsole.log === "function") {
60
+ runtimeConsole.log("Server started and listening on port " +
61
+ port +
62
+ (options && options.basename ? " (Basename: " + options && options.basename + ")" : ""));
63
+ }
53
64
  if (options && options.onBoot) {
54
65
  options.onBoot(port);
55
66
  }
package/dist/index.d.ts CHANGED
@@ -31,4 +31,3 @@ export * from "./Queue/QueueJob";
31
31
  export * from "./Queue/QueueJobsRegisty";
32
32
  export * from "./Commands/ConsoleOutputHelper";
33
33
  export * from "./Modules/ModuleProvider";
34
- export * from "./info";
package/dist/index.js CHANGED
@@ -47,4 +47,5 @@ __exportStar(require("./Queue/QueueJob"), exports);
47
47
  __exportStar(require("./Queue/QueueJobsRegisty"), exports);
48
48
  __exportStar(require("./Commands/ConsoleOutputHelper"), exports);
49
49
  __exportStar(require("./Modules/ModuleProvider"), exports);
50
- __exportStar(require("./info"), exports);
50
+ // export * from "./Telemetry/SigNozTelemetry";
51
+ // export * from "./info";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Config } from "./Config";
2
3
  import { ConsoleOutputHelper } from "./Commands/ConsoleOutputHelper";
3
4
  import { QueueWorkerCommand } from "./Commands/QueueWorkerCommand";
@@ -32,6 +33,10 @@ export class ConsoleApplication {
32
33
  }
33
34
  }
34
35
 
36
+ // if (options && options.signoz) {
37
+ // void SigNozTelemetry.init(options.signoz);
38
+ // }
39
+
35
40
  if (options && options.datatables) {
36
41
  DatatableRegistry.registerMany(options.datatables);
37
42
  }
@@ -0,0 +1,268 @@
1
+ // import { NodeSDK } from "@opentelemetry/sdk-node";
2
+ // import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
3
+ // import { Resource } from "@opentelemetry/resources";
4
+ // import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
5
+ // import { ParentBasedSampler, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
6
+ // import { Config } from "../Config";
7
+
8
+ // export interface SigNozOptions {
9
+ // enabled?: boolean;
10
+ // serviceName?: string;
11
+ // endpoint?: string;
12
+ // apiKey?: string;
13
+ // headers?: Record<string, string>;
14
+ // environment?: string;
15
+ // resourceAttributes?: Record<string, unknown>;
16
+ // samplingRatio?: number;
17
+ // instrumentations?: any[];
18
+ // autoInstrumentations?: boolean;
19
+ // autoInstrumentationConfig?: Record<string, unknown>;
20
+ // logInitialization?: boolean;
21
+ // }
22
+
23
+ // export class SigNozTelemetry {
24
+ // private static sdk: NodeSDK | null = null;
25
+ // private static initPromise: Promise<void> | null = null;
26
+ // private static shutdownRegistered = false;
27
+ // private static readonly missingDependencies = new Set<string>();
28
+ // private static readonly shutdownListener = () => {
29
+ // void SigNozTelemetry.shutdown();
30
+ // };
31
+
32
+ // static async init(options?: SigNozOptions): Promise<void> {
33
+ // if (!options || options.enabled === false) {
34
+ // return;
35
+ // }
36
+ // if (this.sdk) {
37
+ // return;
38
+ // }
39
+ // if (this.initPromise) {
40
+ // await this.initPromise;
41
+ // return;
42
+ // }
43
+
44
+ // console.log("signoz init 1");
45
+ // const initialization = (async () => {
46
+ // try {
47
+ // await this.initialize(options);
48
+ // } catch (error) {
49
+ // this.logWarn("[SigNoz] Initialization failed:", error);
50
+ // }
51
+ // })();
52
+ // console.log("signoz init 2");
53
+
54
+ // this.initPromise = initialization;
55
+
56
+ // try {
57
+ // await initialization;
58
+ // } finally {
59
+ // this.initPromise = null;
60
+ // }
61
+ // console.log("signoz init finish");
62
+ // }
63
+
64
+ // private static async initialize(options: SigNozOptions): Promise<void> {
65
+ // console.log("signoz initialize 1");
66
+ // const serviceName =
67
+ // options.serviceName ||
68
+ // (Config.get("application.serviceName") as string) ||
69
+ // (Config.get("application.name") as string) ||
70
+ // this.getEnv("SIGNOZ_SERVICE_NAME") ||
71
+ // this.getEnv("OTEL_SERVICE_NAME") ||
72
+ // "webframez-service";
73
+
74
+ // const environment =
75
+ // options.environment ||
76
+ // (Config.get("application.environment") as string) ||
77
+ // this.getEnv("SIGNOZ_ENVIRONMENT") ||
78
+ // this.getEnv("NODE_ENV") ||
79
+ // "development";
80
+
81
+ // const traceEndpoint = this.ensureEndpoint(
82
+ // options.endpoint ||
83
+ // this.getEnv("SIGNOZ_ENDPOINT") ||
84
+ // this.getEnv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") ||
85
+ // this.getEnv("OTEL_EXPORTER_OTLP_ENDPOINT"),
86
+ // "http://localhost:4318",
87
+ // "/v1/traces"
88
+ // );
89
+ // console.log("signoz initialize 2");
90
+
91
+ // const headers = { ...(options.headers || {}) };
92
+ // const apiKey = options.apiKey || this.getEnv("SIGNOZ_API_KEY");
93
+ // if (apiKey && !headers["signoz-access-token"]) {
94
+ // headers["signoz-access-token"] = apiKey;
95
+ // }
96
+
97
+ // const resourceAttributes: Record<string, unknown> = {
98
+ // [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
99
+ // [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: environment,
100
+ // };
101
+
102
+ // if (options.resourceAttributes) {
103
+ // Object.assign(resourceAttributes, options.resourceAttributes);
104
+ // }
105
+
106
+ // console.log("signoz initialize 3");
107
+ // const resource = new Resource(resourceAttributes);
108
+
109
+ // let instrumentations = options.instrumentations ? [...options.instrumentations] : [];
110
+ // if (instrumentations.length === 0 && options.autoInstrumentations !== false) {
111
+ // const autoInstrumentation = this.loadAutoInstrumentations(options.autoInstrumentationConfig || {});
112
+ // if (autoInstrumentation) {
113
+ // instrumentations = [autoInstrumentation];
114
+ // }
115
+ // }
116
+ // console.log("signoz initialize 4");
117
+
118
+ // let traceSampler: ParentBasedSampler | undefined;
119
+ // if (typeof options.samplingRatio === "number") {
120
+ // const ratio = Math.min(Math.max(options.samplingRatio, 0), 1);
121
+ // traceSampler = new ParentBasedSampler({
122
+ // root: new TraceIdRatioBasedSampler(ratio),
123
+ // });
124
+ // }
125
+ // console.log("signoz initialize 5");
126
+
127
+ // const traceExporter = new OTLPTraceExporter({
128
+ // url: traceEndpoint,
129
+ // headers,
130
+ // });
131
+
132
+ // const sdkOptions: {
133
+ // resource: Resource;
134
+ // traceExporter: OTLPTraceExporter;
135
+ // instrumentations?: any[];
136
+ // traceSampler?: ParentBasedSampler;
137
+ // } = {
138
+ // resource,
139
+ // traceExporter,
140
+ // };
141
+
142
+ // if (instrumentations.length > 0) {
143
+ // sdkOptions.instrumentations = instrumentations;
144
+ // }
145
+ // if (traceSampler) {
146
+ // sdkOptions.traceSampler = traceSampler;
147
+ // }
148
+
149
+ // console.log("signoz initialize 6");
150
+ // this.sdk = new NodeSDK(sdkOptions as any);
151
+ // await this.sdk.start();
152
+
153
+ // if (options.logInitialization !== false) {
154
+ // this.logInfo(`[SigNoz] Telemetry enabled (service="${serviceName}", endpoint="${traceEndpoint}")`);
155
+ // }
156
+
157
+ // console.log("signoz initialize 7");
158
+ // this.registerShutdownHooks();
159
+
160
+ // console.log("signoz initialize 8");
161
+ // }
162
+
163
+ // static async shutdown(): Promise<void> {
164
+ // if (!this.sdk) {
165
+ // return;
166
+ // }
167
+
168
+ // const sdkToShutdown = this.sdk;
169
+ // this.sdk = null;
170
+
171
+ // try {
172
+ // await sdkToShutdown.shutdown();
173
+ // } catch (error) {
174
+ // this.logWarn("[SigNoz] Shutdown failed:", error);
175
+ // }
176
+ // }
177
+
178
+ // private static ensureEndpoint(value: string | undefined, fallbackHost: string, defaultPath: string): string {
179
+ // const base = value && value.trim() !== "" ? value.trim() : fallbackHost;
180
+ // if (base.includes("/v1/") || base.endsWith(defaultPath)) {
181
+ // return base;
182
+ // }
183
+ // return `${base.replace(/\/$/, "")}${defaultPath}`;
184
+ // }
185
+
186
+ // private static warnMissingDependency(name: string) {
187
+ // if (this.missingDependencies.has(name)) {
188
+ // return;
189
+ // }
190
+ // this.missingDependencies.add(name);
191
+ // this.logWarn(`[SigNoz] Optional package "${name}" not found. Install it to enable the related feature.`);
192
+ // }
193
+
194
+ // private static loadAutoInstrumentations(config: Record<string, unknown>): any | null {
195
+ // if (typeof require !== "function") {
196
+ // return null;
197
+ // }
198
+ // try {
199
+ // // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
200
+ // const module = require("@opentelemetry/auto-instrumentations-node");
201
+ // if (module && typeof module.getNodeAutoInstrumentations === "function") {
202
+ // return module.getNodeAutoInstrumentations(config);
203
+ // }
204
+ // this.warnMissingDependency("@opentelemetry/auto-instrumentations-node");
205
+ // return null;
206
+ // } catch (error: any) {
207
+ // if (error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND")) {
208
+ // this.warnMissingDependency("@opentelemetry/auto-instrumentations-node");
209
+ // return null;
210
+ // }
211
+ // throw error;
212
+ // }
213
+ // }
214
+
215
+ // private static registerShutdownHooks() {
216
+ // if (this.shutdownRegistered) {
217
+ // return;
218
+ // }
219
+ // const nodeProcess = this.getProcess();
220
+ // if (!nodeProcess) {
221
+ // return;
222
+ // }
223
+ // nodeProcess.once("beforeExit", this.shutdownListener);
224
+ // nodeProcess.once("exit", this.shutdownListener);
225
+ // this.shutdownRegistered = true;
226
+ // }
227
+
228
+ // private static getProcess(): any {
229
+ // if (typeof globalThis === "undefined") {
230
+ // return undefined;
231
+ // }
232
+ // const candidate = (globalThis as any).process;
233
+ // if (candidate && typeof candidate.once === "function") {
234
+ // return candidate;
235
+ // }
236
+ // return undefined;
237
+ // }
238
+
239
+ // private static getEnv(key: string): string | undefined {
240
+ // const nodeProcess = this.getProcess();
241
+ // if (!nodeProcess || !nodeProcess.env) {
242
+ // return undefined;
243
+ // }
244
+ // const value = nodeProcess.env[key];
245
+ // return typeof value === "string" ? value : undefined;
246
+ // }
247
+
248
+ // private static getConsole(): any {
249
+ // if (typeof globalThis === "undefined") {
250
+ // return undefined;
251
+ // }
252
+ // return (globalThis as any).console;
253
+ // }
254
+
255
+ // private static logInfo(...args: unknown[]) {
256
+ // const target = this.getConsole();
257
+ // if (target && typeof target.info === "function") {
258
+ // target.info(...args);
259
+ // }
260
+ // }
261
+
262
+ // private static logWarn(...args: unknown[]) {
263
+ // const target = this.getConsole();
264
+ // if (target && typeof target.warn === "function") {
265
+ // target.warn(...args);
266
+ // }
267
+ // }
268
+ // }
@@ -1,9 +1,11 @@
1
+ /// <reference types="node" />
1
2
  import http, { Server } from "http";
2
3
  import { Config } from "./Config";
3
4
  import { Router } from "./Router/Router";
4
5
  import { QueueJobsRegisty } from "./Queue/QueueJobsRegisty";
5
6
  import { DatatableRegistry } from "./Datatable/DatatableRegistry";
6
7
  import { ModulesLoader } from "./Modules/ModulesLoader";
8
+ // import { SigNozTelemetry } from "./Telemetry/SigNozTelemetry";
7
9
 
8
10
  export class WebApplication {
9
11
  private server!: Server;
@@ -19,6 +21,10 @@ export class WebApplication {
19
21
  }
20
22
  }
21
23
 
24
+ // if (options && options.signoz) {
25
+ // void SigNozTelemetry.init(options.signoz);
26
+ // }
27
+
22
28
  this.modulesLoader = new ModulesLoader();
23
29
  this.modulesLoader.load(options && options.modules ? options.modules : []);
24
30
 
@@ -45,16 +51,23 @@ export class WebApplication {
45
51
  }
46
52
 
47
53
  const port = options && options.port ? options.port : 3000;
48
- this.server = http.createServer((req, res) => {
54
+ this.server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
49
55
  Router.handleRequest(req, res);
50
56
  });
51
57
 
58
+ // this.server.on("close", () => {
59
+ // void SigNozTelemetry.shutdown();
60
+ // });
61
+
52
62
  this.server.listen(port, () => {
53
- console.log(
54
- "Server started and listening on port " +
55
- port +
56
- (options && options.basename ? " (Basename: " + options && options.basename + ")" : "")
57
- );
63
+ const runtimeConsole = typeof globalThis !== "undefined" ? (globalThis as any).console : undefined;
64
+ if (runtimeConsole && typeof runtimeConsole.log === "function") {
65
+ runtimeConsole.log(
66
+ "Server started and listening on port " +
67
+ port +
68
+ (options && options.basename ? " (Basename: " + options && options.basename + ")" : "")
69
+ );
70
+ }
58
71
 
59
72
  if (options && options.onBoot) {
60
73
  options.onBoot(port);
package/src/index.ts CHANGED
@@ -31,4 +31,5 @@ export * from "./Queue/QueueJob";
31
31
  export * from "./Queue/QueueJobsRegisty";
32
32
  export * from "./Commands/ConsoleOutputHelper";
33
33
  export * from "./Modules/ModuleProvider";
34
- export * from "./info";
34
+ // export * from "./Telemetry/SigNozTelemetry";
35
+ // export * from "./info";