bootifyjs 0.0.1
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.
- package/dist/application/Application.d.ts +43 -0
- package/dist/application/Application.d.ts.map +1 -0
- package/dist/application/Application.js +283 -0
- package/dist/application/Application.js.map +1 -0
- package/dist/container/container.d.ts +9 -0
- package/dist/container/container.d.ts.map +1 -0
- package/dist/container/container.js +23 -0
- package/dist/container/container.js.map +1 -0
- package/dist/decorators/cache/ICacheClient.d.ts +6 -0
- package/dist/decorators/cache/ICacheClient.d.ts.map +1 -0
- package/dist/decorators/cache/ICacheClient.js +3 -0
- package/dist/decorators/cache/ICacheClient.js.map +1 -0
- package/dist/decorators/cache/cache.decorator.d.ts +2 -0
- package/dist/decorators/cache/cache.decorator.d.ts.map +1 -0
- package/dist/decorators/cache/cache.decorator.js +38 -0
- package/dist/decorators/cache/cache.decorator.js.map +1 -0
- package/dist/decorators/controller.decorator.d.ts +9 -0
- package/dist/decorators/controller.decorator.d.ts.map +1 -0
- package/dist/decorators/controller.decorator.js +99 -0
- package/dist/decorators/controller.decorator.js.map +1 -0
- package/dist/decorators/http.decorator.d.ts +7 -0
- package/dist/decorators/http.decorator.d.ts.map +1 -0
- package/dist/decorators/http.decorator.js +26 -0
- package/dist/decorators/http.decorator.js.map +1 -0
- package/dist/decorators/timing.decorator.d.ts +2 -0
- package/dist/decorators/timing.decorator.d.ts.map +1 -0
- package/dist/decorators/timing.decorator.js +26 -0
- package/dist/decorators/timing.decorator.js.map +1 -0
- package/dist/decorators/transaction/IDatabaseClient.d.ts +9 -0
- package/dist/decorators/transaction/IDatabaseClient.d.ts.map +1 -0
- package/dist/decorators/transaction/IDatabaseClient.js +3 -0
- package/dist/decorators/transaction/IDatabaseClient.js.map +1 -0
- package/dist/decorators/transaction/transactional.decorator.d.ts +2 -0
- package/dist/decorators/transaction/transactional.decorator.d.ts.map +1 -0
- package/dist/decorators/transaction/transactional.decorator.js +27 -0
- package/dist/decorators/transaction/transactional.decorator.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/Logger.d.ts +37 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +142 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/middleware/http.d.ts +2 -0
- package/dist/middleware/http.d.ts.map +1 -0
- package/dist/middleware/http.js +80 -0
- package/dist/middleware/http.js.map +1 -0
- package/dist/middleware/requestcontext.d.ts +12 -0
- package/dist/middleware/requestcontext.d.ts.map +1 -0
- package/dist/middleware/requestcontext.js +6 -0
- package/dist/middleware/requestcontext.js.map +1 -0
- package/package.json +24 -0
- package/src/application/Application.ts +355 -0
- package/src/container/container.ts +28 -0
- package/src/decorators/cache/ICacheClient.ts +5 -0
- package/src/decorators/cache/cache.decorator.ts +36 -0
- package/src/decorators/controller.decorator.ts +119 -0
- package/src/decorators/http.decorator.ts +25 -0
- package/src/decorators/timing.decorator.ts +23 -0
- package/src/decorators/transaction/IDatabaseClient.ts +9 -0
- package/src/decorators/transaction/transactional.decorator.ts +24 -0
- package/src/index.ts +10 -0
- package/src/logger/Logger.ts +179 -0
- package/src/middleware/http.ts +81 -0
- package/src/middleware/requestcontext.ts +12 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Timed = Timed;
|
4
|
+
function Timed() {
|
5
|
+
return (target, propertyKey, descriptor) => {
|
6
|
+
const originalMethod = descriptor.value;
|
7
|
+
descriptor.value = async function (...args) {
|
8
|
+
const start = process.hrtime.bigint();
|
9
|
+
try {
|
10
|
+
const result = await originalMethod.apply(this, args);
|
11
|
+
const end = process.hrtime.bigint();
|
12
|
+
const duration = Number(end - start) / 1000000;
|
13
|
+
console.log(`[TIMED] ${target.constructor.name}.${String(propertyKey)} took ${duration.toFixed(2)}ms`);
|
14
|
+
return result;
|
15
|
+
}
|
16
|
+
catch (error) {
|
17
|
+
const end = process.hrtime.bigint();
|
18
|
+
const duration = Number(end - start) / 1000000;
|
19
|
+
console.error(`[TIMED-ERROR] ${target.constructor.name}.${String(propertyKey)} failed after ${duration.toFixed(2)}ms`, error);
|
20
|
+
throw error;
|
21
|
+
}
|
22
|
+
};
|
23
|
+
return descriptor;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
//# sourceMappingURL=timing.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"timing.decorator.js","sourceRoot":"","sources":["../../src/decorators/timing.decorator.ts"],"names":[],"mappings":";;AAAA,sBAsBC;AAtBD,SAAgB,KAAK;IACjB,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;QACjF,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACtC,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACtD,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,OAAS,CAAC;gBACjD,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACvG,OAAO,MAAM,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,OAAS,CAAC;gBACjD,OAAO,CAAC,KAAK,CAAC,iBAAiB,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,iBAAiB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAC9H,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"IDatabaseClient.d.ts","sourceRoot":"","sources":["../../../src/decorators/transaction/IDatabaseClient.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC5B,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAC7C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"IDatabaseClient.js","sourceRoot":"","sources":["../../../src/decorators/transaction/IDatabaseClient.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transactional.decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/transaction/transactional.decorator.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,IAAI,eAAe,CAoB/C"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.Transactional = Transactional;
|
7
|
+
const container_1 = __importDefault(require("../../container/container"));
|
8
|
+
function Transactional() {
|
9
|
+
return (target, propertyKey, descriptor) => {
|
10
|
+
const originalMethod = descriptor.value;
|
11
|
+
descriptor.value = async function (...args) {
|
12
|
+
const dbClient = container_1.default.get('DatabaseClient');
|
13
|
+
const transaction = await dbClient.startTransaction();
|
14
|
+
try {
|
15
|
+
const result = await originalMethod.apply(this, [...args, transaction.transaction]);
|
16
|
+
await transaction.commit();
|
17
|
+
return result;
|
18
|
+
}
|
19
|
+
catch (error) {
|
20
|
+
await transaction.rollback();
|
21
|
+
throw error;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
return descriptor;
|
25
|
+
};
|
26
|
+
}
|
27
|
+
//# sourceMappingURL=transactional.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transactional.decorator.js","sourceRoot":"","sources":["../../../src/decorators/transaction/transactional.decorator.ts"],"names":[],"mappings":";;;;;AAGA,sCAoBC;AAvBD,0EAAkD;AAGlD,SAAgB,aAAa;IACzB,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;QACjF,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC7C,MAAM,QAAQ,GAAG,mBAAS,CAAC,GAAG,CAAkB,gBAAgB,CAAC,CAAC;YAClE,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YAEtD,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;gBACpF,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;gBAC3B,OAAO,MAAM,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC7B,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from './application/Application';
|
2
|
+
export { default as container, Bean } from './container/container';
|
3
|
+
export * from './decorators/controller.decorator';
|
4
|
+
export * from './decorators/http.decorator';
|
5
|
+
export * from './decorators/timing.decorator';
|
6
|
+
export * from './decorators/cache/cache.decorator';
|
7
|
+
export * from './decorators/cache/ICacheClient';
|
8
|
+
export * from './decorators/transaction/transactional.decorator';
|
9
|
+
export * from './decorators/transaction/IDatabaseClient';
|
10
|
+
export { default as logger, } from './logger/Logger';
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnE,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kDAAkD,CAAC;AACjE,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
|
+
};
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
+
exports.logger = exports.Bean = exports.container = void 0;
|
21
|
+
__exportStar(require("./application/Application"), exports);
|
22
|
+
var container_1 = require("./container/container");
|
23
|
+
Object.defineProperty(exports, "container", { enumerable: true, get: function () { return __importDefault(container_1).default; } });
|
24
|
+
Object.defineProperty(exports, "Bean", { enumerable: true, get: function () { return container_1.Bean; } });
|
25
|
+
__exportStar(require("./decorators/controller.decorator"), exports);
|
26
|
+
__exportStar(require("./decorators/http.decorator"), exports);
|
27
|
+
__exportStar(require("./decorators/timing.decorator"), exports);
|
28
|
+
__exportStar(require("./decorators/cache/cache.decorator"), exports);
|
29
|
+
__exportStar(require("./decorators/cache/ICacheClient"), exports);
|
30
|
+
__exportStar(require("./decorators/transaction/transactional.decorator"), exports);
|
31
|
+
__exportStar(require("./decorators/transaction/IDatabaseClient"), exports);
|
32
|
+
var Logger_1 = require("./logger/Logger");
|
33
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return __importDefault(Logger_1).default; } });
|
34
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,mDAAmE;AAA1D,uHAAA,OAAO,OAAa;AAAE,iGAAA,IAAI,OAAA;AACnC,oEAAkD;AAClD,8DAA4C;AAC5C,gEAA8C;AAC9C,qEAAmD;AACnD,kEAAgD;AAChD,mFAAiE;AACjE,2EAAyD;AACzD,0CAAqD;AAA5C,iHAAA,OAAO,OAAU"}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import pino from 'pino';
|
2
|
+
import { LogContext } from '../middleware/requestcontext';
|
3
|
+
interface AuditLogPayload {
|
4
|
+
action: string;
|
5
|
+
resources: string[];
|
6
|
+
details: any;
|
7
|
+
[key: string]: any;
|
8
|
+
}
|
9
|
+
interface EventLogPayload {
|
10
|
+
eventName: string;
|
11
|
+
status: 'success' | 'failure' | 'pending';
|
12
|
+
metadata: any;
|
13
|
+
[key: string]: any;
|
14
|
+
}
|
15
|
+
declare class Logger {
|
16
|
+
private pinoInstance;
|
17
|
+
private static instance;
|
18
|
+
private constructor();
|
19
|
+
static getInstance(): Logger;
|
20
|
+
/**
|
21
|
+
* Provides access to the raw pino instance, primarily for use with pino-http.
|
22
|
+
*/
|
23
|
+
getPinoInstance(): pino.Logger;
|
24
|
+
private appLog;
|
25
|
+
info(message: string, data?: Record<string, any>): void;
|
26
|
+
error(message: string, error?: Error, data?: Record<string, any>): void;
|
27
|
+
warn(message: string, data?: Record<string, any>): void;
|
28
|
+
debug(message: string, data?: Record<string, any>): void;
|
29
|
+
fatal(message: string, error?: Error, data?: Record<string, any>): void;
|
30
|
+
trace(message: string, data?: Record<string, any>): void;
|
31
|
+
audit(payload: AuditLogPayload): void;
|
32
|
+
event(payload: EventLogPayload): void;
|
33
|
+
child(bindings?: Partial<LogContext> & Record<string, any>): Logger;
|
34
|
+
}
|
35
|
+
declare const logger: Logger;
|
36
|
+
export default logger;
|
37
|
+
//# sourceMappingURL=Logger.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,UAAU,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AE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAKxD,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAMrC,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAKrC,KAAK,CAAC,QAAQ,GAAE,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM;CAQjF;AAED,QAAA,MAAM,MAAM,QAAuB,CAAA;AAEnC,eAAe,MAAM,CAAA"}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const pino_1 = __importDefault(require("pino"));
|
7
|
+
const requestcontext_1 = require("../middleware/requestcontext");
|
8
|
+
// (HttpLogPayload is implicitly handled by pino-http)
|
9
|
+
class Logger {
|
10
|
+
constructor() {
|
11
|
+
const basePinoOptions = {
|
12
|
+
level: process.env.LOG_LEVEL || 'info',
|
13
|
+
timestamp: () => `,"time":"${new Date().toISOString()}"`,
|
14
|
+
messageKey: 'message', // Consistent message key
|
15
|
+
base: {
|
16
|
+
// Remove default pino fields if not needed
|
17
|
+
pid: undefined,
|
18
|
+
hostname: undefined,
|
19
|
+
},
|
20
|
+
formatters: {
|
21
|
+
level: (label) => ({ level: label.toLowerCase() }), // Ensure lowercase level
|
22
|
+
},
|
23
|
+
mixin: () => {
|
24
|
+
const store = requestcontext_1.requestContext.getStore();
|
25
|
+
return {
|
26
|
+
// Common context fields from AsyncLocalStorage
|
27
|
+
requestId: store?.requestId,
|
28
|
+
userId: store?.userId, // This might be overridden by specific log methods like audit
|
29
|
+
traceId: store?.traceId,
|
30
|
+
username: store?.username,
|
31
|
+
// 'additionalContext' from ALS will be merged into the 'context' field for ClickHouse by the transport
|
32
|
+
// context: store?.additionalContext || {},
|
33
|
+
};
|
34
|
+
},
|
35
|
+
};
|
36
|
+
const transports = [];
|
37
|
+
// const clickHouseTransportPath = path.resolve(__dirname, 'pino-clickhouse-transport.js')
|
38
|
+
transports.push({
|
39
|
+
level: 'info', // Minimum level for ClickHouse transport
|
40
|
+
// target: clickHouseTransportPath,
|
41
|
+
options: {
|
42
|
+
url: process.env.CLICKHOUSE_URL || 'http://localhost:8123',
|
43
|
+
username: process.env.CLICKHOUSE_USER || 'default',
|
44
|
+
password: process.env.CLICKHOUSE_PASSWORD || '',
|
45
|
+
database: process.env.CLICKHOUSE_DB || 'default',
|
46
|
+
maxBatchSize: parseInt(process.env.CLICKHOUSE_MAX_BATCH_SIZE || '1000', 10),
|
47
|
+
flushInterval: parseInt(process.env.CLICKHOUSE_FLUSH_INTERVAL || '3000', 10),
|
48
|
+
application: process.env.APP_NAME || 'my-application',
|
49
|
+
},
|
50
|
+
});
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
52
|
+
transports.push({
|
53
|
+
level: 'debug',
|
54
|
+
target: 'pino-pretty',
|
55
|
+
options: {
|
56
|
+
colorize: true,
|
57
|
+
translateTime: 'SYS:standard',
|
58
|
+
ignore: 'pid,hostname,context,username,requestId,userId,traceId,application',
|
59
|
+
messageKey: 'message', // Ensure pino-pretty uses the same messageKey
|
60
|
+
},
|
61
|
+
});
|
62
|
+
}
|
63
|
+
this.pinoInstance = (0, pino_1.default)({
|
64
|
+
...basePinoOptions,
|
65
|
+
// transport: transports.length > 0 ? { targets: transports } : undefined,
|
66
|
+
});
|
67
|
+
}
|
68
|
+
static getInstance() {
|
69
|
+
if (!Logger.instance) {
|
70
|
+
try {
|
71
|
+
Logger.instance = new Logger();
|
72
|
+
}
|
73
|
+
catch (error) {
|
74
|
+
console.error('CRITICAL: Error creating logger instance:', error.message);
|
75
|
+
// Fallback to a very basic console logger if main setup fails
|
76
|
+
const fallbackPino = (0, pino_1.default)({ level: 'info', messageKey: 'message' });
|
77
|
+
fallbackPino.error({ err: error }, 'Fallback console logger activated due to error in primary logger setup.');
|
78
|
+
const fallbackInstance = Object.create(Logger.prototype);
|
79
|
+
fallbackInstance.pinoInstance = fallbackPino;
|
80
|
+
Logger.instance = fallbackInstance;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return Logger.instance;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Provides access to the raw pino instance, primarily for use with pino-http.
|
87
|
+
*/
|
88
|
+
getPinoInstance() {
|
89
|
+
return this.pinoInstance;
|
90
|
+
}
|
91
|
+
// --- Application Logging Methods ---
|
92
|
+
appLog(level, payload) {
|
93
|
+
this.pinoInstance[level]({ ...payload, logType: 'application' });
|
94
|
+
}
|
95
|
+
info(message, data) {
|
96
|
+
this.appLog('info', { message, ...data });
|
97
|
+
}
|
98
|
+
error(message, error, data) {
|
99
|
+
const payload = { message, ...data };
|
100
|
+
if (error) {
|
101
|
+
payload.err = error; // pino stdSerializers.err will handle this
|
102
|
+
}
|
103
|
+
this.appLog('error', payload);
|
104
|
+
}
|
105
|
+
warn(message, data) {
|
106
|
+
this.appLog('warn', { message, ...data });
|
107
|
+
}
|
108
|
+
debug(message, data) {
|
109
|
+
this.appLog('debug', { message, ...data });
|
110
|
+
}
|
111
|
+
fatal(message, error, data) {
|
112
|
+
const payload = { message, ...data };
|
113
|
+
if (error) {
|
114
|
+
payload.err = error;
|
115
|
+
}
|
116
|
+
this.appLog('fatal', payload);
|
117
|
+
}
|
118
|
+
trace(message, data) {
|
119
|
+
this.appLog('trace', { message, ...data });
|
120
|
+
}
|
121
|
+
// --- Audit Logging Method ---
|
122
|
+
audit(payload) {
|
123
|
+
// userId from payload will override userId from mixin if both exist
|
124
|
+
this.pinoInstance.info({ ...payload, logType: 'audit' });
|
125
|
+
}
|
126
|
+
// --- Event Logging Method ---
|
127
|
+
event(payload) {
|
128
|
+
this.pinoInstance.info({ ...payload, logType: 'event' });
|
129
|
+
}
|
130
|
+
// --- Child Logger ---
|
131
|
+
child(bindings = {}) {
|
132
|
+
// Create a new pino child logger instance with additional static bindings
|
133
|
+
const pinoChild = this.pinoInstance.child(bindings);
|
134
|
+
// Create a new Logger wrapper for this pino child
|
135
|
+
const childLoggerInstance = Object.create(Logger.prototype);
|
136
|
+
childLoggerInstance.pinoInstance = pinoChild;
|
137
|
+
return childLoggerInstance;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
const logger = Logger.getInstance();
|
141
|
+
exports.default = logger;
|
142
|
+
//# sourceMappingURL=Logger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,iEAAyE;AA0BzE,sDAAsD;AAEtD,MAAM,MAAM;IAIR;QACI,MAAM,eAAe,GAAuB;YACxC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;YACtC,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG;YACxD,UAAU,EAAE,SAAS,EAAE,yBAAyB;YAChD,IAAI,EAAE;gBACF,2CAA2C;gBAC3C,GAAG,EAAE,SAAS;gBACd,QAAQ,EAAE,SAAS;aACtB;YACD,UAAU,EAAE;gBACR,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,yBAAyB;aACxF;YACD,KAAK,EAAE,GAAG,EAAE;gBACR,MAAM,KAAK,GAAG,+BAAc,CAAC,QAAQ,EAAE,CAAA;gBACvC,OAAO;oBACH,+CAA+C;oBAC/C,SAAS,EAAE,KAAK,EAAE,SAAS;oBAC3B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,8DAA8D;oBACrF,OAAO,EAAE,KAAK,EAAE,OAAO;oBACvB,QAAQ,EAAE,KAAK,EAAE,QAAQ;oBACzB,uG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AAC,QAAQ,CAAC,CAAA;QACnD,kDAAkD;QAClD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAW,CAAA;QACrE,mBAAmB,CAAC,YAAY,GAAG,SAAS,CAAA;QAC5C,OAAO,mBAAmB,CAAA;IAC9B,CAAC;CACJ;AAED,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;AAEnC,kBAAe,MAAM,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/middleware/http.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,sIA6E/B,CAAA"}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.httpLoggerMiddleware = void 0;
|
7
|
+
const pino_http_1 = __importDefault(require("pino-http"));
|
8
|
+
const pino_1 = __importDefault(require("pino"));
|
9
|
+
const Logger_1 = __importDefault(require("../logger/Logger"));
|
10
|
+
exports.httpLoggerMiddleware = (0, pino_http_1.default)({
|
11
|
+
logger: Logger_1.default.getPinoInstance(), // Use the main pino instance
|
12
|
+
customLogLevel: (req, res, err) => {
|
13
|
+
if (res.statusCode >= 500 || err)
|
14
|
+
return 'error';
|
15
|
+
if (res.statusCode >= 400)
|
16
|
+
return 'warn';
|
17
|
+
return 'info';
|
18
|
+
},
|
19
|
+
serializers: {
|
20
|
+
req: (req) => ({
|
21
|
+
id: req.id, // Made available as objFromPinoHttp.req.id
|
22
|
+
method: req.method,
|
23
|
+
url: req.url,
|
24
|
+
remoteAddress: req.remoteAddress || req.socket?.remoteAddress,
|
25
|
+
}),
|
26
|
+
res: (res) => ({
|
27
|
+
statusCode: res.statusCode,
|
28
|
+
}),
|
29
|
+
err: pino_1.default.stdSerializers.err,
|
30
|
+
},
|
31
|
+
// This formatter *must* return the complete, flat object you want to log.
|
32
|
+
formatters: {
|
33
|
+
log: (objFromPinoHttp) => {
|
34
|
+
// objFromPinoHttp contains:
|
35
|
+
// - .req, .res, .err (from serializers above)
|
36
|
+
// - .responseTime (number)
|
37
|
+
// - .level (string, from customLogLevel)
|
38
|
+
// - .message (string, from customSuccessMessage/customErrorMessage)
|
39
|
+
// - properties from `customProps` (e.g., .requestId from req.id fallback)
|
40
|
+
// - IMPORTANT: It ALSO contains properties from the parent `appLogger`'s `mixin`
|
41
|
+
// because pino-http uses the parent logger, and its mixin will have run.
|
42
|
+
const finalHttpLog = {
|
43
|
+
// Standard fields (time will be added by parent pino instance when it actually logs)
|
44
|
+
level: 'hello',
|
45
|
+
test: '123',
|
46
|
+
message: objFromPinoHttp.message,
|
47
|
+
// Contextual fields (these should be present in objFromPinoHttp thanks to parent logger's mixin)
|
48
|
+
requestId: objFromPinoHttp.requestId, // This should be the definitive one after mixin
|
49
|
+
userId: objFromPinoHttp.userId,
|
50
|
+
username: objFromPinoHttp.username,
|
51
|
+
traceId: objFromPinoHttp.traceId,
|
52
|
+
context: objFromPinoHttp.context, // from ALS additionalContext
|
53
|
+
application: objFromPinoHttp.application, // from parent logger or transport default
|
54
|
+
// HTTP specific data, flattened:
|
55
|
+
logType: 'http',
|
56
|
+
method: objFromPinoHttp.req?.method,
|
57
|
+
url: objFromPinoHttp.req?.url,
|
58
|
+
remoteAddress: objFromPinoHttp.req?.remoteAddress,
|
59
|
+
statusCode: objFromPinoHttp.res?.statusCode,
|
60
|
+
responseTimeMs: objFromPinoHttp.responseTime,
|
61
|
+
// If you need req.id specifically, and it's different from the main requestId:
|
62
|
+
// originalHttpRequestId: objFromPinoHttp.req?.id,
|
63
|
+
// Error object (already serialized)
|
64
|
+
err: objFromPinoHttp.err,
|
65
|
+
};
|
66
|
+
// Clean up any top-level undefined properties from the explicitly built object
|
67
|
+
Object.keys(finalHttpLog).forEach((key) => {
|
68
|
+
if (finalHttpLog[key] === undefined) {
|
69
|
+
delete finalHttpLog[key];
|
70
|
+
}
|
71
|
+
});
|
72
|
+
// DEBUG: Log what this formatter is about to return
|
73
|
+
// console.log('--- pino-http formatters.log IS RETURNING: ---', JSON.stringify(finalHttpLog, null, 2));
|
74
|
+
return finalHttpLog;
|
75
|
+
},
|
76
|
+
},
|
77
|
+
customSuccessMessage: (req, res) => `${req.method} ${req.url} request_completed`,
|
78
|
+
customErrorMessage: (req, res, err) => `${req.method} ${req.url} request_errored`,
|
79
|
+
});
|
80
|
+
//# sourceMappingURL=http.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/middleware/http.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgC;AAChC,gDAAuB;AACvB,8DAAqC;AACxB,QAAA,oBAAoB,GAAG,IAAA,mBAAQ,EAAC;IACzC,MAAM,EAAE,gBAAM,CAAC,eAAe,EAAE,EAAE,6BAA6B;IAE/D,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,IAAI,GAAG;YAAE,OAAO,OAAO,CAAA;QAChD,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG;YAAE,OAAO,MAAM,CAAA;QACxC,OAAO,MAAM,CAAA;IACjB,CAAC;IACD,WAAW,EAAE;QACT,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACX,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,2CAA2C;YACvD,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa;SAChE,CAAC;QACF,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACX,UAAU,EAAE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AAC;oBAClC,OAAQ,YAAoB,CAAC,GAAG,CAAC,CAAA;gBACrC,CAAC;YACL,CAAC,CAAC,CAAA;YAEF,oDAAoD;YACpD,wGAAwG;YAExG,OAAO,YAAY,CAAA;QACvB,CAAC;KACJ;IAED,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,oBAAoB;IAChF,kBAAkB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,kBAAkB;CACpF,CAAC,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
2
|
+
export interface LogContext {
|
3
|
+
requestId: string;
|
4
|
+
userId?: string;
|
5
|
+
traceId?: string;
|
6
|
+
username?: string;
|
7
|
+
additionalContext?: {
|
8
|
+
[key: string]: any;
|
9
|
+
};
|
10
|
+
}
|
11
|
+
export declare const requestContext: AsyncLocalStorage<LogContext>;
|
12
|
+
//# sourceMappingURL=requestcontext.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"requestcontext.d.ts","sourceRoot":"","sources":["../../src/middleware/requestcontext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG/C,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CAC7C;AAED,eAAO,MAAM,cAAc,+BAAsC,CAAA"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.requestContext = void 0;
|
4
|
+
const async_hooks_1 = require("async_hooks");
|
5
|
+
exports.requestContext = new async_hooks_1.AsyncLocalStorage();
|
6
|
+
//# sourceMappingURL=requestcontext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"requestcontext.js","sourceRoot":"","sources":["../../src/middleware/requestcontext.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAWlC,QAAA,cAAc,GAAG,IAAI,+BAAiB,EAAc,CAAA"}
|
package/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "bootifyjs",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "Spring Boot inspired framework fro Node.js built on top of fastify and express",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"scripts": {
|
8
|
+
"build": "tsc",
|
9
|
+
"dev": "tsc --watch",
|
10
|
+
"clean": "rm -rf dist"
|
11
|
+
},
|
12
|
+
"dependencies": {
|
13
|
+
"fastify": "^4.24.3",
|
14
|
+
"@fastify/cors": "^8.4.2",
|
15
|
+
"inversify": "^6.0.2",
|
16
|
+
"reflect-metadata": "^0.2.2",
|
17
|
+
"pino": "^8.17.1",
|
18
|
+
"pino-http": "^8.6.1"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
21
|
+
"@types/node": "^20.10.4",
|
22
|
+
"typescript": "^5.3.3"
|
23
|
+
}
|
24
|
+
}
|