@increase21/simplenodejs 1.0.13 → 1.0.15
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/README.md
CHANGED
|
@@ -75,8 +75,9 @@ app.listen(4000,callback)
|
|
|
75
75
|
|
|
76
76
|
Controllers are auto-loaded from `controllersDir`.
|
|
77
77
|
#### Running Multiple Methods
|
|
78
|
-
./controllers/{servicefolder}/auth.ts
|
|
79
|
-
|
|
78
|
+
##### ./controllers/{servicefolder}/auth.ts
|
|
79
|
+
#### or
|
|
80
|
+
#### ./controllers/{servicefolder}/auth.js
|
|
80
81
|
|
|
81
82
|
```ts
|
|
82
83
|
export default AuthControllers extends SimpleNodeJsController {
|
|
@@ -12,7 +12,8 @@ export declare class SimpleNodeJsController {
|
|
|
12
12
|
req: RequestObject;
|
|
13
13
|
res: ResponseObject;
|
|
14
14
|
}): void;
|
|
15
|
+
/** framework-internal method */
|
|
15
16
|
__checkContext(): void;
|
|
16
|
-
protected RunRequest(handlers: SubRequestHandler, params
|
|
17
|
+
protected RunRequest(handlers: SubRequestHandler, params?: SimpleJsPrivateMethodProps): any;
|
|
17
18
|
}
|
|
18
19
|
export {};
|
|
@@ -11,6 +11,7 @@ class SimpleNodeJsController {
|
|
|
11
11
|
this.method = (ctx.req.method || "").toLocaleLowerCase();
|
|
12
12
|
this._custom_data = ctx.req._custom_data;
|
|
13
13
|
}
|
|
14
|
+
/** framework-internal method */
|
|
14
15
|
__checkContext() { }
|
|
15
16
|
RunRequest(handlers, params) {
|
|
16
17
|
const method = this.req.method?.toLowerCase();
|
|
@@ -26,7 +27,12 @@ class SimpleNodeJsController {
|
|
|
26
27
|
if (params && params.idMethod?.[method] === "required" && !params.id) {
|
|
27
28
|
return this.res.status(404).json({ code: 404, error: "Resource not found" });
|
|
28
29
|
}
|
|
29
|
-
return runFn(
|
|
30
|
+
return runFn({
|
|
31
|
+
...(params || {}), req: this.req,
|
|
32
|
+
res: this.res, query: this.query,
|
|
33
|
+
customData: this._custom_data,
|
|
34
|
+
body: this.body,
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
exports.SimpleNodeJsController = SimpleNodeJsController;
|
package/package.json
CHANGED