alp-node 7.0.0 → 8.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +7 -7
  3. package/dist/{AlpNodeApp-node18.mjs → AlpNodeApp-node20.mjs} +59 -77
  4. package/dist/AlpNodeApp-node20.mjs.map +1 -0
  5. package/dist/definitions/AlpNodeApp.d.ts +15 -16
  6. package/dist/definitions/AlpNodeApp.d.ts.map +1 -1
  7. package/dist/definitions/config.d.ts +4 -5
  8. package/dist/definitions/config.d.ts.map +1 -1
  9. package/dist/definitions/errors.d.ts +1 -2
  10. package/dist/definitions/errors.d.ts.map +1 -1
  11. package/dist/definitions/index.d.ts +8 -8
  12. package/dist/definitions/language.d.ts +1 -1
  13. package/dist/definitions/language.d.ts.map +1 -1
  14. package/dist/definitions/listen.d.ts +2 -3
  15. package/dist/definitions/listen.d.ts.map +1 -1
  16. package/dist/definitions/params/ParamValid.d.ts +2 -3
  17. package/dist/definitions/params/ParamValid.d.ts.map +1 -1
  18. package/dist/definitions/params/ParamValueFromContext.d.ts +3 -4
  19. package/dist/definitions/params/ParamValueFromContext.d.ts.map +1 -1
  20. package/dist/definitions/params/ParamValueModelValidator.d.ts +1 -1
  21. package/dist/definitions/params/ParamValueStringValidator.d.ts +1 -1
  22. package/dist/definitions/params/ParamValueValidator.d.ts +1 -1
  23. package/dist/definitions/params/index.d.ts +8 -4
  24. package/dist/definitions/params/index.d.ts.map +1 -1
  25. package/dist/definitions/router.d.ts +3 -4
  26. package/dist/definitions/router.d.ts.map +1 -1
  27. package/dist/definitions/translate/index.d.ts +1 -1
  28. package/dist/definitions/translate/load.d.ts +3 -3
  29. package/dist/definitions/translate/load.d.ts.map +1 -1
  30. package/dist/definitions/types.d.ts +6 -6
  31. package/dist/definitions/types.d.ts.map +1 -1
  32. package/dist/{index-node18.mjs → index-node20.mjs} +142 -158
  33. package/dist/index-node20.mjs.map +1 -0
  34. package/package.json +23 -23
  35. package/src/AlpNodeApp.ts +48 -48
  36. package/src/config.ts +43 -48
  37. package/src/errors.ts +19 -19
  38. package/src/index.ts +16 -16
  39. package/src/language.ts +18 -10
  40. package/src/listen.ts +16 -16
  41. package/src/params/ParamValid.ts +3 -3
  42. package/src/params/ParamValidationResult.test.ts +5 -5
  43. package/src/params/ParamValueFromContext.ts +5 -5
  44. package/src/params/ParamValueModelValidator.ts +1 -1
  45. package/src/params/ParamValueStringValidator.ts +3 -3
  46. package/src/params/ParamValueValidator.ts +1 -1
  47. package/src/params/index.ts +17 -13
  48. package/src/router.ts +7 -7
  49. package/src/translate/index.ts +9 -9
  50. package/src/translate/load.ts +13 -12
  51. package/src/types.ts +8 -8
  52. package/dist/AlpNodeApp-node18.mjs.map +0 -1
  53. package/dist/index-node18.mjs.map +0 -1
  54. package/src/.eslintrc.json +0 -31
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
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
+ ## [8.0.0](https://github.com/christophehurpeau/alp/compare/alp-node@7.0.0...alp-node@8.0.0) (2025-08-02)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * update dependencies and drop node 20
11
+ * update dev dependencies, replace parse-json-object-as-map with native JSON.parse, update koa
12
+ * remove deprecated packageDirname
13
+ * namedRouteParam and otherRouteParam
14
+ * update koa
15
+ * update router-segments
16
+
17
+ ### Features
18
+
19
+ * remove deprecated packageDirname ([82f6f16](https://github.com/christophehurpeau/alp/commit/82f6f163d40bdfe40df181a1d009072cd1eb3c82))
20
+ * update dependencies and drop node 20 ([fc5b322](https://github.com/christophehurpeau/alp/commit/fc5b322e076e9a3c7c4a235d16734b89fd85e211))
21
+ * update dev dependencies, replace parse-json-object-as-map with native JSON.parse, update koa ([5ae7723](https://github.com/christophehurpeau/alp/commit/5ae77238cafc573fe72c5eb63b103802b8b2e537))
22
+ * update koa ([e678114](https://github.com/christophehurpeau/alp/commit/e67811429d951287de715c3dffdbee7b798f3358))
23
+ * update router-segments ([07ff52b](https://github.com/christophehurpeau/alp/commit/07ff52b3f851204256509056d0a4b25e1f630e5b))
24
+
25
+ ### Bug Fixes
26
+
27
+ * namedRouteParam and otherRouteParam ([73e9e2a](https://github.com/christophehurpeau/alp/commit/73e9e2aaf00fe956628efd1380f8e44329562c41))
28
+ * properly call callback ([89cedd4](https://github.com/christophehurpeau/alp/commit/89cedd44a2edb99e9fcc050172f9ac75e1747e20))
29
+
6
30
  ## [7.0.0](https://github.com/christophehurpeau/alp/compare/alp-node@6.2.0...alp-node@7.0.0) (2024-01-06)
7
31
 
8
32
 
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- <h3 align="center">
1
+ <h1 align="center">
2
2
  alp-node
3
- </h3>
3
+ </h1>
4
4
 
5
5
  <p align="center">
6
6
  framework based on koa 2
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/v/alp-node.svg?style=flat-square"></a>
11
- <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/dw/alp-node.svg?style=flat-square"></a>
12
- <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/node/v/alp-node.svg?style=flat-square"></a>
13
- <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/types/alp-node.svg?style=flat-square"></a>
10
+ <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/v/alp-node.svg?style=flat-square" alt="npm version"></a>
11
+ <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/dw/alp-node.svg?style=flat-square" alt="npm downloads"></a>
12
+ <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/node/v/alp-node.svg?style=flat-square" alt="node version"></a>
13
+ <a href="https://npmjs.org/package/alp-node"><img src="https://img.shields.io/npm/types/alp-node.svg?style=flat-square" alt="types"></a>
14
14
  </p>
15
15
 
16
16
  ## Install
@@ -22,7 +22,7 @@ npm install --save alp-node
22
22
  ## Usage
23
23
 
24
24
  ```js
25
- import Alp from 'alp-node';
25
+ import Alp from "alp-node";
26
26
 
27
27
  const app = new Alp();
28
28
  app.servePublic();
@@ -1,26 +1,16 @@
1
1
  import path from 'node:path';
2
- import { deprecate } from 'node:util';
3
2
  import Koa from 'koa';
4
3
  import compress from 'koa-compress';
5
4
  import serve from 'koa-static';
6
5
  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
6
  import { STATUS_CODES, createServer as createServer$2 } from 'node:http';
12
7
  import ErrorHtmlRenderer from 'error-html';
13
8
  import { defineLazyProperty } from 'object-properties';
9
+ import { unlinkSync, chmodSync, readFileSync } from 'node:fs';
14
10
  import { createServer as createServer$1 } from 'node:https';
15
11
  import IntlMessageFormatDefault from 'intl-messageformat';
16
12
 
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');
13
+ const logger$3 = new Logger("alp:errors");
24
14
  const errorHtmlRenderer = new ErrorHtmlRenderer({
25
15
  appPath: `${process.cwd()}/`
26
16
  });
@@ -29,16 +19,16 @@ async function alpNodeErrors(ctx, next) {
29
19
  await next();
30
20
  } catch (error) {
31
21
  // eslint-disable-next-line no-ex-assign
32
- if (!error) error = new Error('Unknown error');
22
+ if (!error) error = new Error("Unknown error");
33
23
  // eslint-disable-next-line no-ex-assign
34
- if (typeof error === 'string') error = new Error(error);
24
+ if (typeof error === "string") error = new Error(error);
35
25
  ctx.status = error.status || 500;
36
26
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
37
27
  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) {
28
+ switch (ctx.request.accepts("html", "text", "json")) {
29
+ case "json":
30
+ ctx.type = "application/json";
31
+ if (process.env.NODE_ENV !== "production" || error.expose) {
42
32
  ctx.body = {
43
33
  error: error.message
44
34
  };
@@ -48,9 +38,9 @@ async function alpNodeErrors(ctx, next) {
48
38
  };
49
39
  }
50
40
  break;
51
- case 'html':
52
- ctx.type = 'text/html';
53
- if (process.env.NODE_ENV !== 'production') {
41
+ case "html":
42
+ ctx.type = "text/html";
43
+ if (process.env.NODE_ENV !== "production") {
54
44
  ctx.body = errorHtmlRenderer.render(error);
55
45
  } else if (error.expose) {
56
46
  ctx.body = error.message;
@@ -58,10 +48,11 @@ async function alpNodeErrors(ctx, next) {
58
48
  throw error;
59
49
  }
60
50
  break;
61
- case 'text':
51
+ case "text":
52
+ case false:
62
53
  default:
63
- ctx.type = 'text/plain';
64
- if (process.env.NODE_ENV !== 'production' || error.expose) {
54
+ ctx.type = "text/plain";
55
+ if (process.env.NODE_ENV !== "production" || error.expose) {
65
56
  ctx.body = error.message;
66
57
  } else {
67
58
  throw error;
@@ -73,20 +64,20 @@ async function alpNodeErrors(ctx, next) {
73
64
 
74
65
  function alpLanguage(app) {
75
66
  const config = app.context.config;
76
- const availableLanguages = config.get('availableLanguages');
67
+ const availableLanguages = config.get("availableLanguages");
77
68
  if (!availableLanguages) {
78
69
  throw new Error('Missing config "availableLanguages"');
79
70
  }
80
- defineLazyProperty(app.context, 'language', function () {
81
- return this.acceptsLanguages(availableLanguages) || availableLanguages[0];
71
+ defineLazyProperty(app.context, "language", function language() {
72
+ return this.acceptsLanguages(availableLanguages) || availableLanguages[0] || "en";
82
73
  });
83
- defineLazyProperty(app.context, 'firstAcceptedLanguage', function () {
84
- return this.acceptsLanguages()[0] || availableLanguages[0];
74
+ defineLazyProperty(app.context, "firstAcceptedLanguage", function firstAcceptedLanguage() {
75
+ return this.acceptsLanguages()[0] || availableLanguages[0] || "en";
85
76
  });
86
77
  }
87
78
 
88
- const logger$2 = new Logger('alp:listen');
89
- const createServer = (callback, socketPath, tls, dirname = ''
79
+ const logger$2 = new Logger("alp:listen");
80
+ const createServer = (callback, socketPath, tls, dirname = ""
90
81
  // eslint-disable-next-line @typescript-eslint/max-params
91
82
  ) => {
92
83
  const createHttpServer = !socketPath && tls ? createServer$1 : createServer$2;
@@ -101,11 +92,11 @@ const createServer = (callback, socketPath, tls, dirname = ''
101
92
  };
102
93
  function alpListen(config, callback, dirname) {
103
94
  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 ? {
95
+ const socketPath = config.get("socketPath");
96
+ const port = config.get("port");
97
+ const hostname = config.get("hostname");
98
+ const tls = config.get("tls");
99
+ logger$2.info("Creating server", socketPath ? {
109
100
  socketPath
110
101
  } : {
111
102
  port
@@ -117,16 +108,16 @@ function alpListen(config, callback, dirname) {
117
108
  } catch {}
118
109
  server.listen(socketPath, () => {
119
110
  if (socketPath) {
120
- chmodSync(socketPath, '777');
111
+ chmodSync(socketPath, "777");
121
112
  }
122
- logger$2.info('Server listening', {
113
+ logger$2.info("Server listening", {
123
114
  socketPath
124
115
  });
125
116
  resolve(server);
126
117
  });
127
118
  } else {
128
119
  server.listen(port, hostname, () => {
129
- logger$2.info('Server listening', {
120
+ logger$2.info("Server listening", {
130
121
  port
131
122
  });
132
123
  resolve(server);
@@ -175,7 +166,7 @@ class ParamValid extends ParamValidationResult {
175
166
  this.context = context;
176
167
  }
177
168
  _error() {
178
- this.context.throw(400, 'Invalid params', {
169
+ this.context.throw(400, "Invalid params", {
179
170
  validator: this
180
171
  });
181
172
  }
@@ -197,8 +188,8 @@ class ParamValueValidator {
197
188
 
198
189
  class ParamValueStringValidator extends ParamValueValidator {
199
190
  notEmpty() {
200
- if (this.value == null || this.value.trim() === '') {
201
- this._error('notEmpty');
191
+ if (this.value == null || this.value.trim() === "") {
192
+ this._error("notEmpty");
202
193
  }
203
194
  return this;
204
195
  }
@@ -210,10 +201,10 @@ class ParamValueFromContext {
210
201
  this.context = context;
211
202
  }
212
203
  namedParam(name) {
213
- return new ParamValueStringValidator(this.validationResult, name, this.context.namedParam(name));
204
+ return new ParamValueStringValidator(this.validationResult, name, this.context.namedRouteParam(name));
214
205
  }
215
206
  otherParam(position) {
216
- return new ParamValueStringValidator(this.validationResult, String(position), this.context.otherParam(position));
207
+ return new ParamValueStringValidator(this.validationResult, String(position), this.context.otherRouteParam(position));
217
208
  }
218
209
  queryParam(name) {
219
210
  return new ParamValueStringValidator(this.validationResult, name, this.context.queryParam(name));
@@ -243,13 +234,13 @@ function alpParams(app) {
243
234
  return this.body[name];
244
235
  }
245
236
  });
246
- defineLazyProperty(app.request, 'searchParams', function () {
237
+ defineLazyProperty(app.request, "searchParams", function searchParams() {
247
238
  return new URLSearchParams(this.search);
248
239
  });
249
- defineLazyProperty(app.context, 'params', function () {
240
+ defineLazyProperty(app.context, "params", function params() {
250
241
  return new ParamValueFromContext(this, new ParamValidationResult());
251
242
  });
252
- defineLazyProperty(app.context, 'validParams', function () {
243
+ defineLazyProperty(app.context, "validParams", function validParams() {
253
244
  return new ParamValueFromContext(this, new ParamValid(this));
254
245
  });
255
246
  }
@@ -259,32 +250,29 @@ const IntlMessageFormat =
259
250
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
260
251
  IntlMessageFormatDefault.default || IntlMessageFormatDefault;
261
252
  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
253
+ const result = {};
254
+ (function loadMap(record, prefix) {
255
+ Object.entries(record).forEach(([key, value]) => {
256
+ if (typeof value === "object" && value !== null) {
267
257
  loadMap(value, `${prefix}${key}.`);
268
258
  return;
269
259
  }
270
-
271
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
272
- result.set(`${prefix}${key}`, new IntlMessageFormat(value, language));
260
+ result[`${prefix}${key}`] = new IntlMessageFormat(value, language);
273
261
  });
274
- })(translations, '');
262
+ })(translations, "");
275
263
  return result;
276
264
  }
277
265
 
278
- const logger$1 = new Logger('alp:translate');
266
+ const logger$1 = new Logger("alp:translate");
279
267
  function alpTranslate(dirname) {
280
- dirname = dirname.replace(/\/*$/, '/');
268
+ dirname = dirname.replace(/\/*$/, "/");
281
269
  return app => {
282
270
  const appTranslations = new Map();
283
271
  Object.assign(app.context, {
284
272
  t(id, args) {
285
- const msg = appTranslations.get(this.language).get(id);
273
+ const msg = appTranslations.get(this.language)?.[id];
286
274
  if (!msg) {
287
- logger$1.warn('invalid msg', {
275
+ logger$1.warn("invalid msg", {
288
276
  language: this.language,
289
277
  id
290
278
  });
@@ -294,7 +282,7 @@ function alpTranslate(dirname) {
294
282
  }
295
283
  });
296
284
  const config = app.config;
297
- config.get('availableLanguages').forEach(language => {
285
+ config.get("availableLanguages").forEach(language => {
298
286
  const translations = app.loadConfigSync(dirname + language);
299
287
  appTranslations.set(language, load(translations, language));
300
288
  });
@@ -302,7 +290,7 @@ function alpTranslate(dirname) {
302
290
  };
303
291
  }
304
292
 
305
- const logger = new Logger('alp');
293
+ const logger = new Logger("alp");
306
294
  class AlpNodeApp extends Koa {
307
295
  /**
308
296
  * @param {Object} [options]
@@ -318,18 +306,13 @@ class AlpNodeApp extends Koa {
318
306
  }) {
319
307
  super();
320
308
  this.dirname = path.normalize(appDirname);
321
- Object.defineProperty(this, 'packageDirname', {
322
- get: deprecate(() => packageDirname, 'packageDirname'),
323
- configurable: false,
324
- enumerable: false
325
- });
326
309
  this.certPath = certPath || `${packageDirname}/config/cert`;
327
310
  this.publicPath = publicPath || `${packageDirname}/public/`;
328
- this.config = getConfig(this, config);
311
+ this.config = config;
329
312
  this.context.config = this.config;
330
313
  alpParams(this);
331
314
  alpLanguage(this);
332
- alpTranslate('locales')(this);
315
+ alpTranslate("locales")(this);
333
316
  this.use(compress());
334
317
  }
335
318
  existsConfigSync(name) {
@@ -340,6 +323,7 @@ class AlpNodeApp extends Koa {
340
323
  }
341
324
  createContext(req, res) {
342
325
  const ctx = super.createContext(req, res);
326
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
343
327
  ctx.sanitizedState = {};
344
328
  return ctx;
345
329
  }
@@ -349,10 +333,8 @@ class AlpNodeApp extends Koa {
349
333
  catchErrors() {
350
334
  this.use(alpNodeErrors);
351
335
  }
352
-
353
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this
354
336
  listen() {
355
- throw new Error('Use start instead');
337
+ throw new Error("Use start instead");
356
338
  }
357
339
 
358
340
  /**
@@ -361,7 +343,7 @@ class AlpNodeApp extends Koa {
361
343
  close() {
362
344
  if (this._server) {
363
345
  this._server.close();
364
- this.emit('close');
346
+ this.emit("close");
365
347
  }
366
348
  }
367
349
  async start(fn) {
@@ -369,11 +351,11 @@ class AlpNodeApp extends Koa {
369
351
  try {
370
352
  const server = await alpListen(this.config, this.callback(), this.certPath);
371
353
  this._server = server;
372
- logger.success('started');
373
- if (process.send) process.send('ready');
354
+ logger.success("started");
355
+ if (process.send) process.send("ready");
374
356
  return server;
375
357
  } catch (error) {
376
- logger.error('start fail', {
358
+ logger.error("start fail", {
377
359
  err: error
378
360
  });
379
361
  throw error;
@@ -382,4 +364,4 @@ class AlpNodeApp extends Koa {
382
364
  }
383
365
 
384
366
  export { AlpNodeApp };
385
- //# sourceMappingURL=AlpNodeApp-node18.mjs.map
367
+ //# sourceMappingURL=AlpNodeApp-node20.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlpNodeApp-node20.mjs","sources":["../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 { 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 case false:\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(\n app.context,\n \"language\",\n function language(this: Context): string {\n return (\n this.acceptsLanguages(availableLanguages) ||\n availableLanguages[0] ||\n \"en\"\n );\n },\n );\n\n defineLazyProperty(\n app.context,\n \"firstAcceptedLanguage\",\n function firstAcceptedLanguage(this: Context): string {\n return this.acceptsLanguages()[0] || availableLanguages[0] || \"en\";\n },\n );\n}\n","import { chmodSync, readFileSync, unlinkSync } from \"node:fs\";\nimport { createServer as createServerHttp } from \"node:http\";\nimport type { IncomingMessage, Server, 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.namedRouteParam(name),\n );\n }\n\n otherParam(position: number): ParamValueStringValidator {\n return new ParamValueStringValidator(\n this.validationResult,\n String(position),\n this.context.otherRouteParam(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 namedRouteParam: (name: string) => string | undefined;\n otherRouteParam: (position: number) => string | undefined;\n /** @deprecated use namedRouteParam */\n namedParam: never;\n /** @deprecated use otherRouteParam */\n otherParam: never;\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 searchParams(this: Context[\"request\"]): URLSearchParams {\n return new URLSearchParams(this.search);\n },\n );\n\n defineLazyProperty(\n app.context,\n \"params\",\n function params(this: Context): ParamValueFromContext {\n return new ParamValueFromContext(this, new ParamValidationResult());\n },\n );\n\n defineLazyProperty(\n app.context,\n \"validParams\",\n function validParams(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 = Readonly<Record<string, IntlMessageFormatDefault>>;\n\nexport default function load(\n translations: Readonly<Record<string, unknown>>,\n language: string,\n): Translations {\n const result: Record<string, IntlMessageFormatDefault> = {};\n\n (function loadMap(record: Record<string, unknown>, prefix: string) {\n Object.entries(record).forEach(([key, value]) => {\n if (typeof value === \"object\" && value !== null) {\n loadMap(value as Record<string, unknown>, `${prefix}${key}.`);\n return;\n }\n\n result[`${prefix}${key}`] = new IntlMessageFormat(\n value as string,\n language,\n );\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)?.[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 {\n IncomingMessage,\n RequestListener,\n Server,\n ServerResponse,\n} from \"node:http\";\nimport path from \"node:path\";\nimport Koa from \"koa\";\nimport type { DefaultState, ParameterizedContext } 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 errors from \"./errors\";\nimport type { AlpLanguageContext } from \"./language\";\nimport language from \"./language\";\nimport _listen from \"./listen\";\nimport type { AlpParamsContext, AlpParamsRequest } from \"./params/index\";\nimport params from \"./params/index\";\nimport type {\n AlpRouteRef,\n RouterContext as AlpRouterContext,\n UrlGenerator,\n} from \"./router\";\nimport type { TranslateBaseContext, TranslateContext } from \"./translate/index\";\nimport translate from \"./translate/index\";\nimport type {\n Context as AlpContext,\n ContextSanitizedState,\n ContextState,\n NodeApplication,\n NodeConfig,\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-object-type\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-object-type\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 this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = 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 // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\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 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(\n this.config,\n this.callback() as RequestListener,\n this.certPath,\n );\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":["logger","Logger","errorHtmlRenderer","ErrorHtmlRenderer","appPath","process","cwd","alpNodeErrors","ctx","next","error","Error","status","request","accepts","type","env","NODE_ENV","expose","body","message","STATUS_CODES","render","alpLanguage","app","config","context","availableLanguages","get","defineLazyProperty","language","acceptsLanguages","firstAcceptedLanguage","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","namedRouteParam","otherParam","position","String","otherRouteParam","queryParam","alpParams","Object","assign","namedParams","route","otherParams","searchParams","bodyParam","URLSearchParams","search","params","validParams","IntlMessageFormat","IntlMessageFormatDefault","default","load","translations","result","loadMap","record","prefix","entries","forEach","alpTranslate","replace","appTranslations","Map","t","id","args","msg","warn","format","loadConfigSync","set","AlpNodeApp","Koa","appDirname","packageDirname","certPath","publicPath","path","normalize","translate","use","compress","existsConfigSync","createContext","req","res","sanitizedState","servePublic","serve","catchErrors","errors","close","_server","emit","start","fn","_listen","success","send","err"],"mappings":";;;;;;;;;;;;AAMA,MAAMA,QAAM,GAAG,IAAIC,MAAM,CAAC,YAAY,CAAC;AACvC,MAAMC,iBAAiB,GAAG,IAAIC,iBAAiB,CAAC;AAC9CC,EAAAA,OAAO,EAAE,CAAA,EAAGC,OAAO,CAACC,GAAG,EAAE,CAAA,CAAA;AAC3B,CAAC,CAAC;AAEa,eAAeC,aAAaA,CACzCC,GAAY,EACZC,IAAgC,EACjB;EACf,IAAI;IACF,MAAMA,IAAI,EAAE;GACb,CAAC,OAAOC,KAAc,EAAE;AACvB;IACA,IAAI,CAACA,KAAK,EAAEA,KAAK,GAAG,IAAIC,KAAK,CAAC,eAAe,CAAC;AAC9C;IACA,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D,KAAK,EAAE;AACpB,MAAA,IAAI,CAACE,IAAI,CAAC,OAAO,CAAC;AACpB;AACF;EAEA,MAAMC,KAAKA,CAACC,EAA8B,EAAmB;IAC3D,MAAMA,EAAE,EAAE;IACV,IAAI;AACF,MAAA,MAAMzF,MAAM,GAAG,MAAM0F,SAAO,CAC1B,IAAI,CAACpH,MAAM,EACX,IAAI,CAACS,QAAQ,EAAE,EACf,IAAI,CAACsF,QACP,CAAC;MACD,IAAI,CAACiB,OAAO,GAAGtF,MAAM;AACrBnD,MAAAA,MAAM,CAAC8I,OAAO,CAAC,SAAS,CAAC;MACzB,IAAIzI,OAAO,CAAC0I,IAAI,EAAE1I,OAAO,CAAC0I,IAAI,CAAC,OAAO,CAAC;AACvC,MAAA,OAAO5F,MAAM;KACd,CAAC,OAAOzC,KAAc,EAAE;AACvBV,MAAAA,MAAM,CAACU,KAAK,CAAC,YAAY,EAAE;AAAEsI,QAAAA,GAAG,EAAEtI;AAAM,OAAC,CAAC;AAC1C,MAAA,MAAMA,KAAK;AACb;AACF;AACF;;;;"}
@@ -1,14 +1,13 @@
1
- /// <reference types="node" />
2
- import type { IncomingMessage, Server, ServerResponse } from 'node:http';
3
- import Koa from 'koa';
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';
1
+ import type { IncomingMessage, Server, ServerResponse } from "node:http";
2
+ import Koa from "koa";
3
+ import type { DefaultState, ParameterizedContext } from "koa";
4
+ import type { Router } from "router-segments";
5
+ import type { Config } from "./config";
6
+ import type { AlpLanguageContext } from "./language";
7
+ import type { AlpParamsContext, AlpParamsRequest } from "./params/index";
8
+ import type { AlpRouteRef, RouterContext as AlpRouterContext, UrlGenerator } from "./router";
9
+ import type { TranslateBaseContext, TranslateContext } from "./translate/index";
10
+ import type { Context as AlpContext, ContextState, NodeApplication, NodeConfig } from "./types";
12
11
  export interface AlpNodeAppOptions {
13
12
  appDirname: string;
14
13
  packageDirname: string;
@@ -16,7 +15,7 @@ export interface AlpNodeAppOptions {
16
15
  certPath?: string;
17
16
  publicPath?: string;
18
17
  }
19
- declare module 'koa' {
18
+ declare module "koa" {
20
19
  interface DefaultState extends ContextState {
21
20
  }
22
21
  interface DefaultContext extends AlpContext, AlpParamsContext, AlpRouterContext, AlpLanguageContext, TranslateContext {
@@ -41,8 +40,8 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
41
40
  * @param {string} [options.publicPath] directory of public files
42
41
  */
43
42
  constructor({ appDirname, packageDirname, config, certPath, publicPath, }: AlpNodeAppOptions);
44
- existsConfigSync(name: string): ReturnType<Config['existsConfigSync']>;
45
- loadConfigSync(name: string): ReturnType<Config['loadConfigSync']>;
43
+ existsConfigSync(name: string): ReturnType<Config["existsConfigSync"]>;
44
+ loadConfigSync(name: string): ReturnType<Config["loadConfigSync"]>;
46
45
  createContext<StateT = DefaultState>(req: IncomingMessage, res: ServerResponse): ParameterizedContext<StateT>;
47
46
  servePublic(): void;
48
47
  catchErrors(): void;
@@ -53,6 +52,6 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
53
52
  close(): void;
54
53
  start(fn: () => Promise<void> | void): Promise<Server>;
55
54
  }
56
- export type { Context } from 'koa';
57
- export { type NodeApplication } from './types';
55
+ export type { Context } from "koa";
56
+ export { type NodeApplication } from "./types";
58
57
  //# 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,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;CAClD;AAED,qBAAa,UAAW,SAAQ,GAAG,CAAC,YAAY,CAAE,YAAW,eAAe;IAC1E,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAE5B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAElC;;;;OAIG;gBACS,EACV,UAAU,EACV,cAAc,EACd,MAAM,EACN,QAAQ,EACR,UAAU,GACX,EAAE,iBAAiB;IAiBpB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAItE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAIzD,aAAa,CAAC,MAAM,GAAG,YAAY,EAC1C,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,oBAAoB,CAAC,MAAM,CAAC;IAO/B,WAAW,IAAI,IAAI;IAInB,WAAW,IAAI,IAAI;IAIV,MAAM,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;CAiB7D;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { NodeApplication, NodeConfig, PackageConfig } from './types';
1
+ import type { NodeConfig, PackageConfig } from "./types";
2
2
  export interface ConfigOptions {
3
3
  argv?: string[];
4
4
  packageConfig?: PackageConfig;
@@ -6,13 +6,12 @@ export interface ConfigOptions {
6
6
  }
7
7
  export declare class Config {
8
8
  packageConfig?: PackageConfig;
9
- private _map;
9
+ private _record;
10
10
  private readonly _dirname;
11
11
  constructor(dirname: string, options?: ConfigOptions);
12
12
  loadSync(options?: ConfigOptions): Config & NodeConfig;
13
- get<T>(key: string): T;
13
+ get<T>(key: string): Readonly<T>;
14
14
  existsConfigSync(name: string): boolean;
15
- loadConfigSync(name: string): ReadonlyMap<string, unknown>;
15
+ loadConfigSync(name: string): Readonly<Record<string, unknown>>;
16
16
  }
17
- export default function getConfig(app: NodeApplication, config: Config & NodeConfig): Config & NodeConfig;
18
17
  //# sourceMappingURL=config.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgBzD,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,OAAO,CAA0B;IAEzC,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,QAAQ,CAAC,CAAC,CAAC;IAIhC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAGhE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="koa" />
2
- import type { Context } from './AlpNodeApp';
1
+ import type { Context } from "./AlpNodeApp";
3
2
  export default function alpNodeErrors(ctx: Context, next: () => Promise<void> | void): Promise<void>;
4
3
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +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
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAGA,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,CAuDf"}
@@ -1,16 +1,16 @@
1
- import type { AlpNodeAppOptions } from './AlpNodeApp';
2
- import { AlpNodeApp } from './AlpNodeApp';
3
- import { Config } from './config';
4
- export type { BaseContext, NodeApplication, NodeConfig, ContextState, ContextSanitizedState, } from './types';
5
- export type { Context } from './AlpNodeApp';
1
+ import type { AlpNodeAppOptions } from "./AlpNodeApp";
2
+ import { AlpNodeApp } from "./AlpNodeApp";
3
+ import { Config } from "./config";
4
+ export type { BaseContext, NodeApplication, NodeConfig, ContextState, ContextSanitizedState, } from "./types";
5
+ export type { Context } from "./AlpNodeApp";
6
6
  export declare const appDirname: string;
7
7
  export declare const packageDirname: string;
8
8
  export declare const packageConfig: Record<string, unknown>;
9
9
  export declare const config: Config & import("./types").NodeConfig;
10
- export type AppOptions = Omit<AlpNodeAppOptions, 'appDirname' | 'config' | 'packageDirname'>;
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
+ export { Config } from "./config";
15
+ export { default as router, createAlpRouterBuilder, type AlpRouteRef, type AlpRouter, } from "./router";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { AlpNodeApp } from './AlpNodeApp';
1
+ import type { AlpNodeApp } from "./AlpNodeApp";
2
2
  export interface AlpLanguageContext {
3
3
  readonly firstAcceptedLanguage: string;
4
4
  readonly language: string;
@@ -1 +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"}
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,CA0BzD"}
@@ -1,6 +1,5 @@
1
- /// <reference types="node" />
2
- import type { Server, IncomingMessage, ServerResponse } from 'node:http';
3
- import type { Config } from './config';
1
+ import type { IncomingMessage, Server, ServerResponse } from "node:http";
2
+ import type { Config } from "./config";
4
3
  type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
5
4
  export default function alpListen(config: Config, callback: RequestListener, dirname?: string): Promise<Server>;
6
5
  export {};
@@ -1 +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"}
1
+ {"version":3,"file":"listen.d.ts","sourceRoot":"","sources":["../../src/listen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,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"}