elseware-nodejs 1.7.7 → 1.7.8
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/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { Request, Response, NextFunction } from 'express';
|
|
3
3
|
import { Model, PopulateOptions, Query } from 'mongoose';
|
|
4
|
-
import {
|
|
4
|
+
import { ZodTypeAny, infer } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
6
|
import { Schema } from 'joi';
|
|
7
7
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
@@ -76,10 +76,19 @@ interface DatabaseConfig {
|
|
|
76
76
|
}
|
|
77
77
|
declare function connectMongoDB(config: DatabaseConfig): Promise<void>;
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Overload 1: No transform → return schema inferred type
|
|
81
|
+
*/
|
|
82
|
+
declare function loadEnv<TSchema extends ZodTypeAny>(options: {
|
|
83
|
+
schema: TSchema;
|
|
84
|
+
}): infer<TSchema>;
|
|
85
|
+
/**
|
|
86
|
+
* Overload 2: With transform → return transformed type
|
|
87
|
+
*/
|
|
88
|
+
declare function loadEnv<TSchema extends ZodTypeAny, TConfig>(options: {
|
|
89
|
+
schema: TSchema;
|
|
90
|
+
transform: (env: infer<TSchema>) => TConfig;
|
|
91
|
+
}): TConfig;
|
|
83
92
|
|
|
84
93
|
interface LoggerOptions {
|
|
85
94
|
timestamp?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { Request, Response, NextFunction } from 'express';
|
|
3
3
|
import { Model, PopulateOptions, Query } from 'mongoose';
|
|
4
|
-
import {
|
|
4
|
+
import { ZodTypeAny, infer } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
6
|
import { Schema } from 'joi';
|
|
7
7
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
@@ -76,10 +76,19 @@ interface DatabaseConfig {
|
|
|
76
76
|
}
|
|
77
77
|
declare function connectMongoDB(config: DatabaseConfig): Promise<void>;
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Overload 1: No transform → return schema inferred type
|
|
81
|
+
*/
|
|
82
|
+
declare function loadEnv<TSchema extends ZodTypeAny>(options: {
|
|
83
|
+
schema: TSchema;
|
|
84
|
+
}): infer<TSchema>;
|
|
85
|
+
/**
|
|
86
|
+
* Overload 2: With transform → return transformed type
|
|
87
|
+
*/
|
|
88
|
+
declare function loadEnv<TSchema extends ZodTypeAny, TConfig>(options: {
|
|
89
|
+
schema: TSchema;
|
|
90
|
+
transform: (env: infer<TSchema>) => TConfig;
|
|
91
|
+
}): TConfig;
|
|
83
92
|
|
|
84
93
|
interface LoggerOptions {
|
|
85
94
|
timestamp?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -332,20 +332,29 @@ function loadEnv(options) {
|
|
|
332
332
|
return options.transform ? options.transform(result.data) : result.data;
|
|
333
333
|
}
|
|
334
334
|
function handleError(error) {
|
|
335
|
-
logger.danger("
|
|
335
|
+
logger.danger("Env validation failed");
|
|
336
336
|
const grouped = {};
|
|
337
337
|
error.issues.forEach((err) => {
|
|
338
338
|
const key = err.path.join(".") || "unknown";
|
|
339
|
+
const rawValue = key !== "unknown" ? process.env[key] : void 0;
|
|
340
|
+
const isSecret = key.toLowerCase().includes("secret");
|
|
341
|
+
const safeValue = isSecret ? "***" : rawValue;
|
|
342
|
+
const messageParts = [
|
|
343
|
+
`message: ${err.message}`,
|
|
344
|
+
`code: ${err.code}`,
|
|
345
|
+
rawValue !== void 0 ? `value: ${JSON.stringify(safeValue)}` : null
|
|
346
|
+
].filter(Boolean);
|
|
347
|
+
const fullMessage = messageParts.join(" | ");
|
|
339
348
|
if (!grouped[key]) grouped[key] = [];
|
|
340
|
-
grouped[key].push(
|
|
349
|
+
grouped[key].push(fullMessage);
|
|
341
350
|
});
|
|
342
351
|
Object.entries(grouped).forEach(([key, messages]) => {
|
|
343
352
|
logger.info(`${key}`);
|
|
344
353
|
messages.forEach((msg) => {
|
|
345
|
-
logger.log(
|
|
354
|
+
logger.log(` - ${msg}`);
|
|
346
355
|
});
|
|
347
356
|
});
|
|
348
|
-
logger.danger("Application startup aborted
|
|
357
|
+
logger.danger("Application startup aborted!");
|
|
349
358
|
process.exit(1);
|
|
350
359
|
}
|
|
351
360
|
|