elseware-nodejs 1.7.3 → 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 +37 -19
- 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 +37 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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 { ZodSchema } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
|
+
import { Schema } from 'joi';
|
|
6
7
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -75,11 +76,10 @@ interface DatabaseConfig {
|
|
|
75
76
|
}
|
|
76
77
|
declare function connectMongoDB(config: DatabaseConfig): Promise<void>;
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
declare function loadEnv<T>(schema: Joi.ObjectSchema<T>): T;
|
|
79
|
+
declare function loadEnv(options: {
|
|
80
|
+
schema: ZodSchema;
|
|
81
|
+
transform?: (env: any) => any;
|
|
82
|
+
}): any;
|
|
83
83
|
|
|
84
84
|
interface LoggerOptions {
|
|
85
85
|
timestamp?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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 { ZodSchema } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
|
+
import { Schema } from 'joi';
|
|
6
7
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -75,11 +76,10 @@ interface DatabaseConfig {
|
|
|
75
76
|
}
|
|
76
77
|
declare function connectMongoDB(config: DatabaseConfig): Promise<void>;
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
declare function loadEnv<T>(schema: Joi.ObjectSchema<T>): T;
|
|
79
|
+
declare function loadEnv(options: {
|
|
80
|
+
schema: ZodSchema;
|
|
81
|
+
transform?: (env: any) => any;
|
|
82
|
+
}): any;
|
|
83
83
|
|
|
84
84
|
interface LoggerOptions {
|
|
85
85
|
timestamp?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -322,17 +322,31 @@ async function connectMongoDB(config) {
|
|
|
322
322
|
process.exit(1);
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
dotenv.config(
|
|
326
|
-
function loadEnv(
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
325
|
+
dotenv.config();
|
|
326
|
+
function loadEnv(options) {
|
|
327
|
+
const result = options.schema.safeParse(process.env);
|
|
328
|
+
if (!result.success) {
|
|
329
|
+
handleError(result.error);
|
|
330
|
+
}
|
|
331
|
+
logger.success("\u2705 Env Configurations validated");
|
|
332
|
+
return options.transform ? options.transform(result.data) : result.data;
|
|
333
|
+
}
|
|
334
|
+
function handleError(error) {
|
|
335
|
+
console.error("\u274C ENV VALIDATION FAILED");
|
|
336
|
+
const grouped = {};
|
|
337
|
+
error.issues.forEach((err) => {
|
|
338
|
+
const key = err.path.join(".") || "unknown";
|
|
339
|
+
if (!grouped[key]) grouped[key] = [];
|
|
340
|
+
grouped[key].push(err.message);
|
|
330
341
|
});
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
342
|
+
Object.entries(grouped).forEach(([key, messages]) => {
|
|
343
|
+
console.error(`\u{1F539} ${key}`);
|
|
344
|
+
messages.forEach((msg) => {
|
|
345
|
+
console.error(` - ${msg}`);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
console.error("\u{1F6AB} Application startup aborted.\n");
|
|
349
|
+
process.exit(1);
|
|
336
350
|
}
|
|
337
351
|
|
|
338
352
|
// src/configs/cors/allowedOrigins.ts
|
|
@@ -5319,16 +5333,20 @@ var TemplateEngine = class {
|
|
|
5319
5333
|
static partialsLoaded = {};
|
|
5320
5334
|
static cssCache = {};
|
|
5321
5335
|
static registerPartials(templateDir) {
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5336
|
+
if (this.partialsLoaded[templateDir]) return;
|
|
5337
|
+
const registerFromDir = (dirPath) => {
|
|
5338
|
+
if (!fs3.existsSync(dirPath)) return;
|
|
5339
|
+
const files = fs3.readdirSync(dirPath);
|
|
5340
|
+
for (const file of files) {
|
|
5341
|
+
if (file.endsWith(".hbs")) {
|
|
5342
|
+
const name = path.basename(file, ".hbs");
|
|
5343
|
+
const content = fs3.readFileSync(path.join(dirPath, file), "utf-8");
|
|
5344
|
+
Handlebars.registerPartial(name, content);
|
|
5345
|
+
}
|
|
5330
5346
|
}
|
|
5331
|
-
}
|
|
5347
|
+
};
|
|
5348
|
+
registerFromDir(path.join(templateDir, "partials"));
|
|
5349
|
+
registerFromDir(path.join(templateDir, "layouts"));
|
|
5332
5350
|
this.partialsLoaded[templateDir] = true;
|
|
5333
5351
|
}
|
|
5334
5352
|
static loadAllCSS(stylesDir) {
|