@levrbet/shared 0.1.145 → 0.1.147
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.
|
@@ -34,7 +34,7 @@ function useBaseAuthHeaders(levrAuth, props = {}) {
|
|
|
34
34
|
const { identityToken } = useIdentityToken();
|
|
35
35
|
const { refreshUser } = useUser();
|
|
36
36
|
return useQuery({
|
|
37
|
-
queryKey: ["authHeaders", user?.id, address].filter((k) => !lodash_1.default.isNil(k)),
|
|
37
|
+
queryKey: ["authHeaders", levrAuth, user?.id, address, identityToken].filter((k) => !lodash_1.default.isNil(k)),
|
|
38
38
|
queryFn: async () => {
|
|
39
39
|
if (!user)
|
|
40
40
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthHeaders.js","sourceRoot":"","sources":["../../../../src/react/hooks/auth/useAuthHeaders.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAEH,oDAAsB;AACtB,4CAAmB;AAGnB,wCAA0D;AAC1D,6DAAoH;AACpH,qEAA4D;AAM5D,SAAS,kBAAkB,CAAC,QAAkB,EAAE,QAA6B,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IACzB,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAA,sCAAe,GAAE,CAAA;IAC3E,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC3C,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAC5C,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAA;IAEjC,OAAO,QAAQ,CAAC;QACZ,QAAQ,EAAE,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAC,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,IAAI,CAAC;QACvB,eAAe,EAAE,IAAA,YAAE,EAAC,IAAI,CAAC;KAC5B,CAAC,CAAA;AACN,CAAC;AAEM,MAAM,cAAc,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,kBAAkB,CAAC,eAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AAAhG,QAAA,cAAc,kBAAkF;AAEtG,MAAM,mBAAmB,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,kBAAkB,CAAC,eAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAAtG,QAAA,mBAAmB,uBAAmF"}
|
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
|
-
export interface LoggerOptions {
|
|
3
|
-
service?: string;
|
|
4
|
-
level?: string;
|
|
5
|
-
additionalMeta?: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
export declare const createLogger: (options?: LoggerOptions) => winston.Logger;
|
|
8
2
|
declare const logger: winston.Logger;
|
|
9
|
-
export declare const createStream: (loggerInstance?: winston.Logger) => {
|
|
10
|
-
write: (message: string) => void;
|
|
11
|
-
};
|
|
12
|
-
export declare const stream: {
|
|
13
|
-
write: (message: string) => void;
|
|
14
|
-
};
|
|
15
3
|
export default logger;
|
|
@@ -3,102 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.stream = exports.createStream = exports.createLogger = void 0;
|
|
7
6
|
const winston_1 = __importDefault(require("winston"));
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { createLogger, createStream } from "@levrbet/shared"
|
|
14
|
-
|
|
15
|
-
// Create a custom logger
|
|
16
|
-
const logger = createLogger({
|
|
17
|
-
service: "levr-oracle-core",
|
|
18
|
-
additionalMeta: {
|
|
19
|
-
version: "1.0.0",
|
|
20
|
-
region: "ap-south-1"
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// Use with Morgan for HTTP request logging
|
|
25
|
-
import morgan from "express"
|
|
26
|
-
const morganStream = createStream(logger)
|
|
27
|
-
app.use(morgan("combined", { stream: morganStream }))
|
|
28
|
-
|
|
29
|
-
// Or just use the default
|
|
30
|
-
import logger from "@levrbet/shared"
|
|
31
|
-
logger.info("Using default logger")
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
const { combine, timestamp, errors, json, colorize, printf, splat } = winston_1.default.format;
|
|
35
|
-
// Determine log level based on environment
|
|
36
|
-
const getLogLevel = () => {
|
|
37
|
-
switch (dotenv_1.LEVR_ENV) {
|
|
38
|
-
case "local":
|
|
39
|
-
return "debug";
|
|
40
|
-
case "dev":
|
|
41
|
-
return "debug";
|
|
42
|
-
case "staging":
|
|
43
|
-
return "info";
|
|
44
|
-
case "prod":
|
|
45
|
-
return "error";
|
|
46
|
-
default:
|
|
47
|
-
return "info";
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
// Custom format for console output in non-production
|
|
51
|
-
const consoleFormat = printf(({ level, message, timestamp, stack, service, ...metadata }) => {
|
|
52
|
-
let msg = `${timestamp} [${level}]`;
|
|
53
|
-
if (service) {
|
|
54
|
-
msg += ` [${service}]`;
|
|
55
|
-
}
|
|
56
|
-
msg += `: ${message}`;
|
|
57
|
-
// Add stack trace if error
|
|
58
|
-
if (stack) {
|
|
59
|
-
msg += `\n${stack}`;
|
|
60
|
-
}
|
|
61
|
-
// Add metadata if present
|
|
62
|
-
const metaKeys = Object.keys(metadata).filter((key) => key !== "environment");
|
|
63
|
-
if (metaKeys.length > 0) {
|
|
64
|
-
const filteredMeta = Object.fromEntries(metaKeys.map((key) => [key, metadata[key]]));
|
|
65
|
-
msg += `\n${JSON.stringify(filteredMeta, null, 2)}`;
|
|
66
|
-
}
|
|
67
|
-
return msg;
|
|
68
|
-
});
|
|
69
|
-
// Production format (structured JSON for OTEL)
|
|
70
|
-
const productionFormat = combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), errors({ stack: true }), splat(), json());
|
|
71
|
-
// Development format (human-readable)
|
|
72
|
-
const developmentFormat = combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), errors({ stack: true }), splat(), colorize(), consoleFormat);
|
|
73
|
-
const createLogger = (options = {}) => {
|
|
74
|
-
const { service = "@levrbet/shared", level = getLogLevel(), additionalMeta = {} } = options;
|
|
75
|
-
const logger = winston_1.default.createLogger({
|
|
76
|
-
level,
|
|
77
|
-
format: dotenv_1.LEVR_ENV === "prod" ? productionFormat : developmentFormat,
|
|
78
|
-
defaultMeta: {
|
|
79
|
-
service,
|
|
80
|
-
environment: dotenv_1.LEVR_ENV,
|
|
81
|
-
...additionalMeta,
|
|
82
|
-
},
|
|
83
|
-
transports: [
|
|
84
|
-
new winston_1.default.transports.Console({
|
|
85
|
-
stderrLevels: ["error"],
|
|
86
|
-
}),
|
|
87
|
-
],
|
|
88
|
-
exitOnError: false,
|
|
89
|
-
});
|
|
90
|
-
return logger;
|
|
91
|
-
};
|
|
92
|
-
exports.createLogger = createLogger;
|
|
93
|
-
// Default logger instance
|
|
94
|
-
const logger = (0, exports.createLogger)();
|
|
95
|
-
// Create stream for Morgan (HTTP logging)
|
|
96
|
-
const createStream = (loggerInstance = logger) => ({
|
|
97
|
-
write: (message) => {
|
|
98
|
-
loggerInstance.info(message.trim());
|
|
99
|
-
},
|
|
7
|
+
const { combine, timestamp, errors, json } = winston_1.default.format;
|
|
8
|
+
const logger = winston_1.default.createLogger({
|
|
9
|
+
level: "info",
|
|
10
|
+
format: combine(timestamp(), errors({ stack: true }), json()),
|
|
11
|
+
transports: [new winston_1.default.transports.Console()],
|
|
100
12
|
});
|
|
101
|
-
exports.createStream = createStream;
|
|
102
|
-
exports.stream = (0, exports.createStream)();
|
|
103
13
|
exports.default = logger;
|
|
104
14
|
//# sourceMappingURL=winston.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"winston.js","sourceRoot":"","sources":["../../../src/server/config/winston.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"winston.js","sourceRoot":"","sources":["../../../src/server/config/winston.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAE7B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAO,CAAC,MAAM,CAAA;AAE3D,MAAM,MAAM,GAAG,iBAAO,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;IAC7D,UAAU,EAAE,CAAC,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;CACjD,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
|