@novice1/app 0.9.4 → 0.9.5
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 +174 -45
- package/lib/app.d.ts +2 -2
- package/lib/app.js +3 -3
- package/lib/app.js.map +1 -1
- package/lib/baseApp.d.ts +4 -4
- package/lib/baseApp.js +44 -49
- package/lib/baseApp.js.map +1 -1
- package/package.json +43 -27
package/README.md
CHANGED
|
@@ -1,30 +1,77 @@
|
|
|
1
1
|
# @novice1/app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
[](https://nodejs.org)
|
|
5
|
+
|
|
6
|
+
Build [Express v5](https://expressjs.com) applications on top of [@novice1/routing](https://www.npmjs.com/package/@novice1/routing).
|
|
7
|
+
|
|
8
|
+
`FrameworkApp` wraps an Express application and gives you:
|
|
9
|
+
|
|
10
|
+
- **Routers** from `@novice1/routing`, registered by options or created on the fly.
|
|
11
|
+
- **Framework-level `middlewares`, `auth` and `validators`**, applied to every registered router.
|
|
12
|
+
- **Route metadata** (`name`, `tags`, ...) available through `app.meta`.
|
|
13
|
+
- **Deferred server creation**: `http`/`https` servers are created for you, so the Express app never has to be wired by hand.
|
|
14
|
+
- **Typed, chainable API** written in TypeScript.
|
|
15
|
+
|
|
16
|
+
## Table of contents
|
|
17
|
+
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Quick start](#quick-start)
|
|
20
|
+
- [Configuration](#configuration)
|
|
21
|
+
- [Defining routes](#defining-routes)
|
|
22
|
+
- [Error handling](#error-handling)
|
|
23
|
+
- [Starting the server](#starting-the-server)
|
|
24
|
+
- [Express settings](#express-settings)
|
|
25
|
+
- [API overview](#api-overview)
|
|
26
|
+
- [Development](#development)
|
|
27
|
+
- [References](#references)
|
|
28
|
+
- [License](#license)
|
|
4
29
|
|
|
5
30
|
## Installation
|
|
6
31
|
|
|
32
|
+
`express` and `@novice1/routing` are peer dependencies.
|
|
33
|
+
|
|
7
34
|
```bash
|
|
8
|
-
|
|
35
|
+
npm install @novice1/app @novice1/routing express
|
|
9
36
|
```
|
|
10
37
|
|
|
11
|
-
|
|
38
|
+
Requires Node.js 18 or later.
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
12
41
|
|
|
13
42
|
```js
|
|
14
|
-
|
|
15
|
-
|
|
43
|
+
import routing from '@novice1/routing';
|
|
44
|
+
import { FrameworkApp } from '@novice1/app';
|
|
16
45
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
|
|
46
|
+
const router = routing()
|
|
47
|
+
.get({ path: '/', name: 'Home', tags: ['Index'] }, (req, res) => {
|
|
48
|
+
res.send('Hello world');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const app = new FrameworkApp({
|
|
52
|
+
routers: [router]
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
app.listen(8000, '0.0.0.0', () => {
|
|
56
|
+
console.log('Application started ...');
|
|
57
|
+
console.log(app.meta); // metadata of every registered route
|
|
22
58
|
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
CommonJS works too:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const { FrameworkApp } = require('@novice1/app');
|
|
65
|
+
```
|
|
23
66
|
|
|
24
|
-
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
Pass options to the constructor, or add them later with `addOptions()`.
|
|
70
|
+
|
|
71
|
+
```js
|
|
25
72
|
const app = new FrameworkApp({
|
|
26
73
|
framework: {
|
|
27
|
-
// middlewares
|
|
74
|
+
// regular Express middlewares, registered before the routers' routes
|
|
28
75
|
middlewares: [
|
|
29
76
|
(req, res, next) => {
|
|
30
77
|
next();
|
|
@@ -43,51 +90,61 @@ const app = new FrameworkApp({
|
|
|
43
90
|
}
|
|
44
91
|
]
|
|
45
92
|
},
|
|
46
|
-
|
|
47
|
-
routers: [
|
|
48
|
-
router
|
|
49
|
-
]
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// http.Server
|
|
53
|
-
const server = app.listen(8000, '0.0.0.0', () => {
|
|
54
|
-
console.log('Application started ...');
|
|
55
|
-
console.log(app.meta)
|
|
93
|
+
routers: [router]
|
|
56
94
|
});
|
|
57
95
|
```
|
|
58
96
|
|
|
59
|
-
|
|
60
|
-
|
|
97
|
+
| Option | Description |
|
|
98
|
+
| ---------------------- | ---------------------------------------------------------------------------------------- |
|
|
99
|
+
| `middlewares` | Express middlewares added to the main router. |
|
|
100
|
+
| `auth` | Authorization handlers, set on each router that does not define its own. |
|
|
101
|
+
| `validators` | Validation handlers, set on each router that does not define its own. |
|
|
102
|
+
| `routers` | `@novice1/routing` routers to register. |
|
|
103
|
+
|
|
104
|
+
> `auth` and `validators` are only applied to routers that have none of their own.
|
|
105
|
+
|
|
106
|
+
### Adding options later
|
|
107
|
+
|
|
108
|
+
`addOptions()` concatenates new options with the current ones. Routers can be added even after the application is built.
|
|
109
|
+
|
|
61
110
|
```js
|
|
62
111
|
app.addOptions({
|
|
63
|
-
|
|
64
|
-
routers: [router]
|
|
112
|
+
routers: [anotherRouter]
|
|
65
113
|
});
|
|
66
|
-
```
|
|
67
114
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
app.addRouters([router]);
|
|
115
|
+
// or, only routers
|
|
116
|
+
app.addRouters([anotherRouter]);
|
|
71
117
|
```
|
|
118
|
+
|
|
119
|
+
## Defining routes
|
|
120
|
+
|
|
121
|
+
Besides registering routers, you can declare routes directly on the application. They are added to an internal router created with `lazyrouter()`.
|
|
122
|
+
|
|
72
123
|
```js
|
|
73
124
|
app.get({
|
|
74
125
|
path: '/index',
|
|
75
126
|
name: 'Home',
|
|
76
127
|
tags: ['Index']
|
|
77
128
|
}, function homepage(req, res) {
|
|
78
|
-
|
|
129
|
+
res.send('Home');
|
|
79
130
|
});
|
|
80
131
|
|
|
81
132
|
app.put('/add', (req, res) => {
|
|
82
133
|
// ...
|
|
83
134
|
});
|
|
84
135
|
|
|
85
|
-
app.use((
|
|
86
|
-
|
|
136
|
+
app.use((req, res, next) => {
|
|
137
|
+
next();
|
|
87
138
|
});
|
|
88
139
|
```
|
|
140
|
+
|
|
141
|
+
Supported methods: `all`, `get`, `post`, `put`, `delete`, `patch`, `options`, `head`, `use` and `param`.
|
|
142
|
+
|
|
143
|
+
You can also create and keep a reference to the router yourself. It is added to the application immediately:
|
|
144
|
+
|
|
89
145
|
```js
|
|
90
146
|
const lazyRouter = app.lazyrouter();
|
|
147
|
+
|
|
91
148
|
lazyRouter.get({
|
|
92
149
|
path: '/index',
|
|
93
150
|
name: 'Home',
|
|
@@ -99,31 +156,103 @@ lazyRouter.get({
|
|
|
99
156
|
lazyRouter.put('/add', (req, res) => {
|
|
100
157
|
// ...
|
|
101
158
|
});
|
|
159
|
+
```
|
|
102
160
|
|
|
103
|
-
|
|
104
|
-
|
|
161
|
+
## Error handling
|
|
162
|
+
|
|
163
|
+
Use `useError()` to register error-handling middlewares. They are mounted after all routes when the application is built (or immediately if it is already built).
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
app.useError((err, req, res, next) => {
|
|
167
|
+
res.status(500).json({ message: err.message });
|
|
105
168
|
});
|
|
106
169
|
```
|
|
107
170
|
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
const httpServerOptions = {};
|
|
171
|
+
## Starting the server
|
|
111
172
|
|
|
112
|
-
|
|
113
|
-
|
|
173
|
+
### `listen()`
|
|
174
|
+
|
|
175
|
+
`listen()` builds the application and starts an `http.Server`. It accepts the same arguments as `server.listen()` and returns the server.
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
const server = app.listen(8000, '0.0.0.0', () => {
|
|
114
179
|
console.log('Application started ...');
|
|
115
|
-
console.log(app.meta)
|
|
116
180
|
});
|
|
117
181
|
```
|
|
118
182
|
|
|
183
|
+
### `build()`
|
|
184
|
+
|
|
185
|
+
`build()` builds the application and returns the `http.Server` **without** starting it. Calling it again returns the same server. Pass `http.ServerOptions`, and optionally another module such as `https`:
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
const server = app.build({ keepAlive: true });
|
|
189
|
+
server.listen(8000);
|
|
190
|
+
```
|
|
191
|
+
|
|
119
192
|
```js
|
|
120
|
-
|
|
121
|
-
|
|
193
|
+
import https from 'https';
|
|
194
|
+
|
|
195
|
+
const httpsServerOptions = {
|
|
196
|
+
// key, cert, ...
|
|
197
|
+
};
|
|
122
198
|
|
|
123
199
|
const server = app.build(httpsServerOptions, https);
|
|
124
|
-
server.listen(
|
|
200
|
+
server.listen(8443);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
After building, `app.server` returns the server, and `app.built` is `true`.
|
|
204
|
+
|
|
205
|
+
## Express settings
|
|
206
|
+
|
|
207
|
+
The usual Express application helpers are available and chainable:
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
app
|
|
211
|
+
.set('trust proxy', true)
|
|
212
|
+
.enable('etag')
|
|
213
|
+
.disable('x-powered-by');
|
|
214
|
+
|
|
215
|
+
app.enabled('etag'); // true
|
|
216
|
+
app.get('trust proxy'); // true
|
|
217
|
+
app.engine('html', renderFn);
|
|
125
218
|
```
|
|
219
|
+
|
|
220
|
+
## API overview
|
|
221
|
+
|
|
222
|
+
| Member | Description |
|
|
223
|
+
| ------------------------------------ | ----------------------------------------------------------------- |
|
|
224
|
+
| `new FrameworkApp(options?)` | Creates the application. |
|
|
225
|
+
| `addOptions(options)` | Concatenates options with the current ones. |
|
|
226
|
+
| `addFrameworkOptions(options)` | Sets `middlewares`, `auth` and/or `validators`. |
|
|
227
|
+
| `addRouters(routers)` | Adds one or several routers. |
|
|
228
|
+
| `lazyrouter(options?)` | Creates a router, adds it to the app and returns it. |
|
|
229
|
+
| `all / get / post / put / delete / patch / options / head / use / param` | Declare routes and middlewares. |
|
|
230
|
+
| `useError(...handlers)` | Registers error-handling middlewares. |
|
|
231
|
+
| `build(options?, mod?)` | Builds the app and creates the server (without listening). |
|
|
232
|
+
| `listen(...)` | Builds the app and starts listening. |
|
|
233
|
+
| `set / enable / disable / enabled / disabled / engine / on('mount')` | Express settings. |
|
|
234
|
+
| `meta` | Metadata of the registered routes. |
|
|
235
|
+
| `server`, `building`, `built` | Server instance and build state. |
|
|
236
|
+
|
|
237
|
+
Full documentation is available at [kisiwu.github.io/novice-app](https://kisiwu.github.io/novice-app/latest/).
|
|
238
|
+
|
|
239
|
+
## Development
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npm run build # compile TypeScript to lib/
|
|
243
|
+
npm test # run tests against the sources
|
|
244
|
+
npm run test:lib # run tests against the compiled output
|
|
245
|
+
npm run lint # lint
|
|
246
|
+
npm run format # format with Prettier
|
|
247
|
+
npm run doc # generate the documentation
|
|
248
|
+
```
|
|
249
|
+
|
|
126
250
|
## References
|
|
127
251
|
|
|
128
252
|
- [Express](https://expressjs.com)
|
|
129
|
-
- [@novice1/
|
|
253
|
+
- [@novice1/routing](https://www.npmjs.com/package/@novice1/routing)
|
|
254
|
+
- [Documentation](https://kisiwu.github.io/novice-app/latest/)
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
[MIT](./LICENSE)
|
package/lib/app.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseApp, Options } from './baseApp';
|
|
2
|
+
import { IRouter, RequestHandler, RequestHandlerParams, RouteSettings, RouteSettingsParams } from '@novice1/routing';
|
|
1
3
|
import core from 'express-serve-static-core';
|
|
2
4
|
import { ParsedQs } from 'qs';
|
|
3
|
-
import { IRouter, RequestHandler, RequestHandlerParams, RouteSettings, RouteSettingsParams } from '@novice1/routing';
|
|
4
|
-
import { BaseApp, Options } from './baseApp';
|
|
5
5
|
/**
|
|
6
6
|
* The application
|
|
7
7
|
*/
|
package/lib/app.js
CHANGED
|
@@ -34,7 +34,7 @@ class FrameworkApp extends baseApp_1.BaseApp {
|
|
|
34
34
|
//--- LAZYROUTER METHODS
|
|
35
35
|
param(name, handler) {
|
|
36
36
|
if (Array.isArray(name)) {
|
|
37
|
-
name.forEach(n => {
|
|
37
|
+
name.forEach((n) => {
|
|
38
38
|
this.param(n, handler);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -47,9 +47,9 @@ class FrameworkApp extends baseApp_1.BaseApp {
|
|
|
47
47
|
this.lazyrouter().all(path, ...handlers);
|
|
48
48
|
return this;
|
|
49
49
|
}
|
|
50
|
-
get(path,
|
|
50
|
+
get(path, ...handlers
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
|
|
52
|
+
) {
|
|
53
53
|
if (!handlers.length && typeof path === 'string') {
|
|
54
54
|
return super.get(path);
|
|
55
55
|
}
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAK7C;;GAEG;AACH,kBAA0B,SAAQ,iBAAO;IACvC,sBAAsB;IAEtB,UAAU,CAAC,OAAgB;QACzB,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAA4B;QACrC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,OAAe;QACpB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,EAAE,CAAC,KAAc,EAAE,QAA4C;QAC7D,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CA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ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import net from 'net';
|
|
3
|
-
import { ParsedQs } from 'qs';
|
|
1
|
+
import { IRouter, RequestHandler, RouteMeta } from '@novice1/routing';
|
|
4
2
|
import express from 'express';
|
|
5
3
|
import core from 'express-serve-static-core';
|
|
6
|
-
import
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import net from 'node:net';
|
|
6
|
+
import { ParsedQs } from 'qs';
|
|
7
7
|
export interface FrameworkOptions {
|
|
8
8
|
auth?: RequestHandler[];
|
|
9
9
|
middlewares?: (core.RequestHandler | core.RequestHandlerParams)[];
|
package/lib/baseApp.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _BaseApp_config, _BaseApp_server, _BaseApp_errorRequestHandlers, _BaseApp_isBuilding, _BaseApp_isBuilt;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.BaseApp = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
|
-
const http_1 = tslib_1.__importDefault(require("http"));
|
|
7
|
-
const express_1 = tslib_1.__importDefault(require("express"));
|
|
8
5
|
const routing_1 = tslib_1.__importDefault(require("@novice1/routing"));
|
|
6
|
+
const express_1 = tslib_1.__importDefault(require("express"));
|
|
7
|
+
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
9
8
|
/**
|
|
10
9
|
* Abstract application
|
|
11
10
|
*/
|
|
12
11
|
class BaseApp {
|
|
12
|
+
#config = {};
|
|
13
|
+
#server;
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
#errorRequestHandlers = [];
|
|
16
|
+
#isBuilding = false;
|
|
17
|
+
#isBuilt = false;
|
|
18
|
+
__app;
|
|
19
|
+
__router;
|
|
13
20
|
/**
|
|
14
21
|
* Express Application
|
|
15
22
|
*/
|
|
@@ -23,61 +30,49 @@ class BaseApp {
|
|
|
23
30
|
return this.__router;
|
|
24
31
|
}
|
|
25
32
|
get building() {
|
|
26
|
-
return
|
|
33
|
+
return this.#isBuilding;
|
|
27
34
|
}
|
|
28
35
|
get built() {
|
|
29
|
-
return
|
|
36
|
+
return this.#isBuilt;
|
|
30
37
|
}
|
|
31
38
|
get meta() {
|
|
32
39
|
return this.__router.getMeta();
|
|
33
40
|
}
|
|
34
41
|
get server() {
|
|
35
|
-
return
|
|
42
|
+
return this.#server;
|
|
36
43
|
}
|
|
37
44
|
constructor(options) {
|
|
38
|
-
_BaseApp_config.set(this, {});
|
|
39
|
-
_BaseApp_server.set(this, void 0);
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
_BaseApp_errorRequestHandlers.set(this, []);
|
|
42
|
-
_BaseApp_isBuilding.set(this, false);
|
|
43
|
-
_BaseApp_isBuilt.set(this, false);
|
|
44
45
|
this.__app = (0, express_1.default)();
|
|
45
46
|
this.__router = (0, routing_1.default)();
|
|
46
47
|
this.addOptions(options || {});
|
|
47
48
|
}
|
|
48
49
|
_registerRouter(router) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
&& typeof router.setValidatorsIfNone === 'function') {
|
|
52
|
-
router.setValidatorsIfNone(tslib_1.__classPrivateFieldGet(this, _BaseApp_config, "f").framework.validators);
|
|
50
|
+
if (this.#config?.framework?.validators?.length && typeof router.setValidatorsIfNone === 'function') {
|
|
51
|
+
router.setValidatorsIfNone(this.#config.framework.validators);
|
|
53
52
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
router.setAuthHandlersIfNone(tslib_1.__classPrivateFieldGet(this, _BaseApp_config, "f").framework.auth);
|
|
53
|
+
if (this.#config?.framework?.auth?.length && typeof router.setAuthHandlersIfNone === 'function') {
|
|
54
|
+
router.setAuthHandlersIfNone(this.#config.framework.auth);
|
|
57
55
|
}
|
|
58
56
|
this.__router.use(router);
|
|
59
57
|
}
|
|
60
58
|
_buildFramework() {
|
|
61
|
-
var _a, _b;
|
|
62
59
|
// register main router
|
|
63
60
|
this.__app.use(this.__router);
|
|
64
61
|
// register framework's middlewares
|
|
65
62
|
// ... no more framework's middlewares
|
|
66
63
|
// register user's middlewares
|
|
67
|
-
if (
|
|
68
|
-
this.__router.use(...
|
|
64
|
+
if (this.#config.framework?.middlewares?.length) {
|
|
65
|
+
this.__router.use(...this.#config.framework.middlewares);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
_buildRoutes() {
|
|
72
|
-
|
|
73
|
-
(_a = tslib_1.__classPrivateFieldGet(this, _BaseApp_config, "f").routers) === null || _a === void 0 ? void 0 : _a.forEach(router => {
|
|
69
|
+
this.#config.routers?.forEach((router) => {
|
|
74
70
|
this._registerRouter(router);
|
|
75
71
|
});
|
|
76
72
|
}
|
|
77
73
|
_buildErrorRequestHandlers() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.__app.use(...tslib_1.__classPrivateFieldGet(this, _BaseApp_errorRequestHandlers, "f"));
|
|
74
|
+
if (this.#errorRequestHandlers?.length) {
|
|
75
|
+
this.__app.use(...this.#errorRequestHandlers);
|
|
81
76
|
}
|
|
82
77
|
}
|
|
83
78
|
/**
|
|
@@ -97,17 +92,17 @@ class BaseApp {
|
|
|
97
92
|
return this;
|
|
98
93
|
}
|
|
99
94
|
addFrameworkOptions(options) {
|
|
100
|
-
const frameworkOpts =
|
|
95
|
+
const frameworkOpts = this.#config.framework || {};
|
|
101
96
|
if (Array.isArray(options.middlewares)) {
|
|
102
97
|
const middlewares = [];
|
|
103
|
-
options.middlewares.forEach(element => {
|
|
98
|
+
options.middlewares.forEach((element) => {
|
|
104
99
|
middlewares.push(element);
|
|
105
100
|
});
|
|
106
101
|
frameworkOpts.middlewares = middlewares;
|
|
107
102
|
}
|
|
108
103
|
if (Array.isArray(options.auth)) {
|
|
109
104
|
const auth = [];
|
|
110
|
-
options.auth.forEach(element => {
|
|
105
|
+
options.auth.forEach((element) => {
|
|
111
106
|
if (typeof element === 'function') {
|
|
112
107
|
auth.push(element);
|
|
113
108
|
}
|
|
@@ -116,35 +111,35 @@ class BaseApp {
|
|
|
116
111
|
}
|
|
117
112
|
if (Array.isArray(options.validators)) {
|
|
118
113
|
const validators = [];
|
|
119
|
-
options.validators.forEach(element => {
|
|
114
|
+
options.validators.forEach((element) => {
|
|
120
115
|
if (typeof element === 'function') {
|
|
121
116
|
validators.push(element);
|
|
122
117
|
}
|
|
123
118
|
});
|
|
124
119
|
frameworkOpts.validators = validators;
|
|
125
120
|
}
|
|
126
|
-
|
|
121
|
+
this.#config.framework = frameworkOpts;
|
|
127
122
|
return this;
|
|
128
123
|
}
|
|
129
124
|
addRouters(routers) {
|
|
130
125
|
if (!this.built) {
|
|
131
126
|
if (routers) {
|
|
132
127
|
if (Array.isArray(routers)) {
|
|
133
|
-
routers.forEach(router => {
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
routers.forEach((router) => {
|
|
129
|
+
this.#config.routers = this.#config.routers || [];
|
|
130
|
+
this.#config.routers.push(router);
|
|
136
131
|
});
|
|
137
132
|
}
|
|
138
133
|
else {
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
this.#config.routers = this.#config.routers || [];
|
|
135
|
+
this.#config.routers.push(routers);
|
|
141
136
|
}
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
else {
|
|
145
140
|
if (routers) {
|
|
146
141
|
if (Array.isArray(routers)) {
|
|
147
|
-
routers.forEach(router => {
|
|
142
|
+
routers.forEach((router) => {
|
|
148
143
|
this._registerRouter(router);
|
|
149
144
|
});
|
|
150
145
|
}
|
|
@@ -167,26 +162,26 @@ class BaseApp {
|
|
|
167
162
|
* ```
|
|
168
163
|
*/
|
|
169
164
|
build(options, mod) {
|
|
170
|
-
if (!
|
|
171
|
-
|
|
165
|
+
if (!this.#server /*&& !this.#isBuilding*/) {
|
|
166
|
+
this.#isBuilding = true;
|
|
172
167
|
this._buildFramework();
|
|
173
168
|
this._buildRoutes();
|
|
174
169
|
this._buildErrorRequestHandlers();
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
this.#isBuilt = true;
|
|
171
|
+
this.#isBuilding = false;
|
|
177
172
|
if (mod) {
|
|
178
173
|
if (options) {
|
|
179
|
-
|
|
174
|
+
this.#server = mod.createServer(options, this.__app);
|
|
180
175
|
}
|
|
181
176
|
else {
|
|
182
|
-
|
|
177
|
+
this.#server = mod.createServer(this.__app);
|
|
183
178
|
}
|
|
184
179
|
}
|
|
185
180
|
else {
|
|
186
|
-
|
|
181
|
+
this.#server = node_http_1.default.createServer(options || {}, this.__app);
|
|
187
182
|
}
|
|
188
183
|
}
|
|
189
|
-
return
|
|
184
|
+
return this.#server;
|
|
190
185
|
}
|
|
191
186
|
listen(a1, a2, a3, a4) {
|
|
192
187
|
const server = this.build();
|
|
@@ -291,8 +286,9 @@ class BaseApp {
|
|
|
291
286
|
this.__app.set(setting, val);
|
|
292
287
|
return this;
|
|
293
288
|
}
|
|
289
|
+
engine(ext,
|
|
294
290
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
295
|
-
|
|
291
|
+
fn) {
|
|
296
292
|
this.__app.engine(ext, fn);
|
|
297
293
|
return this;
|
|
298
294
|
}
|
|
@@ -303,7 +299,7 @@ class BaseApp {
|
|
|
303
299
|
//--- ERROR METHODS
|
|
304
300
|
useError(...handlers) {
|
|
305
301
|
if (!this.built) {
|
|
306
|
-
|
|
302
|
+
this.#errorRequestHandlers.push(...handlers);
|
|
307
303
|
}
|
|
308
304
|
else {
|
|
309
305
|
this._app.use(...handlers);
|
|
@@ -312,5 +308,4 @@ class BaseApp {
|
|
|
312
308
|
}
|
|
313
309
|
}
|
|
314
310
|
exports.BaseApp = BaseApp;
|
|
315
|
-
_BaseApp_config = new WeakMap(), _BaseApp_server = new WeakMap(), _BaseApp_errorRequestHandlers = new WeakMap(), _BaseApp_isBuilding = new WeakMap(), _BaseApp_isBuilt = new WeakMap();
|
|
316
311
|
//# sourceMappingURL=baseApp.js.map
|
package/lib/baseApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseApp.js","sourceRoot":"","sources":["../src/baseApp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseApp.js","sourceRoot":"","sources":["../src/baseApp.ts"],"names":[],"mappings":";;;;AAAA,uEAA+E;AAC/E,8DAA8B;AAE9B,kEAA6B;AAkC7B;;GAEG;AACH;IACE,OAAO,GAAY,EAAE,CAAC;IACtB,OAAO,CAAe;IAEtB,8DAA8D;IAC9D,qBAAqB,GAAyD,EAAE,CAAC;IAEjF,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,GAAG,KAAK,CAAC;IAEP,KAAK,CAAsB;IAC3B,QAAQ,CAAU;IAE5B;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,OAAiB;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAA,iBAAO,GAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAA,iBAAO,GAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAEO,eAAe,CAAC,MAAe;QACrC,IAAI,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,OAAO,MAAM,CAAC,mBAAmB,KAAK,U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IACd,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,EAAE,CAAC,KAAc,EAAE,QAA4C;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,GAAa;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CACJ,GAAW;IACX,8DAA8D;IAC9D,EAAsG;QAEtG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8DAA8D;IAC9D,GAAG,CAAC,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,mBAAmB;IAEnB,QAAQ,CASN,GAAG,QAAiF;QACpF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novice1/app",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.9.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.9.5",
|
|
5
|
+
"description": "Build Express applications on top of @novice1/routing.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"require": "./lib/index.js",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"homepage": "https://kisiwu.github.io/novice-app/latest/",
|
|
8
16
|
"repository": {
|
|
9
17
|
"type": "git",
|
|
@@ -12,40 +20,48 @@
|
|
|
12
20
|
"scripts": {
|
|
13
21
|
"doc": "typedoc",
|
|
14
22
|
"build": "tsc",
|
|
23
|
+
"format": "cross-env NODE_OPTIONS=--experimental-strip-types prettier --write .",
|
|
24
|
+
"format:check": "cross-env NODE_OPTIONS=--experimental-strip-types prettier --check .",
|
|
15
25
|
"lint": "eslint .",
|
|
16
|
-
"test": "kaukau --require ts-node/register --config kaukau-src.config.mjs",
|
|
17
|
-
"
|
|
26
|
+
"test": "cross-env TS_NODE_PROJECT=test/tsconfig.json kaukau --require ts-node/register --config kaukau-src.config.mjs",
|
|
27
|
+
"test:lib": "kaukau --config kaukau-lib.config.mjs"
|
|
18
28
|
},
|
|
19
29
|
"author": "demingongo",
|
|
20
30
|
"license": "MIT",
|
|
21
31
|
"engines": {
|
|
22
32
|
"node": ">=18.0.0"
|
|
23
33
|
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@novice1/logger": "^1.6.1",
|
|
26
|
-
"@novice1/routing": "^2.1.0",
|
|
27
|
-
"express": "^5.2.1",
|
|
28
|
-
"tslib": "^2.8.1"
|
|
29
|
-
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@eslint/eslintrc": "^3.3.
|
|
32
|
-
"@eslint/js": "^
|
|
33
|
-
"@stylistic/eslint-plugin": "^5.
|
|
35
|
+
"@eslint/eslintrc": "^3.3.7",
|
|
36
|
+
"@eslint/js": "^10.0.1",
|
|
37
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
38
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
34
39
|
"@types/chai": "^5.2.3",
|
|
35
|
-
"@types/debug": "^4.1.12",
|
|
36
|
-
"@types/eslint-plugin-mocha": "^10.4.0",
|
|
37
|
-
"@types/express": "^5.0.6",
|
|
38
40
|
"@types/mocha": "^10.0.10",
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
41
|
-
"@typescript-eslint/parser": "^8.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
41
|
+
"@types/node": "^26.6.6",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.72.2",
|
|
43
|
+
"@typescript-eslint/parser": "^8.72.2",
|
|
44
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
45
|
+
"chai": "^6.3.0",
|
|
46
|
+
"cross-env": "^10.1.0",
|
|
47
|
+
"eslint": "^10.14.0",
|
|
48
|
+
"eslint-config-prettier": "^10.1.8",
|
|
49
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
50
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
51
|
+
"eslint-plugin-mocha": "^12.0.2",
|
|
52
|
+
"kaukau": "^6.0.0",
|
|
53
|
+
"prettier": "^3.10.0",
|
|
46
54
|
"ts-node": "^10.9.2",
|
|
47
|
-
"typedoc": "^0.28.
|
|
48
|
-
"typescript": "
|
|
49
|
-
"typescript-eslint": "^8.
|
|
55
|
+
"typedoc": "^0.28.20",
|
|
56
|
+
"typescript": "npm:@typescript/typescript6@^6.0.0",
|
|
57
|
+
"typescript-eslint": "^8.72.2"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@novice1/routing": "^2.1.0",
|
|
61
|
+
"express": "^5.2.1"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@novice1/logger": "^2.0.1",
|
|
65
|
+
"tslib": "^2.9.1"
|
|
50
66
|
}
|
|
51
|
-
}
|
|
67
|
+
}
|