namirasoft-node 1.4.71 → 1.4.73
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/BaseController.d.ts +12 -3
- package/dist/BaseController.js +26 -10
- package/dist/BaseController.js.map +1 -1
- package/package.json +4 -4
- package/src/BaseController.ts +39 -10
package/dist/BaseController.d.ts
CHANGED
|
@@ -8,8 +8,17 @@ import { BaseTypeSchema, BaseVariableSchema, ControllerSchema } from 'namirasoft
|
|
|
8
8
|
export declare abstract class BaseController<D extends {
|
|
9
9
|
[name: string]: BaseDatabase;
|
|
10
10
|
}, State, Props, Output> {
|
|
11
|
-
protected
|
|
12
|
-
|
|
11
|
+
protected log: {
|
|
12
|
+
show: boolean;
|
|
13
|
+
beginning: {
|
|
14
|
+
show: boolean;
|
|
15
|
+
onBefore: () => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
end: {
|
|
18
|
+
show: boolean;
|
|
19
|
+
onBefore: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
13
22
|
app: BaseApplication<D>;
|
|
14
23
|
req: express.Request;
|
|
15
24
|
res: express.Response;
|
|
@@ -54,5 +63,5 @@ export declare abstract class BaseController<D extends {
|
|
|
54
63
|
abstract postHandle(): Promise<void>;
|
|
55
64
|
run(): Promise<void | express.Response<any, Record<string, any>>>;
|
|
56
65
|
getSchema(): Promise<ControllerSchema>;
|
|
57
|
-
protected _setCookie(name: string, value: any): void;
|
|
66
|
+
protected _setCookie(name: string, value: any, expires?: Date | undefined): void;
|
|
58
67
|
}
|
package/dist/BaseController.js
CHANGED
|
@@ -15,8 +15,17 @@ const namirasoft_core_1 = require("namirasoft-core");
|
|
|
15
15
|
const namirasoft_schema_1 = require("namirasoft-schema");
|
|
16
16
|
class BaseController {
|
|
17
17
|
constructor(app, req, res) {
|
|
18
|
-
this.
|
|
19
|
-
|
|
18
|
+
this.log = {
|
|
19
|
+
show: true,
|
|
20
|
+
beginning: {
|
|
21
|
+
show: false,
|
|
22
|
+
onBefore: () => __awaiter(this, void 0, void 0, function* () { })
|
|
23
|
+
},
|
|
24
|
+
end: {
|
|
25
|
+
show: false,
|
|
26
|
+
onBefore: () => __awaiter(this, void 0, void 0, function* () { })
|
|
27
|
+
}
|
|
28
|
+
};
|
|
20
29
|
this.validate_query = true;
|
|
21
30
|
this.bodyAs = {
|
|
22
31
|
json: {
|
|
@@ -45,15 +54,19 @@ class BaseController {
|
|
|
45
54
|
}
|
|
46
55
|
run() {
|
|
47
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
48
58
|
let info = this.getInfo();
|
|
49
59
|
this.meta = new Meta_1.Meta(info, this.req, this.sensitive);
|
|
50
60
|
this.output = null;
|
|
51
61
|
this.result = null;
|
|
52
62
|
try {
|
|
53
63
|
this.meta.onStart();
|
|
54
|
-
if (this.
|
|
55
|
-
if (
|
|
56
|
-
this.
|
|
64
|
+
if (this.log.show)
|
|
65
|
+
if (this.log.beginning.show)
|
|
66
|
+
if (!this.meta.url.endsWith("/healthz")) {
|
|
67
|
+
yield ((_b = (_a = this.log.beginning).onBefore) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
68
|
+
this.app.logger.info(this.meta);
|
|
69
|
+
}
|
|
57
70
|
let accpet = new namirasoft_core_1.ObjectService(this.req.headers.accept).getString("");
|
|
58
71
|
let isJson = accpet.includes("application/json") || accpet.includes("*/*");
|
|
59
72
|
let isSchema = accpet.includes("application/schema");
|
|
@@ -118,9 +131,12 @@ class BaseController {
|
|
|
118
131
|
this.result = this.output;
|
|
119
132
|
}
|
|
120
133
|
this.meta.onFinish();
|
|
121
|
-
if (this.
|
|
122
|
-
if (
|
|
123
|
-
this.
|
|
134
|
+
if (this.log.show)
|
|
135
|
+
if (this.log.end.show)
|
|
136
|
+
if (!this.meta.url.endsWith("/healthz")) {
|
|
137
|
+
yield ((_d = (_c = this.log.end).onBefore) === null || _d === void 0 ? void 0 : _d.call(_c));
|
|
138
|
+
this.app.logger.info(this.meta);
|
|
139
|
+
}
|
|
124
140
|
if (this.meta.redirect_location)
|
|
125
141
|
return this.res.redirect(this.meta.code, this.meta.redirect_location);
|
|
126
142
|
return this.res.status(this.meta.code).send(this.result);
|
|
@@ -139,10 +155,10 @@ class BaseController {
|
|
|
139
155
|
return schema;
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
|
-
_setCookie(name, value) {
|
|
158
|
+
_setCookie(name, value, expires = undefined) {
|
|
143
159
|
let DOMAIN = new namirasoft_core_1.EnvService("DOMAIN").getString();
|
|
144
160
|
let domain = "." + DOMAIN;
|
|
145
|
-
this.res.cookie(name, value, { domain, path: "/", sameSite: "none", secure: true });
|
|
161
|
+
this.res.cookie(name, value, { domain, path: "/", sameSite: "none", secure: true, expires });
|
|
146
162
|
}
|
|
147
163
|
}
|
|
148
164
|
exports.BaseController = BaseController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseController.js","sourceRoot":"","sources":["../src/BaseController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,iCAA8B;AAC9B,qDAAmG;AAEnG,yDAAuG;AAEvG,MAAsB,cAAc;
|
|
1
|
+
{"version":3,"file":"BaseController.js","sourceRoot":"","sources":["../src/BaseController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,iCAA8B;AAC9B,qDAAmG;AAEnG,yDAAuG;AAEvG,MAAsB,cAAc;IAgDhC,YAAY,GAAuB,EAAE,GAAoB,EAAE,GAAqB;QA9CtE,QAAG,GAUT;YACI,IAAI,EAAE,IAAI;YACV,SAAS,EAAE;gBACP,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,GAAS,EAAE,gDAAG,CAAC,CAAA;aAC5B;YACD,GAAG,EAAE;gBACD,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,GAAS,EAAE,gDAAG,CAAC,CAAA;aAC5B;SACJ,CAAC;QASI,mBAAc,GAAY,IAAI,CAAC;QAC/B,WA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EAAE,CAAC,CAAC;IACjG,CAAC;CACJ;AAjND,wCAiNC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.73",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@supercharge/request-ip": "^1.2.0",
|
|
21
21
|
"@types/cors": "^2.8.17",
|
|
22
22
|
"@types/express": "^5.0.0",
|
|
23
|
-
"@types/node": "^22.13.
|
|
23
|
+
"@types/node": "^22.13.4",
|
|
24
24
|
"@types/node-cron": "^3.0.11",
|
|
25
25
|
"@types/nodemailer": "^6.4.17",
|
|
26
26
|
"@types/nodemailer-smtp-transport": "^2.7.8",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"cors": "^2.8.5",
|
|
31
31
|
"express": "^4.21.2",
|
|
32
32
|
"joi": "^17.13.3",
|
|
33
|
-
"namirasoft-core": "^1.4.
|
|
34
|
-
"namirasoft-log": "^1.4.
|
|
33
|
+
"namirasoft-core": "^1.4.51",
|
|
34
|
+
"namirasoft-log": "^1.4.20",
|
|
35
35
|
"namirasoft-schema": "^1.4.25",
|
|
36
36
|
"node-cron": "^3.0.3",
|
|
37
37
|
"nodemailer": "^6.10.0",
|
package/src/BaseController.ts
CHANGED
|
@@ -8,8 +8,27 @@ import { BaseTypeSchema, BaseVariableSchema, ControllerSchema, JoiValidator } fr
|
|
|
8
8
|
|
|
9
9
|
export abstract class BaseController<D extends { [name: string]: BaseDatabase }, State, Props, Output>
|
|
10
10
|
{
|
|
11
|
-
protected
|
|
12
|
-
|
|
11
|
+
protected log: {
|
|
12
|
+
show: boolean;
|
|
13
|
+
beginning: {
|
|
14
|
+
show: boolean;
|
|
15
|
+
onBefore: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
end: {
|
|
18
|
+
show: boolean;
|
|
19
|
+
onBefore: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
} = {
|
|
22
|
+
show: true,
|
|
23
|
+
beginning: {
|
|
24
|
+
show: false,
|
|
25
|
+
onBefore: async () => { }
|
|
26
|
+
},
|
|
27
|
+
end: {
|
|
28
|
+
show: false,
|
|
29
|
+
onBefore: async () => { }
|
|
30
|
+
}
|
|
31
|
+
};
|
|
13
32
|
public app: BaseApplication<D>;
|
|
14
33
|
public req: express.Request;
|
|
15
34
|
public res: express.Response;
|
|
@@ -72,9 +91,13 @@ export abstract class BaseController<D extends { [name: string]: BaseDatabase },
|
|
|
72
91
|
{
|
|
73
92
|
// meta
|
|
74
93
|
this.meta.onStart();
|
|
75
|
-
if (this.
|
|
76
|
-
if (
|
|
77
|
-
this.
|
|
94
|
+
if (this.log.show)
|
|
95
|
+
if (this.log.beginning.show)
|
|
96
|
+
if (!this.meta.url.endsWith("/healthz"))
|
|
97
|
+
{
|
|
98
|
+
await this.log.beginning.onBefore?.();
|
|
99
|
+
this.app.logger.info(this.meta);
|
|
100
|
+
}
|
|
78
101
|
|
|
79
102
|
let accpet: string = new ObjectService(this.req.headers.accept).getString("");
|
|
80
103
|
let isJson = accpet.includes("application/json") || accpet.includes("*/*");
|
|
@@ -159,11 +182,17 @@ export abstract class BaseController<D extends { [name: string]: BaseDatabase },
|
|
|
159
182
|
else
|
|
160
183
|
this.result = this.output;
|
|
161
184
|
}
|
|
185
|
+
|
|
162
186
|
// finish
|
|
163
187
|
this.meta.onFinish();
|
|
164
|
-
if (this.
|
|
165
|
-
if (
|
|
166
|
-
this.
|
|
188
|
+
if (this.log.show)
|
|
189
|
+
if (this.log.end.show)
|
|
190
|
+
if (!this.meta.url.endsWith("/healthz"))
|
|
191
|
+
{
|
|
192
|
+
await this.log.end.onBefore?.();
|
|
193
|
+
this.app.logger.info(this.meta);
|
|
194
|
+
}
|
|
195
|
+
|
|
167
196
|
if (this.meta.redirect_location)
|
|
168
197
|
return this.res.redirect(this.meta.code, this.meta.redirect_location);
|
|
169
198
|
return this.res.status(this.meta.code).send(this.result);
|
|
@@ -180,10 +209,10 @@ export abstract class BaseController<D extends { [name: string]: BaseDatabase },
|
|
|
180
209
|
schema.check();
|
|
181
210
|
return schema;
|
|
182
211
|
}
|
|
183
|
-
protected _setCookie(name: string, value: any)
|
|
212
|
+
protected _setCookie(name: string, value: any, expires: Date | undefined = undefined)
|
|
184
213
|
{
|
|
185
214
|
let DOMAIN = new EnvService("DOMAIN").getString();
|
|
186
215
|
let domain = "." + DOMAIN;
|
|
187
|
-
this.res.cookie(name, value, { domain, path: "/", sameSite: "none", secure: true });
|
|
216
|
+
this.res.cookie(name, value, { domain, path: "/", sameSite: "none", secure: true, expires });
|
|
188
217
|
}
|
|
189
218
|
}
|