@novice1/app 0.2.1 → 0.3.1
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 +1 -1
- package/lib/app.d.ts +100 -100
- package/lib/app.js +97 -97
- package/lib/baseApp.d.ts +101 -97
- package/lib/baseApp.js +310 -291
- package/lib/baseApp.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +5 -5
- package/lib/middlewares/reply.d.ts +3 -3
- package/lib/middlewares/reply.js +13 -13
- package/package.json +18 -17
package/lib/baseApp.d.ts
CHANGED
|
@@ -1,97 +1,101 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
get
|
|
48
|
-
get
|
|
49
|
-
get
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
listen(port?: number, listeningListener?: () => void): http.Server;
|
|
80
|
-
listen(
|
|
81
|
-
listen(
|
|
82
|
-
listen(
|
|
83
|
-
listen(
|
|
84
|
-
listen(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import net from 'net';
|
|
5
|
+
import { ParsedQs } from 'qs';
|
|
6
|
+
import express from 'express';
|
|
7
|
+
import core from 'express-serve-static-core';
|
|
8
|
+
import { IRouter, RequestHandler, RouteMeta } from '@novice1/routing';
|
|
9
|
+
export interface FrameworkOptions {
|
|
10
|
+
auth?: RequestHandler[];
|
|
11
|
+
middlewares?: (core.RequestHandler | core.RequestHandlerParams)[];
|
|
12
|
+
validators?: RequestHandler[];
|
|
13
|
+
}
|
|
14
|
+
export interface Options {
|
|
15
|
+
framework?: FrameworkOptions;
|
|
16
|
+
routers?: IRouter[];
|
|
17
|
+
}
|
|
18
|
+
export interface IApp {
|
|
19
|
+
get meta(): RouteMeta[];
|
|
20
|
+
get server(): http.Server | undefined;
|
|
21
|
+
addRouters(routers: IRouter[] | IRouter): IApp;
|
|
22
|
+
addOptions(options: Options): IApp;
|
|
23
|
+
build<T extends http.ServerOptions = http.ServerOptions>(options?: T | null, mod?: {
|
|
24
|
+
createServer(requestListener?: http.RequestListener): http.Server;
|
|
25
|
+
createServer(options: T, requestListener?: http.RequestListener | undefined): http.Server;
|
|
26
|
+
}): http.Server;
|
|
27
|
+
disable(setting: string): IApp;
|
|
28
|
+
enable(setting: string): IApp;
|
|
29
|
+
disabled(setting: string): boolean;
|
|
30
|
+
enabled(setting: string): boolean;
|
|
31
|
+
on(event: string, callback: (parent: core.Application) => void): IApp;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Abstract application
|
|
35
|
+
*/
|
|
36
|
+
export declare abstract class BaseApp implements IApp {
|
|
37
|
+
#private;
|
|
38
|
+
protected __app: express.Application;
|
|
39
|
+
protected __router: IRouter;
|
|
40
|
+
/**
|
|
41
|
+
* Express Application
|
|
42
|
+
*/
|
|
43
|
+
get _app(): express.Application;
|
|
44
|
+
/**
|
|
45
|
+
* Main router
|
|
46
|
+
*/
|
|
47
|
+
get _router(): IRouter;
|
|
48
|
+
get building(): boolean;
|
|
49
|
+
get built(): boolean;
|
|
50
|
+
get meta(): RouteMeta[];
|
|
51
|
+
get server(): http.Server | undefined;
|
|
52
|
+
constructor(options?: Options);
|
|
53
|
+
private _registerRouter;
|
|
54
|
+
private _buildFramework;
|
|
55
|
+
private _buildRoutes;
|
|
56
|
+
private _buildErrorRequestHandlers;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param options Options to concatenate with current options.
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
addOptions(options: Options): BaseApp;
|
|
63
|
+
addFrameworkOptions(options: FrameworkOptions): BaseApp;
|
|
64
|
+
addRouters(routers: IRouter[] | IRouter): BaseApp;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param options
|
|
68
|
+
* @param mod Module that will create the server (e.g.: require('https'))
|
|
69
|
+
* @example ```js
|
|
70
|
+
* const https = require('https');
|
|
71
|
+
* const server = app.build(HTTPS_SERVER_OPTIONS, https);
|
|
72
|
+
* server.listen(PORT);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
build<T extends http.ServerOptions = http.ServerOptions>(options?: T | null, mod?: {
|
|
76
|
+
createServer(requestListener?: http.RequestListener): http.Server;
|
|
77
|
+
createServer(options: T, requestListener?: http.RequestListener | undefined): http.Server;
|
|
78
|
+
}): http.Server;
|
|
79
|
+
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): http.Server;
|
|
80
|
+
listen(port?: number, hostname?: string, listeningListener?: () => void): http.Server;
|
|
81
|
+
listen(port?: number, backlog?: number, listeningListener?: () => void): http.Server;
|
|
82
|
+
listen(port?: number, listeningListener?: () => void): http.Server;
|
|
83
|
+
listen(path: string, backlog?: number, listeningListener?: () => void): http.Server;
|
|
84
|
+
listen(path: string, listeningListener?: () => void): http.Server;
|
|
85
|
+
listen(options: net.ListenOptions, listeningListener?: () => void): http.Server;
|
|
86
|
+
listen(handle: unknown, backlog?: number, listeningListener?: () => void): http.Server;
|
|
87
|
+
listen(handle: unknown, listeningListener?: () => void): http.Server;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a router and adds it to the application.
|
|
90
|
+
* @returns The created router
|
|
91
|
+
*/
|
|
92
|
+
lazyrouter(options?: express.RouterOptions): IRouter;
|
|
93
|
+
disable(setting: string): BaseApp;
|
|
94
|
+
disabled(setting: string): boolean;
|
|
95
|
+
enable(setting: string): BaseApp;
|
|
96
|
+
enabled(setting: string): boolean;
|
|
97
|
+
on(event: string, callback: (parent: core.Application) => void): BaseApp;
|
|
98
|
+
set(setting: string, val?: unknown): BaseApp;
|
|
99
|
+
get(setting: string): any;
|
|
100
|
+
useError<P = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, Locals extends Record<string, any> = Record<string, any>>(...handlers: Array<core.RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, Locals>>): BaseApp;
|
|
101
|
+
}
|