@rdyl/node-koa-controller 0.3.6 → 0.3.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/CHANGELOG.md +1 -1
- package/dist/index.js +3 -0
- package/dist/meta.js +4 -0
- package/package.json +1 -1
- package/types/meta.d.ts +2 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -70,10 +70,13 @@ function useApiController(app, opts) {
|
|
|
70
70
|
cache_1.default.logs = logs;
|
|
71
71
|
cache_1.default.prefix = prefix;
|
|
72
72
|
router = new koa_router_1.default();
|
|
73
|
+
if (!root) return [3 /*break*/, 2];
|
|
73
74
|
rootDir = (0, path_1.resolve)(process.cwd(), root);
|
|
74
75
|
return [4 /*yield*/, cache_1.default.resolve(rootDir)];
|
|
75
76
|
case 1:
|
|
76
77
|
_d.sent();
|
|
78
|
+
_d.label = 2;
|
|
79
|
+
case 2:
|
|
77
80
|
// 注册路由
|
|
78
81
|
cache_1.default.register(router, useJwt);
|
|
79
82
|
if (opts.static) {
|
package/dist/meta.js
CHANGED
|
@@ -135,6 +135,10 @@ var BaseController = /** @class */ (function () {
|
|
|
135
135
|
_this._ctx.body = body;
|
|
136
136
|
};
|
|
137
137
|
return {
|
|
138
|
+
raw: function (body) {
|
|
139
|
+
_this._ctx.status = 200;
|
|
140
|
+
_this._ctx.body = body;
|
|
141
|
+
},
|
|
138
142
|
ok: function (data) {
|
|
139
143
|
sendJson({ data: data, code: 200, msg: "ok" });
|
|
140
144
|
},
|
package/package.json
CHANGED
package/types/meta.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class BaseController {
|
|
|
30
30
|
get body(): any;
|
|
31
31
|
files(): Promise<import("formidable").Files | undefined>;
|
|
32
32
|
get status(): {
|
|
33
|
+
raw: (body?: unknown) => void;
|
|
33
34
|
ok(data?: unknown): void;
|
|
34
35
|
okCreated(data: unknown, msg?: string): void;
|
|
35
36
|
okAccept(data: unknown, msg?: string): void;
|
|
@@ -53,7 +54,7 @@ export interface ResData<T> {
|
|
|
53
54
|
}
|
|
54
55
|
export interface UseProps {
|
|
55
56
|
port: number;
|
|
56
|
-
root
|
|
57
|
+
root?: string;
|
|
57
58
|
prefix?: string;
|
|
58
59
|
static?: string;
|
|
59
60
|
logs?: boolean;
|