elseware-nodejs 1.7.4 → 1.7.5
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 +24 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -337,17 +337,31 @@ async function connectMongoDB(config) {
|
|
|
337
337
|
process.exit(1);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
dotenv__default.default.config(
|
|
341
|
-
function loadEnv(
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
340
|
+
dotenv__default.default.config();
|
|
341
|
+
function loadEnv(options) {
|
|
342
|
+
const result = options.schema.safeParse(process.env);
|
|
343
|
+
if (!result.success) {
|
|
344
|
+
handleError(result.error);
|
|
345
|
+
}
|
|
346
|
+
logger.success("\u2705 Env Configurations validated");
|
|
347
|
+
return options.transform ? options.transform(result.data) : result.data;
|
|
348
|
+
}
|
|
349
|
+
function handleError(error) {
|
|
350
|
+
console.error("\u274C ENV VALIDATION FAILED");
|
|
351
|
+
const grouped = {};
|
|
352
|
+
error.issues.forEach((err) => {
|
|
353
|
+
const key = err.path.join(".") || "unknown";
|
|
354
|
+
if (!grouped[key]) grouped[key] = [];
|
|
355
|
+
grouped[key].push(err.message);
|
|
345
356
|
});
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
357
|
+
Object.entries(grouped).forEach(([key, messages]) => {
|
|
358
|
+
console.error(`\u{1F539} ${key}`);
|
|
359
|
+
messages.forEach((msg) => {
|
|
360
|
+
console.error(` - ${msg}`);
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
console.error("\u{1F6AB} Application startup aborted.\n");
|
|
364
|
+
process.exit(1);
|
|
351
365
|
}
|
|
352
366
|
|
|
353
367
|
// src/configs/cors/allowedOrigins.ts
|