alp-node 6.1.1 → 7.0.0
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 +21 -0
- package/dist/AlpNodeApp-node18.mjs +303 -12
- package/dist/AlpNodeApp-node18.mjs.map +1 -1
- package/dist/definitions/AlpNodeApp.d.ts +15 -7
- package/dist/definitions/AlpNodeApp.d.ts.map +1 -1
- package/dist/definitions/config.d.ts +18 -0
- package/dist/definitions/config.d.ts.map +1 -0
- package/dist/definitions/errors.d.ts +4 -0
- package/dist/definitions/errors.d.ts.map +1 -0
- package/dist/definitions/index.d.ts +5 -3
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/language.d.ts +7 -0
- package/dist/definitions/language.d.ts.map +1 -0
- package/dist/definitions/listen.d.ts +7 -0
- package/dist/definitions/listen.d.ts.map +1 -0
- package/dist/definitions/params/ParamValid.d.ts +9 -0
- package/dist/definitions/params/ParamValid.d.ts.map +1 -0
- package/dist/definitions/params/ParamValidationResult.d.ts +9 -0
- package/dist/definitions/params/ParamValidationResult.d.ts.map +1 -0
- package/dist/definitions/params/ParamValidationResult.test.d.ts +2 -0
- package/dist/definitions/params/ParamValidationResult.test.d.ts.map +1 -0
- package/dist/definitions/params/ParamValueFromContext.d.ts +13 -0
- package/dist/definitions/params/ParamValueFromContext.d.ts.map +1 -0
- package/dist/definitions/params/ParamValueModelValidator.d.ts +4 -0
- package/dist/definitions/params/ParamValueModelValidator.d.ts.map +1 -0
- package/dist/definitions/params/ParamValueStringValidator.d.ts +5 -0
- package/dist/definitions/params/ParamValueStringValidator.d.ts.map +1 -0
- package/dist/definitions/params/ParamValueValidator.d.ts +10 -0
- package/dist/definitions/params/ParamValueValidator.d.ts.map +1 -0
- package/dist/definitions/params/index.d.ts +15 -0
- package/dist/definitions/params/index.d.ts.map +1 -0
- package/dist/definitions/router.d.ts +14 -0
- package/dist/definitions/router.d.ts.map +1 -0
- package/dist/definitions/translate/index.d.ts +11 -0
- package/dist/definitions/translate/index.d.ts.map +1 -0
- package/dist/definitions/translate/load.d.ts +4 -0
- package/dist/definitions/translate/load.d.ts.map +1 -0
- package/dist/definitions/types.d.ts +53 -0
- package/dist/definitions/types.d.ts.map +1 -0
- package/dist/index-node18.mjs +402 -15
- package/dist/index-node18.mjs.map +1 -1
- package/package.json +8 -9
- package/src/AlpNodeApp.ts +42 -21
- package/src/config.ts +121 -0
- package/src/errors.ts +70 -0
- package/src/index.ts +18 -3
- package/src/language.ts +27 -0
- package/src/listen.ts +68 -0
- package/src/params/ParamValid.ts +15 -0
- package/src/params/ParamValidationResult.test.ts +65 -0
- package/src/params/ParamValidationResult.ts +38 -0
- package/src/params/ParamValueFromContext.ts +42 -0
- package/src/params/ParamValueModelValidator.ts +36 -0
- package/src/params/ParamValueStringValidator.ts +13 -0
- package/src/params/ParamValueValidator.ts +23 -0
- package/src/params/index.ts +66 -0
- package/src/router.ts +64 -0
- package/src/translate/index.ts +45 -0
- package/src/translate/load.ts +30 -0
- package/src/types.ts +67 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.0.0](https://github.com/christophehurpeau/alp/compare/alp-node@6.2.0...alp-node@7.0.0) (2024-01-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* merge to alp-node to improve maintenability, remove alp-types
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* merge to alp-node to improve maintenability, remove alp-types ([ead9a2f](https://github.com/christophehurpeau/alp/commit/ead9a2fd1bcbedce0be29ea0e444c5cead99c64d))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [6.2.0](https://github.com/christophehurpeau/alp/compare/alp-node@6.1.1...alp-node@6.2.0) (2024-01-06)
|
|
21
|
+
|
|
22
|
+
Note: no notable changes
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## [6.1.1](https://github.com/christophehurpeau/alp/compare/alp-node@6.1.0...alp-node@6.1.1) (2024-01-06)
|
|
7
28
|
|
|
8
29
|
Note: no notable changes
|
|
@@ -1,15 +1,306 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { deprecate } from 'node:util';
|
|
3
|
-
import _listen from 'alp-listen';
|
|
4
|
-
import _config from 'alp-node-config';
|
|
5
|
-
import errors from 'alp-node-errors';
|
|
6
|
-
import language from 'alp-node-language';
|
|
7
|
-
import params from 'alp-params';
|
|
8
|
-
import translate from 'alp-translate';
|
|
9
3
|
import Koa from 'koa';
|
|
10
4
|
import compress from 'koa-compress';
|
|
11
5
|
import serve from 'koa-static';
|
|
12
6
|
import { Logger } from 'nightingale-logger';
|
|
7
|
+
import { unlinkSync, chmodSync, readFileSync } from 'node:fs';
|
|
8
|
+
import 'deep-freeze-es6';
|
|
9
|
+
import minimist from 'minimist';
|
|
10
|
+
import 'parse-json-object-as-map';
|
|
11
|
+
import { STATUS_CODES, createServer as createServer$2 } from 'node:http';
|
|
12
|
+
import ErrorHtmlRenderer from 'error-html';
|
|
13
|
+
import { defineLazyProperty } from 'object-properties';
|
|
14
|
+
import { createServer as createServer$1 } from 'node:https';
|
|
15
|
+
import IntlMessageFormatDefault from 'intl-messageformat';
|
|
16
|
+
|
|
17
|
+
minimist(process.argv.slice(2));
|
|
18
|
+
function getConfig(app, config) {
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* eslint-disable complexity */
|
|
23
|
+
const logger$3 = new Logger('alp:errors');
|
|
24
|
+
const errorHtmlRenderer = new ErrorHtmlRenderer({
|
|
25
|
+
appPath: `${process.cwd()}/`
|
|
26
|
+
});
|
|
27
|
+
async function alpNodeErrors(ctx, next) {
|
|
28
|
+
try {
|
|
29
|
+
await next();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
// eslint-disable-next-line no-ex-assign
|
|
32
|
+
if (!error) error = new Error('Unknown error');
|
|
33
|
+
// eslint-disable-next-line no-ex-assign
|
|
34
|
+
if (typeof error === 'string') error = new Error(error);
|
|
35
|
+
ctx.status = error.status || 500;
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
37
|
+
logger$3.error(error);
|
|
38
|
+
switch (ctx.request.accepts('html', 'text', 'json')) {
|
|
39
|
+
case 'json':
|
|
40
|
+
ctx.type = 'application/json';
|
|
41
|
+
if (process.env.NODE_ENV !== 'production' || error.expose) {
|
|
42
|
+
ctx.body = {
|
|
43
|
+
error: error.message
|
|
44
|
+
};
|
|
45
|
+
} else {
|
|
46
|
+
ctx.body = {
|
|
47
|
+
error: STATUS_CODES[ctx.status]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'html':
|
|
52
|
+
ctx.type = 'text/html';
|
|
53
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
54
|
+
ctx.body = errorHtmlRenderer.render(error);
|
|
55
|
+
} else if (error.expose) {
|
|
56
|
+
ctx.body = error.message;
|
|
57
|
+
} else {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'text':
|
|
62
|
+
default:
|
|
63
|
+
ctx.type = 'text/plain';
|
|
64
|
+
if (process.env.NODE_ENV !== 'production' || error.expose) {
|
|
65
|
+
ctx.body = error.message;
|
|
66
|
+
} else {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function alpLanguage(app) {
|
|
75
|
+
const config = app.context.config;
|
|
76
|
+
const availableLanguages = config.get('availableLanguages');
|
|
77
|
+
if (!availableLanguages) {
|
|
78
|
+
throw new Error('Missing config "availableLanguages"');
|
|
79
|
+
}
|
|
80
|
+
defineLazyProperty(app.context, 'language', function () {
|
|
81
|
+
return this.acceptsLanguages(availableLanguages) || availableLanguages[0];
|
|
82
|
+
});
|
|
83
|
+
defineLazyProperty(app.context, 'firstAcceptedLanguage', function () {
|
|
84
|
+
return this.acceptsLanguages()[0] || availableLanguages[0];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const logger$2 = new Logger('alp:listen');
|
|
89
|
+
const createServer = (callback, socketPath, tls, dirname = ''
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
91
|
+
) => {
|
|
92
|
+
const createHttpServer = !socketPath && tls ? createServer$1 : createServer$2;
|
|
93
|
+
if (!tls) {
|
|
94
|
+
return createHttpServer(callback);
|
|
95
|
+
}
|
|
96
|
+
const options = {
|
|
97
|
+
key: readFileSync(`${dirname}/server.key`),
|
|
98
|
+
cert: readFileSync(`${dirname}/server.crt`)
|
|
99
|
+
};
|
|
100
|
+
return createHttpServer(options, callback);
|
|
101
|
+
};
|
|
102
|
+
function alpListen(config, callback, dirname) {
|
|
103
|
+
return new Promise(resolve => {
|
|
104
|
+
const socketPath = config.get('socketPath');
|
|
105
|
+
const port = config.get('port');
|
|
106
|
+
const hostname = config.get('hostname');
|
|
107
|
+
const tls = config.get('tls');
|
|
108
|
+
logger$2.info('Creating server', socketPath ? {
|
|
109
|
+
socketPath
|
|
110
|
+
} : {
|
|
111
|
+
port
|
|
112
|
+
});
|
|
113
|
+
const server = createServer(callback, socketPath, tls, dirname);
|
|
114
|
+
if (socketPath) {
|
|
115
|
+
try {
|
|
116
|
+
unlinkSync(socketPath);
|
|
117
|
+
} catch {}
|
|
118
|
+
server.listen(socketPath, () => {
|
|
119
|
+
if (socketPath) {
|
|
120
|
+
chmodSync(socketPath, '777');
|
|
121
|
+
}
|
|
122
|
+
logger$2.info('Server listening', {
|
|
123
|
+
socketPath
|
|
124
|
+
});
|
|
125
|
+
resolve(server);
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
server.listen(port, hostname, () => {
|
|
129
|
+
logger$2.info('Server listening', {
|
|
130
|
+
port
|
|
131
|
+
});
|
|
132
|
+
resolve(server);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
class ParamValidationResult {
|
|
139
|
+
_error(name, key, value) {
|
|
140
|
+
if (!this._errors) {
|
|
141
|
+
this._errors = {};
|
|
142
|
+
}
|
|
143
|
+
this._errors[name] = {
|
|
144
|
+
error: key,
|
|
145
|
+
value
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
getErrors() {
|
|
149
|
+
return this._errors;
|
|
150
|
+
}
|
|
151
|
+
hasErrors() {
|
|
152
|
+
return this._errors !== undefined;
|
|
153
|
+
}
|
|
154
|
+
isValid() {
|
|
155
|
+
return this._errors === undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// string(name: string): ParamValueStringValidator {
|
|
159
|
+
// return new ParamValueStringValidator(this, name, this.context.param(name));
|
|
160
|
+
// }
|
|
161
|
+
/* int(name, position) {
|
|
162
|
+
return new ParamValueIntValidator(this, name, this.context.param(name, position));
|
|
163
|
+
}
|
|
164
|
+
model(modelName, name) {
|
|
165
|
+
name = name || S.string.lcFirst(modelName);
|
|
166
|
+
console.log('paramvalidator model', modelName, M[modelName]);
|
|
167
|
+
let data = this.context.getOrPostParam(name);
|
|
168
|
+
return new ParamValueModelValidator(this, name, !data ? null : new M[modelName](data));
|
|
169
|
+
} */
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
class ParamValid extends ParamValidationResult {
|
|
173
|
+
constructor(context) {
|
|
174
|
+
super();
|
|
175
|
+
this.context = context;
|
|
176
|
+
}
|
|
177
|
+
_error() {
|
|
178
|
+
this.context.throw(400, 'Invalid params', {
|
|
179
|
+
validator: this
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
class ParamValueValidator {
|
|
185
|
+
constructor(validationResult, name, value) {
|
|
186
|
+
this.validationResult = validationResult;
|
|
187
|
+
this.name = name;
|
|
188
|
+
this.value = value;
|
|
189
|
+
}
|
|
190
|
+
isValid() {
|
|
191
|
+
return this.validationResult.isValid();
|
|
192
|
+
}
|
|
193
|
+
_error(key) {
|
|
194
|
+
this.validationResult._error(this.name, key, this.value);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class ParamValueStringValidator extends ParamValueValidator {
|
|
199
|
+
notEmpty() {
|
|
200
|
+
if (this.value == null || this.value.trim() === '') {
|
|
201
|
+
this._error('notEmpty');
|
|
202
|
+
}
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
class ParamValueFromContext {
|
|
208
|
+
constructor(context, validationResult) {
|
|
209
|
+
this.validationResult = validationResult;
|
|
210
|
+
this.context = context;
|
|
211
|
+
}
|
|
212
|
+
namedParam(name) {
|
|
213
|
+
return new ParamValueStringValidator(this.validationResult, name, this.context.namedParam(name));
|
|
214
|
+
}
|
|
215
|
+
otherParam(position) {
|
|
216
|
+
return new ParamValueStringValidator(this.validationResult, String(position), this.context.otherParam(position));
|
|
217
|
+
}
|
|
218
|
+
queryParam(name) {
|
|
219
|
+
return new ParamValueStringValidator(this.validationResult, name, this.context.queryParam(name));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// bodyParam: <T>(name: string): ParamValueValidator<string | undefined> {
|
|
223
|
+
|
|
224
|
+
// }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function alpParams(app) {
|
|
228
|
+
Object.assign(app.context, {
|
|
229
|
+
namedRouteParam(name) {
|
|
230
|
+
const namedParams = this.route.namedParams;
|
|
231
|
+
return namedParams?.get(name);
|
|
232
|
+
},
|
|
233
|
+
otherRouteParam(position) {
|
|
234
|
+
const otherParams = this.route.otherParams;
|
|
235
|
+
return otherParams?.[position - 1];
|
|
236
|
+
},
|
|
237
|
+
queryParam(name) {
|
|
238
|
+
const searchParams = this.request.searchParams;
|
|
239
|
+
return searchParams.get(name) ?? undefined;
|
|
240
|
+
},
|
|
241
|
+
bodyParam(name) {
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
243
|
+
return this.body[name];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
defineLazyProperty(app.request, 'searchParams', function () {
|
|
247
|
+
return new URLSearchParams(this.search);
|
|
248
|
+
});
|
|
249
|
+
defineLazyProperty(app.context, 'params', function () {
|
|
250
|
+
return new ParamValueFromContext(this, new ParamValidationResult());
|
|
251
|
+
});
|
|
252
|
+
defineLazyProperty(app.context, 'validParams', function () {
|
|
253
|
+
return new ParamValueFromContext(this, new ParamValid(this));
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
258
|
+
const IntlMessageFormat =
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
260
|
+
IntlMessageFormatDefault.default || IntlMessageFormatDefault;
|
|
261
|
+
function load(translations, language) {
|
|
262
|
+
const result = new Map();
|
|
263
|
+
(function loadMap(map, prefix) {
|
|
264
|
+
map.forEach((value, key) => {
|
|
265
|
+
if (typeof value === 'object') {
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
267
|
+
loadMap(value, `${prefix}${key}.`);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
272
|
+
result.set(`${prefix}${key}`, new IntlMessageFormat(value, language));
|
|
273
|
+
});
|
|
274
|
+
})(translations, '');
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const logger$1 = new Logger('alp:translate');
|
|
279
|
+
function alpTranslate(dirname) {
|
|
280
|
+
dirname = dirname.replace(/\/*$/, '/');
|
|
281
|
+
return app => {
|
|
282
|
+
const appTranslations = new Map();
|
|
283
|
+
Object.assign(app.context, {
|
|
284
|
+
t(id, args) {
|
|
285
|
+
const msg = appTranslations.get(this.language).get(id);
|
|
286
|
+
if (!msg) {
|
|
287
|
+
logger$1.warn('invalid msg', {
|
|
288
|
+
language: this.language,
|
|
289
|
+
id
|
|
290
|
+
});
|
|
291
|
+
return id;
|
|
292
|
+
}
|
|
293
|
+
return msg.format(args);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
const config = app.config;
|
|
297
|
+
config.get('availableLanguages').forEach(language => {
|
|
298
|
+
const translations = app.loadConfigSync(dirname + language);
|
|
299
|
+
appTranslations.set(language, load(translations, language));
|
|
300
|
+
});
|
|
301
|
+
return appTranslations;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
13
304
|
|
|
14
305
|
const logger = new Logger('alp');
|
|
15
306
|
class AlpNodeApp extends Koa {
|
|
@@ -34,11 +325,11 @@ class AlpNodeApp extends Koa {
|
|
|
34
325
|
});
|
|
35
326
|
this.certPath = certPath || `${packageDirname}/config/cert`;
|
|
36
327
|
this.publicPath = publicPath || `${packageDirname}/public/`;
|
|
37
|
-
this.config =
|
|
328
|
+
this.config = getConfig(this, config);
|
|
38
329
|
this.context.config = this.config;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
330
|
+
alpParams(this);
|
|
331
|
+
alpLanguage(this);
|
|
332
|
+
alpTranslate('locales')(this);
|
|
42
333
|
this.use(compress());
|
|
43
334
|
}
|
|
44
335
|
existsConfigSync(name) {
|
|
@@ -56,7 +347,7 @@ class AlpNodeApp extends Koa {
|
|
|
56
347
|
this.use(serve(this.publicPath)); // static files
|
|
57
348
|
}
|
|
58
349
|
catchErrors() {
|
|
59
|
-
this.use(
|
|
350
|
+
this.use(alpNodeErrors);
|
|
60
351
|
}
|
|
61
352
|
|
|
62
353
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
@@ -76,7 +367,7 @@ class AlpNodeApp extends Koa {
|
|
|
76
367
|
async start(fn) {
|
|
77
368
|
await fn();
|
|
78
369
|
try {
|
|
79
|
-
const server = await
|
|
370
|
+
const server = await alpListen(this.config, this.callback(), this.certPath);
|
|
80
371
|
this._server = server;
|
|
81
372
|
logger.success('started');
|
|
82
373
|
if (process.send) process.send('ready');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlpNodeApp-node18.mjs","sources":["../src/AlpNodeApp.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'node:http';\nimport path from 'node:path';\nimport { deprecate } from 'node:util';\nimport _listen from 'alp-listen';\nimport type { Config } from 'alp-node-config';\nimport _config from 'alp-node-config';\nimport errors from 'alp-node-errors';\nimport language from 'alp-node-language';\nimport params from 'alp-params';\nimport translate from 'alp-translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n ContextRequest,\n} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface DefaultContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface BaseRequest extends ContextRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: Config & NodeConfig;\n\n declare request: BaseRequest & ContextRequest;\n\n _server?: Server;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n override createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n override listen(): never {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (error: unknown) {\n logger.error('start fail', { err: error });\n throw error;\n }\n }\n}\n\nexport type { Context } from 'koa';\n"],"names":["logger","Logger","AlpNodeApp","Koa","constructor","appDirname","packageDirname","config","certPath","publicPath","dirname","path","normalize","Object","defineProperty","get","deprecate","configurable","enumerable","_config","context","params","language","translate","use","compress","existsConfigSync","name","loadConfigSync","createContext","req","res","ctx","sanitizedState","servePublic","serve","catchErrors","errors","listen","Error","close","_server","emit","start","fn","server","_listen","callback","success","process","send","error","err"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMA,MAAM,GAAG,IAAIC,MAAM,CAAC,KAAK,CAAC,CAAA;AAqBzB,MAAMC,UAAU,SAASC,GAAG,CAA0C;AAa3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAWA,CAAC;IACVC,UAAU;IACVC,cAAc;IACdC,MAAM;IACNC,QAAQ;AACRC,IAAAA,UAAAA;AACiB,GAAC,EAAE;AACpB,IAAA,KAAK,EAAE,CAAA;IAEP,IAAI,CAACC,OAAO,GAAGC,IAAI,CAACC,SAAS,CAACP,UAAU,CAAC,CAAA;AAEzCQ,IAAAA,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE;AAC5CC,MAAAA,GAAG,EAAEC,SAAS,CAAC,MAAMV,cAAc,EAAE,gBAAgB,CAAC;AACtDW,MAAAA,YAAY,EAAE,KAAK;AACnBC,MAAAA,UAAU,EAAE,KAAA;AACd,KAAC,CAAC,CAAA;AAEF,IAAA,IAAI,CAACV,QAAQ,GAAGA,QAAQ,IAAK,CAAA,EAAEF,cAAe,CAAa,YAAA,CAAA,CAAA;AAC3D,IAAA,IAAI,CAACG,UAAU,GAAGA,UAAU,IAAK,CAAA,EAAEH,cAAe,CAAS,QAAA,CAAA,CAAA;IAE3D,IAAI,CAACC,MAAM,GAAGY,OAAO,CAAC,IAAI,EAAEZ,MAAM,CAAC,CAAA;AACnC,IAAA,IAAI,CAACa,OAAO,CAACb,MAAM,GAAG,IAAI,CAACA,MAAM,CAAA;IAEjCc,MAAM,CAAC,IAAI,CAAC,CAAA;IACZC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACdC,IAAAA,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAA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AAM,EAAE,IAAI,CAACwC,QAAQ,EAAE,EAAE,IAAI,CAACvC,QAAQ,CAAC,CAAA;MACzE,IAAI,CAACiC,OAAO,GAAGI,MAAM,CAAA;AACrB7C,MAAAA,MAAM,CAACgD,OAAO,CAAC,SAAS,CAAC,CAAA;MACzB,IAAIC,OAAO,CAACC,IAAI,EAAED,OAAO,CAACC,IAAI,CAAC,OAAO,CAAC,CAAA;AACvC,MAAA,OAAOL,MAAM,CAAA;KACd,CAAC,OAAOM,KAAc,EAAE;AACvBnD,MAAAA,MAAM,CAACmD,KAAK,CAAC,YAAY,EAAE;AAAEC,QAAAA,GAAG,EAAED,KAAAA;AAAM,OAAC,CAAC,CAAA;AAC1C,MAAA,MAAMA,KAAK,CAAA;AACb,KAAA;AACF,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"AlpNodeApp-node18.mjs","sources":["../src/config.ts","../src/errors.ts","../src/language.ts","../src/listen.ts","../src/params/ParamValidationResult.ts","../src/params/ParamValid.ts","../src/params/ParamValueValidator.ts","../src/params/ParamValueStringValidator.ts","../src/params/ParamValueFromContext.ts","../src/params/index.ts","../src/translate/load.ts","../src/translate/index.ts","../src/AlpNodeApp.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport deepFreeze from 'deep-freeze-es6';\nimport minimist from 'minimist';\nimport parseJSON from 'parse-json-object-as-map';\nimport type { NodeApplication, NodeConfig, PackageConfig } from './types';\n\nconst argv = minimist(process.argv.slice(2));\n\nfunction _existsConfigSync(dirname: string, name: string): boolean {\n return existsSync(`${dirname}${name}.json`);\n}\n\nfunction _loadConfigSync(dirname: string, name: string): Map<string, unknown> {\n const content = readFileSync(`${dirname}${name}.json`, 'utf8');\n return parseJSON(content) as Map<string, unknown>;\n}\n\nexport interface ConfigOptions {\n argv?: string[];\n packageConfig?: PackageConfig;\n version?: string;\n}\n\nexport class Config {\n packageConfig?: PackageConfig;\n\n private _map: Map<string, unknown>;\n\n private readonly _dirname: string;\n\n constructor(dirname: string, options?: ConfigOptions) {\n this._map = new Map<string, unknown>();\n this._dirname = dirname.replace(/\\/*$/, '/');\n if (options) {\n this.loadSync(options);\n }\n }\n\n loadSync(options: ConfigOptions = {}): Config & NodeConfig {\n const env = process.env.CONFIG_ENV || process.env.NODE_ENV || 'development';\n const { argv: argvOverrides = [], packageConfig, version } = options;\n this.packageConfig = packageConfig;\n\n const config = this.loadConfigSync('common') as Map<string, unknown>;\n for (const [key, value] of this.loadConfigSync(env)) {\n config.set(key, value);\n }\n\n if (this.existsConfigSync('local')) {\n for (const [key, value] of this.loadConfigSync('local')) {\n config.set(key, value);\n }\n }\n\n if (config.has('version')) {\n throw new Error('Cannot have \"version\", in config.');\n }\n\n config.set(\n 'version',\n String(version || argv.version || packageConfig?.version),\n );\n\n const socketPath: string | undefined = (argv.socket ||\n argv['socket-path'] ||\n argv.socketPath) as string | undefined;\n if (socketPath) {\n config.set('socketPath', socketPath);\n } else if (argv.port) {\n config.set('port', argv.port);\n config.delete('socketPath');\n } else if (process.env.PORT) {\n config.set('port', Number(process.env.PORT));\n config.delete('socketPath');\n }\n\n argvOverrides.forEach((key) => {\n const splitted = key.split('.');\n const value =\n splitted.length > 0 &&\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return,unicorn/no-array-reduce, @typescript-eslint/no-shadow\n splitted.reduce((config, partialKey) => config?.[partialKey], argv);\n if (value !== undefined) {\n const last = splitted.pop()!;\n const map =\n splitted.length === 0\n ? config\n : // eslint-disable-next-line unicorn/no-array-reduce\n splitted.reduce(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (config, partialKey) =>\n config.get(partialKey) as Map<string, unknown>,\n config,\n );\n map.set(last, value);\n }\n });\n\n this._map = deepFreeze(config);\n return this as Config & NodeConfig;\n }\n\n get<T>(key: string): T {\n return this._map.get(key) as T;\n }\n\n existsConfigSync(name: string): boolean {\n return _existsConfigSync(this._dirname, name);\n }\n\n loadConfigSync(name: string): ReadonlyMap<string, unknown> {\n return _loadConfigSync(this._dirname, name);\n }\n}\n\nexport default function getConfig(\n app: NodeApplication,\n config: Config & NodeConfig,\n): Config & NodeConfig {\n return config;\n}\n","/* eslint-disable complexity */\nimport { STATUS_CODES } from 'node:http';\nimport ErrorHtmlRenderer from 'error-html';\nimport { Logger } from 'nightingale-logger';\nimport type { Context } from './AlpNodeApp';\nimport type { HtmlError } from './types';\n\nconst logger = new Logger('alp:errors');\nconst errorHtmlRenderer = new ErrorHtmlRenderer({\n appPath: `${process.cwd()}/`,\n});\n\nexport default async function alpNodeErrors(\n ctx: Context,\n next: () => Promise<void> | void,\n): Promise<void> {\n try {\n await next();\n } catch (error: unknown) {\n // eslint-disable-next-line no-ex-assign\n if (!error) error = new Error('Unknown error');\n // eslint-disable-next-line no-ex-assign\n if (typeof error === 'string') error = new Error(error);\n\n ctx.status = (error as HtmlError).status || 500;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n logger.error(error as any);\n\n switch (ctx.request.accepts('html', 'text', 'json')) {\n case 'json':\n ctx.type = 'application/json';\n if (\n process.env.NODE_ENV !== 'production' ||\n (error as HtmlError).expose\n ) {\n ctx.body = { error: (error as Error).message };\n } else {\n ctx.body = { error: STATUS_CODES[ctx.status] };\n }\n\n break;\n\n case 'html':\n ctx.type = 'text/html';\n if (process.env.NODE_ENV !== 'production') {\n ctx.body = errorHtmlRenderer.render(error as Error);\n } else if ((error as HtmlError).expose) {\n ctx.body = (error as Error).message;\n } else {\n throw error;\n }\n\n break;\n\n case 'text':\n default:\n ctx.type = 'text/plain';\n if (\n process.env.NODE_ENV !== 'production' ||\n (error as HtmlError).expose\n ) {\n ctx.body = (error as Error).message;\n } else {\n throw error;\n }\n\n break;\n }\n }\n}\n","import type { Context } from 'koa';\nimport { defineLazyProperty } from 'object-properties';\nimport type { AlpNodeApp } from './AlpNodeApp';\n\nexport interface AlpLanguageContext {\n readonly firstAcceptedLanguage: string;\n readonly language: string;\n}\nexport default function alpLanguage(app: AlpNodeApp): void {\n const config = app.context.config;\n const availableLanguages: string[] = config.get('availableLanguages');\n if (!availableLanguages) {\n throw new Error('Missing config \"availableLanguages\"');\n }\n\n defineLazyProperty(app.context, 'language', function (this: Context): string {\n return this.acceptsLanguages(availableLanguages) || availableLanguages[0];\n });\n\n defineLazyProperty(\n app.context,\n 'firstAcceptedLanguage',\n function (this: Context): string {\n return this.acceptsLanguages()[0] || availableLanguages[0];\n },\n );\n}\n","import { chmodSync, unlinkSync, readFileSync } from 'node:fs';\nimport { createServer as createServerHttp } from 'node:http';\nimport type { Server, IncomingMessage, ServerResponse } from 'node:http';\nimport { createServer as createServerHttps } from 'node:https';\nimport { Logger } from 'nightingale-logger';\nimport type { Config } from './config';\n\nconst logger = new Logger('alp:listen');\n\ntype RequestListener = (req: IncomingMessage, res: ServerResponse) => void;\n\nconst createServer = (\n callback: RequestListener,\n socketPath?: string,\n tls?: boolean,\n dirname = '',\n // eslint-disable-next-line @typescript-eslint/max-params\n): Server => {\n const createHttpServer =\n !socketPath && tls ? createServerHttps : createServerHttp;\n\n if (!tls) {\n return (createHttpServer as typeof createServerHttps)(callback);\n }\n\n const options = {\n key: readFileSync(`${dirname}/server.key`),\n cert: readFileSync(`${dirname}/server.crt`),\n };\n\n return (createHttpServer as typeof createServerHttps)(options, callback);\n};\n\nexport default function alpListen(\n config: Config,\n callback: RequestListener,\n dirname?: string,\n): Promise<Server> {\n return new Promise((resolve) => {\n const socketPath = config.get<string>('socketPath');\n const port = config.get<number>('port');\n const hostname = config.get<string>('hostname');\n const tls = config.get<boolean>('tls');\n\n logger.info('Creating server', socketPath ? { socketPath } : { port });\n const server = createServer(callback, socketPath, tls, dirname);\n\n if (socketPath) {\n try {\n unlinkSync(socketPath);\n } catch {}\n\n server.listen(socketPath, () => {\n if (socketPath) {\n chmodSync(socketPath, '777');\n }\n\n logger.info('Server listening', { socketPath });\n resolve(server);\n });\n } else {\n server.listen(port, hostname, () => {\n logger.info('Server listening', { port });\n resolve(server);\n });\n }\n });\n}\n","export type Errors = Record<string, any>;\n\nexport class ParamValidationResult {\n _errors?: Errors;\n\n _error(name: string, key: string, value: unknown): void {\n if (!this._errors) {\n this._errors = {};\n }\n\n this._errors[name] = { error: key, value };\n }\n\n getErrors(): Errors | undefined {\n return this._errors;\n }\n\n hasErrors(): boolean {\n return this._errors !== undefined;\n }\n\n isValid(): boolean {\n return this._errors === undefined;\n }\n\n // string(name: string): ParamValueStringValidator {\n // return new ParamValueStringValidator(this, name, this.context.param(name));\n // }\n /* int(name, position) {\n return new ParamValueIntValidator(this, name, this.context.param(name, position));\n }\n model(modelName, name) {\n name = name || S.string.lcFirst(modelName);\n console.log('paramvalidator model', modelName, M[modelName]);\n let data = this.context.getOrPostParam(name);\n return new ParamValueModelValidator(this, name, !data ? null : new M[modelName](data));\n } */\n}\n","import type { Context } from '../AlpNodeApp';\nimport { ParamValidationResult } from './ParamValidationResult';\n\nexport default class ParamValid extends ParamValidationResult {\n context: Context;\n\n constructor(context: Context) {\n super();\n this.context = context;\n }\n\n override _error(): void {\n this.context.throw(400, 'Invalid params', { validator: this });\n }\n}\n","import type { ParamValidationResult } from './ParamValidationResult';\n\nexport default class ParamValueValidator<T> {\n readonly validationResult: ParamValidationResult;\n\n readonly name: string;\n\n readonly value: T;\n\n constructor(validationResult: ParamValidationResult, name: string, value: T) {\n this.validationResult = validationResult;\n this.name = name;\n this.value = value;\n }\n\n isValid(): boolean {\n return this.validationResult.isValid();\n }\n\n _error(key: string): void {\n this.validationResult._error(this.name, key, this.value);\n }\n}\n","import ParamValueValidator from './ParamValueValidator';\n\nexport default class ParamValueStringValidator<\n T extends string = string,\n> extends ParamValueValidator<T | null | undefined> {\n notEmpty(): ParamValueValidator<T> {\n if (this.value == null || this.value.trim() === '') {\n this._error('notEmpty');\n }\n\n return this as ParamValueValidator<T>;\n }\n}\n","import type { Context } from '../AlpNodeApp';\nimport type { ParamValidationResult } from './ParamValidationResult';\nimport ParamValueStringValidator from './ParamValueStringValidator';\n\nexport class ParamValueFromContext {\n readonly validationResult: ParamValidationResult;\n\n readonly context: Context;\n\n constructor(context: Context, validationResult: ParamValidationResult) {\n this.validationResult = validationResult;\n this.context = context;\n }\n\n namedParam(name: string): ParamValueStringValidator {\n return new ParamValueStringValidator(\n this.validationResult,\n name,\n this.context.namedParam(name),\n );\n }\n\n otherParam(position: number): ParamValueStringValidator {\n return new ParamValueStringValidator(\n this.validationResult,\n String(position),\n this.context.otherParam(position),\n );\n }\n\n queryParam(name: string): ParamValueStringValidator {\n return new ParamValueStringValidator(\n this.validationResult,\n name,\n this.context.queryParam(name),\n );\n }\n\n // bodyParam: <T>(name: string): ParamValueValidator<string | undefined> {\n\n // }\n}\n","import { defineLazyProperty } from 'object-properties';\nimport type { AlpNodeApp, Context } from '../AlpNodeApp';\nimport ParamValid from './ParamValid';\nimport { ParamValidationResult } from './ParamValidationResult';\nimport { ParamValueFromContext } from './ParamValueFromContext';\n\nexport interface AlpParamsContext {\n params: ParamValueFromContext;\n validParams: ParamValueFromContext;\n namedParam: (name: string) => string | undefined;\n otherParam: (position: number) => string | undefined;\n queryParam: (name: string) => string | undefined;\n bodyParam: <T>(name: string) => T | undefined;\n}\n\nexport interface AlpParamsRequest {\n searchParams: URLSearchParams;\n}\n\nexport default function alpParams(app: AlpNodeApp): void {\n Object.assign(app.context, {\n namedRouteParam(this: Context, name: string): string | undefined {\n const namedParams = this.route.namedParams;\n return namedParams?.get(name);\n },\n\n otherRouteParam(this: Context, position: number): string | undefined {\n const otherParams = this.route.otherParams;\n return otherParams?.[position - 1];\n },\n\n queryParam(this: Context, name: string): string | undefined {\n const searchParams = this.request.searchParams;\n return searchParams.get(name) ?? undefined;\n },\n\n bodyParam<T>(this: Context, name: string): T | undefined {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (this.body as any)[name];\n },\n });\n\n defineLazyProperty(\n app.request,\n 'searchParams',\n function (this: Context['request']): URLSearchParams {\n return new URLSearchParams(this.search);\n },\n );\n\n defineLazyProperty(\n app.context,\n 'params',\n function (this: Context): ParamValueFromContext {\n return new ParamValueFromContext(this, new ParamValidationResult());\n },\n );\n\n defineLazyProperty(\n app.context,\n 'validParams',\n function (this: Context): ParamValueFromContext {\n return new ParamValueFromContext(this, new ParamValid(this));\n },\n );\n}\n","import IntlMessageFormatDefault from 'intl-messageformat';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst IntlMessageFormat: typeof IntlMessageFormatDefault =\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n (IntlMessageFormatDefault as any).default || IntlMessageFormatDefault;\n\nexport type Translations = ReadonlyMap<string, IntlMessageFormatDefault>;\n\nexport default function load(\n translations: ReadonlyMap<string, unknown>,\n language: string,\n): Translations {\n const result = new Map();\n\n (function loadMap(map, prefix) {\n map.forEach((value: any, key) => {\n if (typeof value === 'object') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n loadMap(value, `${prefix}${key}.`);\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n result.set(`${prefix}${key}`, new IntlMessageFormat(value, language));\n });\n })(translations, '');\n\n return result;\n}\n","import { Logger } from 'nightingale-logger';\nimport type { AlpNodeApp, Context } from '../AlpNodeApp';\nimport type { Translations } from './load';\nimport load from './load';\n\nconst logger = new Logger('alp:translate');\n\ntype Args = Record<string, any>;\n\nexport interface TranslateBaseContext {\n t: (id: string, args: Args) => string;\n}\nexport interface TranslateContext {\n readonly language: string;\n}\n\nexport default function alpTranslate(\n dirname: string,\n): (app: AlpNodeApp) => void {\n dirname = dirname.replace(/\\/*$/, '/');\n return (app: AlpNodeApp) => {\n const appTranslations = new Map<string, Translations>();\n\n Object.assign(app.context, {\n t(this: Context, id: string, args: Args): string {\n const msg = appTranslations.get(this.language)!.get(id);\n if (!msg) {\n logger.warn('invalid msg', { language: this.language, id });\n return id;\n }\n\n return msg.format(args) as string;\n },\n });\n\n const config = app.config;\n\n config.get<string[]>('availableLanguages').forEach((language) => {\n const translations = app.loadConfigSync(dirname + language);\n appTranslations.set(language, load(translations, language));\n });\n\n return appTranslations;\n };\n}\n","import type { IncomingMessage, Server, ServerResponse } from 'node:http';\nimport path from 'node:path';\nimport { deprecate } from 'node:util';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\nimport type { Router } from 'router-segments';\nimport type { Config } from './config';\nimport _config from './config';\nimport errors from './errors';\nimport type { AlpLanguageContext } from './language';\nimport language from './language';\nimport _listen from './listen';\nimport type { AlpParamsContext, AlpParamsRequest } from './params';\nimport params from './params';\nimport type {\n AlpRouteRef,\n RouterContext as AlpRouterContext,\n UrlGenerator,\n} from './router';\nimport type { TranslateBaseContext, TranslateContext } from './translate';\nimport translate from './translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n} from './types';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n\n interface DefaultContext\n extends AlpContext,\n AlpParamsContext,\n AlpRouterContext,\n AlpLanguageContext,\n TranslateContext {}\n\n interface BaseContext extends AlpContext, TranslateBaseContext {\n urlGenerator: UrlGenerator;\n redirectTo: <P extends Record<string, unknown>>(\n to: string,\n params?: P,\n ) => void;\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseRequest extends AlpParamsRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: Config & NodeConfig;\n\n _server?: Server;\n\n router?: Router<any, AlpRouteRef>;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n override createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n override listen(): never {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (error: unknown) {\n logger.error('start fail', { err: error });\n throw error;\n }\n }\n}\n\nexport type { Context } from 'koa';\n\nexport { type NodeApplication } from './types';\n"],"names":["minimist","process","argv","slice","getConfig","app","config","logger","Logger","errorHtmlRenderer","ErrorHtmlRenderer","appPath","cwd","alpNodeErrors","ctx","next","error","Error","status","request","accepts","type","env","NODE_ENV","expose","body","message","STATUS_CODES","render","alpLanguage","context","availableLanguages","get","defineLazyProperty","acceptsLanguages","createServer","callback","socketPath","tls","dirname","createHttpServer","createServerHttps","createServerHttp","options","key","readFileSync","cert","alpListen","Promise","resolve","port","hostname","info","server","unlinkSync","listen","chmodSync","ParamValidationResult","_error","name","value","_errors","getErrors","hasErrors","undefined","isValid","ParamValid","constructor","throw","validator","ParamValueValidator","validationResult","ParamValueStringValidator","notEmpty","trim","ParamValueFromContext","namedParam","otherParam","position","String","queryParam","alpParams","Object","assign","namedRouteParam","namedParams","route","otherRouteParam","otherParams","searchParams","bodyParam","URLSearchParams","search","IntlMessageFormat","IntlMessageFormatDefault","default","load","translations","language","result","Map","loadMap","map","prefix","forEach","set","alpTranslate","replace","appTranslations","t","id","args","msg","warn","format","loadConfigSync","AlpNodeApp","Koa","appDirname","packageDirname","certPath","publicPath","path","normalize","defineProperty","deprecate","configurable","enumerable","_config","params","translate","use","compress","existsConfigSync","createContext","req","res","sanitizedState","servePublic","serve","catchErrors","errors","close","_server","emit","start","fn","_listen","success","send","err"],"mappings":";;;;;;;;;;;;;;;;AAMaA,QAAQ,CAACC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,EAAC;AA6G7B,SAASC,SAASA,CAC/BC,GAAoB,EACpBC,MAA2B,EACN;AACrB,EAAA,OAAOA,MAAM,CAAA;AACf;;ACxHA;AAOA,MAAMC,QAAM,GAAG,IAAIC,MAAM,CAAC,YAAY,CAAC,CAAA;AACvC,MAAMC,iBAAiB,GAAG,IAAIC,iBAAiB,CAAC;AAC9CC,EAAAA,OAAO,EAAG,CAAEV,EAAAA,OAAO,CAACW,GAAG,EAAG,CAAA,CAAA,CAAA;AAC5B,CAAC,CAAC,CAAA;AAEa,eAAeC,aAAaA,CACzCC,GAAY,EACZC,IAAgC,EACjB;EACf,IAAI;IACF,MAAMA,IAAI,EAAE,CAAA;GACb,CAAC,OAAOC,KAAc,EAAE;AACvB;IACA,IAAI,CAACA,KAAK,EAAEA,KAAK,GAAG,IAAIC,KAAK,CA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AAO,EAAE;AAChB,MAAA,IAAI,CAACA,OAAO,CAACD,KAAK,EAAE,CAAA;AACpB,MAAA,IAAI,CAACE,IAAI,CAAC,OAAO,CAAC,CAAA;AACpB,KAAA;AACF,GAAA;EAEA,MAAMC,KAAKA,CAACC,EAA8B,EAAmB;IAC3D,MAAMA,EAAE,EAAE,CAAA;IACV,IAAI;AACF,MAAA,MAAM7F,MAAM,GAAG,MAAM8F,SAAO,CAAC,IAAI,CAAC7I,MAAM,EAAE,IAAI,CAAC8B,QAAQ,EAAE,EAAE,IAAI,CAACoF,QAAQ,CAAC,CAAA;MACzE,IAAI,CAACuB,OAAO,GAAG1F,MAAM,CAAA;AACrB9C,MAAAA,MAAM,CAAC6I,OAAO,CAAC,SAAS,CAAC,CAAA;MACzB,IAAInJ,OAAO,CAACoJ,IAAI,EAAEpJ,OAAO,CAACoJ,IAAI,CAAC,OAAO,CAAC,CAAA;AACvC,MAAA,OAAOhG,MAAM,CAAA;KACd,CAAC,OAAOrC,KAAc,EAAE;AACvBT,MAAAA,MAAM,CAACS,KAAK,CAAC,YAAY,EAAE;AAAEsI,QAAAA,GAAG,EAAEtI,KAAAA;AAAM,OAAC,CAAC,CAAA;AAC1C,MAAA,MAAMA,KAAK,CAAA;AACb,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
3
|
-
import type { Config } from 'alp-node-config';
|
|
4
|
-
import type { NodeApplication, NodeConfig, Context as AlpContext, ContextState, ContextRequest } from 'alp-types';
|
|
5
3
|
import Koa from 'koa';
|
|
6
|
-
import type { ParameterizedContext, DefaultState
|
|
4
|
+
import type { ParameterizedContext, DefaultState } from 'koa';
|
|
5
|
+
import type { Router } from 'router-segments';
|
|
6
|
+
import type { Config } from './config';
|
|
7
|
+
import type { AlpLanguageContext } from './language';
|
|
8
|
+
import type { AlpParamsContext, AlpParamsRequest } from './params';
|
|
9
|
+
import type { AlpRouteRef, RouterContext as AlpRouterContext, UrlGenerator } from './router';
|
|
10
|
+
import type { TranslateBaseContext, TranslateContext } from './translate';
|
|
11
|
+
import type { NodeApplication, NodeConfig, Context as AlpContext, ContextState } from './types';
|
|
7
12
|
export interface AlpNodeAppOptions {
|
|
8
13
|
appDirname: string;
|
|
9
14
|
packageDirname: string;
|
|
@@ -14,11 +19,13 @@ export interface AlpNodeAppOptions {
|
|
|
14
19
|
declare module 'koa' {
|
|
15
20
|
interface DefaultState extends ContextState {
|
|
16
21
|
}
|
|
17
|
-
interface DefaultContext extends AlpContext {
|
|
22
|
+
interface DefaultContext extends AlpContext, AlpParamsContext, AlpRouterContext, AlpLanguageContext, TranslateContext {
|
|
18
23
|
}
|
|
19
|
-
interface BaseContext extends AlpContext {
|
|
24
|
+
interface BaseContext extends AlpContext, TranslateBaseContext {
|
|
25
|
+
urlGenerator: UrlGenerator;
|
|
26
|
+
redirectTo: <P extends Record<string, unknown>>(to: string, params?: P) => void;
|
|
20
27
|
}
|
|
21
|
-
interface BaseRequest extends
|
|
28
|
+
interface BaseRequest extends AlpParamsRequest {
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
|
|
@@ -26,8 +33,8 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
|
|
|
26
33
|
certPath: string;
|
|
27
34
|
publicPath: string;
|
|
28
35
|
config: Config & NodeConfig;
|
|
29
|
-
request: BaseRequest & ContextRequest;
|
|
30
36
|
_server?: Server;
|
|
37
|
+
router?: Router<any, AlpRouteRef>;
|
|
31
38
|
/**
|
|
32
39
|
* @param {Object} [options]
|
|
33
40
|
* @param {string} [options.certPath] directory of the ssl certificates
|
|
@@ -47,4 +54,5 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
|
|
|
47
54
|
start(fn: () => Promise<void> | void): Promise<Server>;
|
|
48
55
|
}
|
|
49
56
|
export type { Context } from 'koa';
|
|
57
|
+
export { type NodeApplication } from './types';
|
|
50
58
|
//# sourceMappingURL=AlpNodeApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlpNodeApp.d.ts","sourceRoot":"","sources":["../../src/AlpNodeApp.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"AlpNodeApp.d.ts","sourceRoot":"","sources":["../../src/AlpNodeApp.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGzE,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAI9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,KAAK,EACV,WAAW,EACX,aAAa,IAAI,gBAAgB,EACjC,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,OAAO,IAAI,UAAU,EACrB,YAAY,EAEb,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;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AAM,IAAI,KAAK;IAIxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAOP,KAAK,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAa7D;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { NodeApplication, NodeConfig, PackageConfig } from './types';
|
|
2
|
+
export interface ConfigOptions {
|
|
3
|
+
argv?: string[];
|
|
4
|
+
packageConfig?: PackageConfig;
|
|
5
|
+
version?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class Config {
|
|
8
|
+
packageConfig?: PackageConfig;
|
|
9
|
+
private _map;
|
|
10
|
+
private readonly _dirname;
|
|
11
|
+
constructor(dirname: string, options?: ConfigOptions);
|
|
12
|
+
loadSync(options?: ConfigOptions): Config & NodeConfig;
|
|
13
|
+
get<T>(key: string): T;
|
|
14
|
+
existsConfigSync(name: string): boolean;
|
|
15
|
+
loadConfigSync(name: string): ReadonlyMap<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export default function getConfig(app: NodeApplication, config: Config & NodeConfig): Config & NodeConfig;
|
|
18
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa1E,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,MAAM;IACjB,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,OAAO,CAAC,IAAI,CAAuB;IAEnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;IAQpD,QAAQ,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,GAAG,UAAU;IAgE1D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAItB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;CAG3D;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,GAAG,UAAU,GAC1B,MAAM,GAAG,UAAU,CAErB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQ5C,wBAA8B,aAAa,CACzC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAC/B,OAAO,CAAC,IAAI,CAAC,CAsDf"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Config } from 'alp-node-config';
|
|
2
1
|
import type { AlpNodeAppOptions } from './AlpNodeApp';
|
|
3
2
|
import { AlpNodeApp } from './AlpNodeApp';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
export type { BaseContext, NodeApplication, NodeConfig, ContextState, ContextSanitizedState, } from './types';
|
|
4
5
|
export type { Context } from './AlpNodeApp';
|
|
5
|
-
export { Config } from 'alp-node-config';
|
|
6
6
|
export declare const appDirname: string;
|
|
7
7
|
export declare const packageDirname: string;
|
|
8
8
|
export declare const packageConfig: Record<string, unknown>;
|
|
9
|
-
export declare const config: Config & import("
|
|
9
|
+
export declare const config: Config & import("./types").NodeConfig;
|
|
10
10
|
export type AppOptions = Omit<AlpNodeAppOptions, 'appDirname' | 'config' | 'packageDirname'>;
|
|
11
11
|
export default class App extends AlpNodeApp {
|
|
12
12
|
constructor(options?: AppOptions);
|
|
13
13
|
}
|
|
14
|
+
export { Config } from './config';
|
|
15
|
+
export { default as router, createAlpRouterBuilder, type AlpRouteRef, type AlpRouter, } from './router';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,YAAY,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,YAAY,EACZ,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,eAAO,MAAM,UAAU,QAAwB,CAAC;AAMhD,eAAO,MAAM,cAAc,QAA4B,CAAC;AAIxD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAEtB,CAAC;AAO7B,eAAO,MAAM,MAAM,uCAAqD,CAAC;AAEzE,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,iBAAiB,EACjB,YAAY,GAAG,QAAQ,GAAG,gBAAgB,CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,UAAU;gBAC7B,OAAO,CAAC,EAAE,UAAU;CAQjC;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,SAAS,GACf,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/language.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AACD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAkBzD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import type { Config } from './config';
|
|
4
|
+
type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
5
|
+
export default function alpListen(config: Config, callback: RequestListener, dirname?: string): Promise<Server>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=listen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen.d.ts","sourceRoot":"","sources":["../../src/listen.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAwB3E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="koa" />
|
|
2
|
+
import type { Context } from '../AlpNodeApp';
|
|
3
|
+
import { ParamValidationResult } from './ParamValidationResult';
|
|
4
|
+
export default class ParamValid extends ParamValidationResult {
|
|
5
|
+
context: Context;
|
|
6
|
+
constructor(context: Context);
|
|
7
|
+
_error(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ParamValid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParamValid.d.ts","sourceRoot":"","sources":["../../../src/params/ParamValid.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,qBAAqB;IAC3D,OAAO,EAAE,OAAO,CAAC;gBAEL,OAAO,EAAE,OAAO;IAKnB,MAAM,IAAI,IAAI;CAGxB"}
|