@wxn0brp/falcon-frame 0.0.11 → 0.0.12
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.d.ts +3 -3
- package/dist/index.js +8 -5
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger, LoggerOptions } from "@wxn0brp/lucerna-log";
|
|
2
2
|
import http from "http";
|
|
3
3
|
import { FFResponse } from "./res.js";
|
|
4
|
-
import { FFRequest, Method, Middleware, RouteHandler } from "./types.js";
|
|
4
|
+
import { AfterHandleRequest, FFRequest, Method, Middleware, RouteHandler } from "./types.js";
|
|
5
5
|
import { renderHTML } from "./render.js";
|
|
6
6
|
import { PluginSystem } from "./plugins.js";
|
|
7
7
|
export declare class FalconFrame {
|
|
@@ -16,8 +16,8 @@ export declare class FalconFrame {
|
|
|
16
16
|
delete(path: string, ...handlers: RouteHandler[]): void;
|
|
17
17
|
all(path: string, ...handlers: RouteHandler[]): void;
|
|
18
18
|
static(apiPath: string, dirPath: string): void;
|
|
19
|
-
listen(port: number, callback?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
20
|
-
getApp(): (req: any, res: any) =>
|
|
19
|
+
listen(port: number, callback?: () => void, afterHandleRequest?: AfterHandleRequest): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
20
|
+
getApp(afterHandleRequest?: AfterHandleRequest): (req: any, res: any) => any;
|
|
21
21
|
}
|
|
22
22
|
export default FalconFrame;
|
|
23
23
|
export { FFResponse, FFRequest, RouteHandler, renderHTML, PluginSystem, };
|
package/dist/index.js
CHANGED
|
@@ -54,15 +54,18 @@ export class FalconFrame {
|
|
|
54
54
|
middleware: handleStaticFiles(apiPath, dirPath)
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
listen(port, callback) {
|
|
58
|
-
const server = http.createServer((
|
|
59
|
-
handleRequest(req, res, this);
|
|
60
|
-
});
|
|
57
|
+
listen(port, callback, afterHandleRequest) {
|
|
58
|
+
const server = http.createServer(this.getApp(afterHandleRequest));
|
|
61
59
|
server.listen(port, callback);
|
|
62
60
|
return server;
|
|
63
61
|
}
|
|
64
|
-
getApp() {
|
|
62
|
+
getApp(afterHandleRequest) {
|
|
65
63
|
return (req, res) => {
|
|
64
|
+
if (afterHandleRequest) {
|
|
65
|
+
const result = afterHandleRequest(req, res);
|
|
66
|
+
if (result)
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
66
69
|
handleRequest(req, res, this);
|
|
67
70
|
};
|
|
68
71
|
}
|
package/dist/types.d.ts
CHANGED