@mojojs/core 1.27.0 → 2.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 (157) hide show
  1. package/README.md +1 -1
  2. package/lib/app.d.ts +24 -16
  3. package/lib/app.js +172 -126
  4. package/lib/body/params.js +0 -1
  5. package/lib/body.d.ts +13 -5
  6. package/lib/body.js +47 -17
  7. package/lib/cache.d.ts +1 -2
  8. package/lib/cache.js +12 -21
  9. package/lib/cgi.d.ts +3 -3
  10. package/lib/cgi.js +6 -5
  11. package/lib/cli/cgi.d.ts +1 -1
  12. package/lib/cli/cgi.js +1 -2
  13. package/lib/cli/create-full-app.d.ts +1 -1
  14. package/lib/cli/create-full-app.js +27 -27
  15. package/lib/cli/create-lite-app.d.ts +1 -1
  16. package/lib/cli/create-lite-app.js +2 -3
  17. package/lib/cli/create-plugin.d.ts +1 -1
  18. package/lib/cli/create-plugin.js +25 -23
  19. package/lib/cli/eval.d.ts +1 -1
  20. package/lib/cli/eval.js +12 -5
  21. package/lib/cli/get.d.ts +1 -1
  22. package/lib/cli/get.js +30 -26
  23. package/lib/cli/repl.d.ts +1 -1
  24. package/lib/cli/repl.js +0 -1
  25. package/lib/cli/routes.d.ts +1 -1
  26. package/lib/cli/routes.js +10 -7
  27. package/lib/cli/server.d.ts +1 -1
  28. package/lib/cli/server.js +41 -24
  29. package/lib/cli/version.js +1 -2
  30. package/lib/cli.d.ts +1 -1
  31. package/lib/cli.js +25 -19
  32. package/lib/context.d.ts +10 -10
  33. package/lib/context.js +94 -34
  34. package/lib/core.d.ts +14 -14
  35. package/lib/core.js +12 -13
  36. package/lib/headers.js +5 -4
  37. package/lib/hooks.d.ts +1 -1
  38. package/lib/hooks.js +1 -5
  39. package/lib/logger.d.ts +2 -2
  40. package/lib/logger.js +28 -16
  41. package/lib/mime.js +10 -13
  42. package/lib/plugins/default-conditions.d.ts +1 -1
  43. package/lib/plugins/default-conditions.js +0 -1
  44. package/lib/plugins/default-helpers.d.ts +1 -1
  45. package/lib/plugins/default-helpers.js +28 -11
  46. package/lib/plugins/json-config.d.ts +1 -1
  47. package/lib/plugins/json-config.js +0 -1
  48. package/lib/plugins/mount.d.ts +1 -1
  49. package/lib/plugins/mount.js +0 -1
  50. package/lib/plugins/tmpl-engine.d.ts +1 -1
  51. package/lib/plugins/tmpl-engine.js +2 -5
  52. package/lib/plugins/yaml-config.d.ts +1 -1
  53. package/lib/plugins/yaml-config.js +1 -2
  54. package/lib/renderer.d.ts +1 -1
  55. package/lib/renderer.js +27 -30
  56. package/lib/router/pattern.d.ts +1 -1
  57. package/lib/router/pattern.js +25 -14
  58. package/lib/router/plan.d.ts +1 -1
  59. package/lib/router/plan.js +12 -15
  60. package/lib/router/route.d.ts +3 -3
  61. package/lib/router/route.js +35 -38
  62. package/lib/router.d.ts +4 -4
  63. package/lib/router.js +25 -26
  64. package/lib/server/cookie.d.ts +1 -1
  65. package/lib/server/cookie.js +1 -2
  66. package/lib/server/request.d.ts +3 -3
  67. package/lib/server/request.js +44 -17
  68. package/lib/server/response.d.ts +3 -3
  69. package/lib/server/response.js +20 -20
  70. package/lib/server.d.ts +7 -2
  71. package/lib/server.js +69 -19
  72. package/lib/session.d.ts +3 -3
  73. package/lib/session.js +46 -34
  74. package/lib/sse.d.ts +1 -1
  75. package/lib/sse.js +0 -1
  76. package/lib/static.d.ts +1 -1
  77. package/lib/static.js +27 -22
  78. package/lib/types.d.ts +6 -5
  79. package/lib/types.js +0 -1
  80. package/lib/user-agent/cookie-jar.d.ts +2 -2
  81. package/lib/user-agent/cookie-jar.js +6 -9
  82. package/lib/user-agent/mock.d.ts +4 -4
  83. package/lib/user-agent/mock.js +6 -7
  84. package/lib/user-agent/response.d.ts +2 -2
  85. package/lib/user-agent/response.js +14 -3
  86. package/lib/user-agent/test.d.ts +5 -5
  87. package/lib/user-agent/test.js +14 -15
  88. package/lib/user-agent/transport/http.d.ts +2 -2
  89. package/lib/user-agent/transport/http.js +7 -10
  90. package/lib/user-agent/transport/https.d.ts +2 -2
  91. package/lib/user-agent/transport/https.js +2 -6
  92. package/lib/user-agent/transport/ws.d.ts +2 -2
  93. package/lib/user-agent/transport/ws.js +2 -3
  94. package/lib/user-agent.d.ts +18 -19
  95. package/lib/user-agent.js +64 -49
  96. package/lib/util.d.ts +13 -0
  97. package/lib/util.js +35 -11
  98. package/lib/validator/result.d.ts +1 -1
  99. package/lib/validator/result.js +8 -1
  100. package/lib/validator.d.ts +2 -2
  101. package/lib/validator.js +3 -6
  102. package/lib/websocket.d.ts +2 -2
  103. package/lib/websocket.js +9 -1
  104. package/package.json +22 -29
  105. package/lib/app.js.map +0 -1
  106. package/lib/body/params.js.map +0 -1
  107. package/lib/body.js.map +0 -1
  108. package/lib/cache.js.map +0 -1
  109. package/lib/cgi.js.map +0 -1
  110. package/lib/cli/cgi.js.map +0 -1
  111. package/lib/cli/create-full-app.js.map +0 -1
  112. package/lib/cli/create-lite-app.js.map +0 -1
  113. package/lib/cli/create-plugin.js.map +0 -1
  114. package/lib/cli/eval.js.map +0 -1
  115. package/lib/cli/get.js.map +0 -1
  116. package/lib/cli/repl.js.map +0 -1
  117. package/lib/cli/routes.js.map +0 -1
  118. package/lib/cli/server.js.map +0 -1
  119. package/lib/cli/version.js.map +0 -1
  120. package/lib/cli.js.map +0 -1
  121. package/lib/context.js.map +0 -1
  122. package/lib/core.js.map +0 -1
  123. package/lib/headers.js.map +0 -1
  124. package/lib/hooks.js.map +0 -1
  125. package/lib/logger.js.map +0 -1
  126. package/lib/mime.js.map +0 -1
  127. package/lib/plugins/default-conditions.js.map +0 -1
  128. package/lib/plugins/default-helpers.js.map +0 -1
  129. package/lib/plugins/json-config.js.map +0 -1
  130. package/lib/plugins/mount.js.map +0 -1
  131. package/lib/plugins/tmpl-engine.js.map +0 -1
  132. package/lib/plugins/yaml-config.js.map +0 -1
  133. package/lib/renderer.js.map +0 -1
  134. package/lib/router/pattern.js.map +0 -1
  135. package/lib/router/plan.js.map +0 -1
  136. package/lib/router/route.js.map +0 -1
  137. package/lib/router.js.map +0 -1
  138. package/lib/server/cookie.js.map +0 -1
  139. package/lib/server/request.js.map +0 -1
  140. package/lib/server/response.js.map +0 -1
  141. package/lib/server.js.map +0 -1
  142. package/lib/session.js.map +0 -1
  143. package/lib/sse.js.map +0 -1
  144. package/lib/static.js.map +0 -1
  145. package/lib/types.js.map +0 -1
  146. package/lib/user-agent/cookie-jar.js.map +0 -1
  147. package/lib/user-agent/mock.js.map +0 -1
  148. package/lib/user-agent/response.js.map +0 -1
  149. package/lib/user-agent/test.js.map +0 -1
  150. package/lib/user-agent/transport/http.js.map +0 -1
  151. package/lib/user-agent/transport/https.js.map +0 -1
  152. package/lib/user-agent/transport/ws.js.map +0 -1
  153. package/lib/user-agent.js.map +0 -1
  154. package/lib/util.js.map +0 -1
  155. package/lib/validator/result.js.map +0 -1
  156. package/lib/validator.js.map +0 -1
  157. package/lib/websocket.js.map +0 -1
package/lib/renderer.js CHANGED
@@ -7,35 +7,33 @@ const gzipPromise = promisify(gzip);
7
7
  * Renderer class.
8
8
  */
9
9
  export class Renderer {
10
- constructor() {
11
- /**
12
- * Try to negotiate compression for dynamically generated response content and gzip compress it automatically.
13
- */
14
- this.autoCompress = true;
15
- /**
16
- * The default template engine to use for rendering in cases where auto-detection doesn't work, like for inline
17
- * templates, defaults to `tmpl`.
18
- */
19
- this.defaultEngine = 'tmpl';
20
- /**
21
- * The default format to render if format is not set, defaults to `html`. Note that changing the default away from
22
- * `html` is not recommended, as it has the potential to break, for example, plugins with bundled templates.
23
- */
24
- this.defaultFormat = 'html';
25
- /**
26
- * Template engines.
27
- */
28
- this.engines = {};
29
- /**
30
- * Minimum output size in bytes required for compression to be used if enabled, defaults to `860`.
31
- */
32
- this.minCompressSize = 860;
33
- /**
34
- * Directories to look for templates in, first one has the highest precedence.
35
- */
36
- this.viewPaths = [Path.currentFile().sibling('..', 'vendor', 'views').toString()];
37
- this._viewIndex = undefined;
38
- }
10
+ /**
11
+ * Try to negotiate compression for dynamically generated response content and gzip compress it automatically.
12
+ */
13
+ autoCompress = true;
14
+ /**
15
+ * The default template engine to use for rendering in cases where auto-detection doesn't work, like for inline
16
+ * templates, defaults to `tmpl`.
17
+ */
18
+ defaultEngine = 'tmpl';
19
+ /**
20
+ * The default format to render if format is not set, defaults to `html`. Note that changing the default away from
21
+ * `html` is not recommended, as it has the potential to break, for example, plugins with bundled templates.
22
+ */
23
+ defaultFormat = 'html';
24
+ /**
25
+ * Template engines.
26
+ */
27
+ engines = {};
28
+ /**
29
+ * Minimum output size in bytes required for compression to be used if enabled, defaults to `860`.
30
+ */
31
+ minCompressSize = 860;
32
+ /**
33
+ * Directories to look for templates in, first one has the highest precedence.
34
+ */
35
+ viewPaths = [Path.currentFile().sibling('..', 'vendor', 'views').toString()];
36
+ _viewIndex = undefined;
39
37
  /**
40
38
  * Register a template engine.
41
39
  */
@@ -194,4 +192,3 @@ export class Renderer {
194
192
  return { output: await engine.render(ctx, options), format: view.format };
195
193
  }
196
194
  }
197
- //# sourceMappingURL=renderer.js.map
@@ -1,4 +1,4 @@
1
- import type { PlaceholderType } from '../types.js';
1
+ import type { PlaceholderType } from '../types.ts';
2
2
  interface MatchOptions {
3
3
  isEndpoint: boolean;
4
4
  }
@@ -10,20 +10,32 @@ const OP = {
10
10
  * Route pattern class.
11
11
  */
12
12
  export class Pattern {
13
+ /**
14
+ * Pattern constraints.
15
+ */
16
+ constraints;
17
+ /**
18
+ * Pattern default values.
19
+ */
20
+ defaults;
21
+ /**
22
+ * Placeholder names.
23
+ */
24
+ placeholders = [];
25
+ /**
26
+ * Pattern in compiled regular expression form.
27
+ */
28
+ regex = undefined;
29
+ /**
30
+ * Placeholder types.
31
+ */
32
+ types;
33
+ /**
34
+ * Raw unparsed pattern.
35
+ */
36
+ unparsed = '';
37
+ _ast = [];
13
38
  constructor(path, options = {}) {
14
- /**
15
- * Placeholder names.
16
- */
17
- this.placeholders = [];
18
- /**
19
- * Pattern in compiled regular expression form.
20
- */
21
- this.regex = undefined;
22
- /**
23
- * Raw unparsed pattern.
24
- */
25
- this.unparsed = '';
26
- this._ast = [];
27
39
  this.constraints = options.constraints ?? {};
28
40
  this.defaults = options.defaults ?? {};
29
41
  this.types = options.types ?? {};
@@ -202,4 +214,3 @@ export class Pattern {
202
214
  ast.reverse();
203
215
  }
204
216
  }
205
- //# sourceMappingURL=pattern.js.map
@@ -1,4 +1,4 @@
1
- import type { Route } from './route.js';
1
+ import type { Route } from './route.ts';
2
2
  /**
3
3
  * Router plan class.
4
4
  */
@@ -2,20 +2,18 @@
2
2
  * Router plan class.
3
3
  */
4
4
  export class Plan {
5
- constructor() {
6
- /**
7
- * Route endpoint.
8
- */
9
- this.endpoint = undefined;
10
- /**
11
- * Steps in route.
12
- */
13
- this.steps = [];
14
- /**
15
- * Dispatch stops in route.
16
- */
17
- this.stops = [];
18
- }
5
+ /**
6
+ * Route endpoint.
7
+ */
8
+ endpoint = undefined;
9
+ /**
10
+ * Steps in route.
11
+ */
12
+ steps = [];
13
+ /**
14
+ * Dispatch stops in route.
15
+ */
16
+ stops = [];
19
17
  /**
20
18
  * Render route.
21
19
  */
@@ -27,4 +25,3 @@ export class Plan {
27
25
  return { path: endpoint.render(merged), websocket: endpoint.hasWebSocket() };
28
26
  }
29
27
  }
30
- //# sourceMappingURL=plan.js.map
@@ -1,6 +1,6 @@
1
- import type { Router } from '../router.js';
2
- import type { AnyArguments, MojoAction, RouteArguments } from '../types.js';
3
- import { Pattern } from './pattern.js';
1
+ import type { Router } from '../router.ts';
2
+ import type { AnyArguments, MojoAction, RouteArguments } from '../types.ts';
3
+ import { Pattern } from './pattern.ts';
4
4
  /**
5
5
  * Route class.
6
6
  */
@@ -1,44 +1,42 @@
1
- import { Pattern } from './pattern.js';
1
+ import { Pattern } from "./pattern.js";
2
2
  /**
3
3
  * Route class.
4
4
  */
5
5
  export class Route {
6
- constructor() {
7
- /**
8
- * The children of this route, used for nesting routes.
9
- */
10
- this.children = [];
11
- /**
12
- * Custom route name, if defined.
13
- */
14
- this.customName = undefined;
15
- /**
16
- * Default route name.
17
- */
18
- this.defaultName = undefined;
19
- /**
20
- * Allow `under` semantics for this route.
21
- */
22
- this.underRoute = false;
23
- /**
24
- * Restrict HTTP methods this route is allowed to handle, defaults to no restrictions.
25
- */
26
- this.methods = [];
27
- /**
28
- * Pattern for this route.
29
- */
30
- this.pattern = new Pattern();
31
- /**
32
- * Activate conditions for this route.
33
- */
34
- this.requirements = [];
35
- /**
36
- * Activate `websocket` semantics for this route.
37
- */
38
- this.websocketRoute = false;
39
- this._parent = undefined;
40
- this._root = undefined;
41
- }
6
+ /**
7
+ * The children of this route, used for nesting routes.
8
+ */
9
+ children = [];
10
+ /**
11
+ * Custom route name, if defined.
12
+ */
13
+ customName = undefined;
14
+ /**
15
+ * Default route name.
16
+ */
17
+ defaultName = undefined;
18
+ /**
19
+ * Allow `under` semantics for this route.
20
+ */
21
+ underRoute = false;
22
+ /**
23
+ * Restrict HTTP methods this route is allowed to handle, defaults to no restrictions.
24
+ */
25
+ methods = [];
26
+ /**
27
+ * Pattern for this route.
28
+ */
29
+ pattern = new Pattern();
30
+ /**
31
+ * Activate conditions for this route.
32
+ */
33
+ requirements = [];
34
+ /**
35
+ * Activate `websocket` semantics for this route.
36
+ */
37
+ websocketRoute = false;
38
+ _parent = undefined;
39
+ _root = undefined;
42
40
  /**
43
41
  * Add a child to this route.
44
42
  */
@@ -296,4 +294,3 @@ export class Route {
296
294
  return branch;
297
295
  }
298
296
  }
299
- //# sourceMappingURL=route.js.map
package/lib/router.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { MojoContext, PlaceholderType } from './types.js';
2
- import { Cache } from './cache.js';
3
- import { Plan } from './router/plan.js';
4
- import { Route } from './router/route.js';
1
+ import type { MojoContext, PlaceholderType } from './types.ts';
2
+ import { Cache } from './cache.ts';
3
+ import { Plan } from './router/plan.ts';
4
+ import { Route } from './router/route.ts';
5
5
  type RouteIndex = Record<string, Route>;
6
6
  interface RouteSpec {
7
7
  ctx?: MojoContext;
package/lib/router.js CHANGED
@@ -1,35 +1,35 @@
1
- import { Cache } from './cache.js';
2
- import { Plan } from './router/plan.js';
3
- import { Route } from './router/route.js';
4
- import * as util from './util.js';
1
+ import { Cache } from "./cache.js";
2
+ import { Plan } from "./router/plan.js";
3
+ import { Route } from "./router/route.js";
4
+ import * as util from "./util.js";
5
5
  const PLACEHOLDER = {};
6
6
  /**
7
7
  * Router class.
8
8
  */
9
9
  export class Router extends Route {
10
+ /**
11
+ * Routing cache.
12
+ */
13
+ cache = new Cache();
14
+ /**
15
+ * Contains all available conditions.
16
+ */
17
+ conditions = {};
18
+ /**
19
+ * Directories to look for controllers in, first one has the highest precedence.
20
+ */
21
+ controllerPaths = [];
22
+ /**
23
+ * Already loaded controllers.
24
+ */
25
+ controllers = {};
26
+ /**
27
+ * Registered placeholder types, by default only `num` is already defined.
28
+ */
29
+ types = { num: /[0-9]+/ };
30
+ _lookupIndex = undefined;
10
31
  constructor() {
11
32
  super();
12
- /**
13
- * Routing cache.
14
- */
15
- this.cache = new Cache();
16
- /**
17
- * Contains all available conditions.
18
- */
19
- this.conditions = {};
20
- /**
21
- * Directories to look for controllers in, first one has the highest precedence.
22
- */
23
- this.controllerPaths = [];
24
- /**
25
- * Already loaded controllers.
26
- */
27
- this.controllers = {};
28
- /**
29
- * Registered placeholder types, by default only `num` is already defined.
30
- */
31
- this.types = { num: /[0-9]+/ };
32
- this._lookupIndex = undefined;
33
33
  this.root = this;
34
34
  }
35
35
  /**
@@ -218,4 +218,3 @@ export class Router extends Route {
218
218
  return false;
219
219
  }
220
220
  }
221
- //# sourceMappingURL=router.js.map
@@ -1,4 +1,4 @@
1
- import type { CookieOptions } from '../types.js';
1
+ import type { CookieOptions } from '../types.ts';
2
2
  /**
3
3
  * Parse cookie.
4
4
  */
@@ -3,7 +3,7 @@ import { decodeURIComponentSafe } from '@mojojs/util';
3
3
  * Parse cookie.
4
4
  */
5
5
  export function parseCookie(cookie) {
6
- const values = {};
6
+ const values = Object.create(null);
7
7
  for (const pair of cookie.split(/[,;]/)) {
8
8
  const match = pair.match(/^\s*([^=\s]+)\s*=\s*(\S+)\s*$/);
9
9
  if (match === null)
@@ -50,4 +50,3 @@ export function stringifyCookie(name, value, options = {}) {
50
50
  cookie.push('Secure');
51
51
  return cookie.join('; ');
52
52
  }
53
- //# sourceMappingURL=cookie.js.map
@@ -1,6 +1,6 @@
1
- import type { ServerRequestOptions } from '../types.js';
2
- import { Params } from '../body/params.js';
3
- import { Body } from '../body.js';
1
+ import type { ServerRequestOptions } from '../types.ts';
2
+ import { Params } from '../body/params.ts';
3
+ import { Body } from '../body.ts';
4
4
  /**
5
5
  * Server request class.
6
6
  */
@@ -1,6 +1,6 @@
1
- import { Params } from '../body/params.js';
2
- import { Body } from '../body.js';
3
- import { parseCookie } from '../server/cookie.js';
1
+ import { Params } from "../body/params.js";
2
+ import { Body } from "../body.js";
3
+ import { parseCookie } from "../server/cookie.js";
4
4
  import { decodeURIComponentSafe } from '@mojojs/util';
5
5
  // Official regex from RFC 3986
6
6
  const URL_RE = /^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
@@ -9,21 +9,49 @@ let requestId = 0;
9
9
  * Server request class.
10
10
  */
11
11
  export class ServerRequest extends Body {
12
+ /**
13
+ * Request base path.
14
+ */
15
+ basePath = '';
16
+ /**
17
+ * Check if underlying socket was encrypted with TLS.
18
+ */
19
+ isSecure;
20
+ /**
21
+ * Request is a WebSocket handshake.
22
+ */
23
+ isWebSocket;
24
+ /**
25
+ * Request method.
26
+ */
27
+ method;
28
+ /**
29
+ * Request path.
30
+ */
31
+ path = '/';
32
+ /**
33
+ * Peer address.
34
+ */
35
+ remoteAddress;
36
+ /**
37
+ * Request ID.
38
+ */
39
+ requestId;
40
+ /**
41
+ * Reverse proxy support is activated.
42
+ */
43
+ reverseProxy;
44
+ /**
45
+ * Request URL.
46
+ */
47
+ url;
48
+ _cookies = undefined;
49
+ _ip = undefined;
50
+ _protocol = undefined;
51
+ _query = undefined;
52
+ _userinfo = undefined;
12
53
  constructor(options) {
13
54
  super(options.headers, options.body);
14
- /**
15
- * Request base path.
16
- */
17
- this.basePath = '';
18
- /**
19
- * Request path.
20
- */
21
- this.path = '/';
22
- this._cookies = undefined;
23
- this._ip = undefined;
24
- this._protocol = undefined;
25
- this._query = undefined;
26
- this._userinfo = undefined;
27
55
  this.method = options.method ?? null;
28
56
  const url = (this.url = options.url ?? null);
29
57
  const pathMatch = (url ?? '').match(URL_RE);
@@ -114,4 +142,3 @@ export class ServerRequest extends Body {
114
142
  return this._userinfo;
115
143
  }
116
144
  }
117
- //# sourceMappingURL=request.js.map
@@ -1,7 +1,7 @@
1
- import type { Context } from '../context.js';
2
- import type { CookieOptions } from '../types.js';
1
+ import type { Context } from '../context.ts';
2
+ import type { CookieOptions } from '../types.ts';
3
3
  import type { Stream } from 'node:stream';
4
- import { Headers } from '../headers.js';
4
+ import { Headers } from '../headers.ts';
5
5
  type SendResponse = (res: ServerResponse, body?: string | Buffer | Stream) => void;
6
6
  /**
7
7
  * Server response class.
@@ -1,27 +1,28 @@
1
- import { stringifyCookie } from './cookie.js';
2
- import { Headers } from '../headers.js';
1
+ import { stringifyCookie } from "./cookie.js";
2
+ import { Headers } from "../headers.js";
3
3
  /**
4
4
  * Server response class.
5
5
  */
6
6
  export class ServerResponse {
7
+ /**
8
+ * Response headers.
9
+ */
10
+ headers = new Headers();
11
+ /**
12
+ * Response has already been sent.
13
+ */
14
+ isSent = false;
15
+ /**
16
+ * Response status code.
17
+ */
18
+ statusCode = 200;
19
+ /**
20
+ * Response status message.
21
+ */
22
+ statusMessage = null;
23
+ _ctx = undefined;
24
+ _sendResponse;
7
25
  constructor(sendResponse) {
8
- /**
9
- * Response headers.
10
- */
11
- this.headers = new Headers();
12
- /**
13
- * Response has already been sent.
14
- */
15
- this.isSent = false;
16
- /**
17
- * Response status code.
18
- */
19
- this.statusCode = 200;
20
- /**
21
- * Response status message.
22
- */
23
- this.statusMessage = null;
24
- this._ctx = undefined;
25
26
  this._sendResponse = sendResponse;
26
27
  }
27
28
  /**
@@ -91,4 +92,3 @@ export class ServerResponse {
91
92
  return this.set('Content-Type', type);
92
93
  }
93
94
  }
94
- //# sourceMappingURL=response.js.map
package/lib/server.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { MojoApp, ServerOptions } from './types.js';
1
+ import type { MojoApp, ServerOptions } from './types.ts';
2
2
  import type { Socket } from 'node:net';
3
3
  import http from 'node:http';
4
4
  import https from 'node:https';
5
5
  import { URL } from 'node:url';
6
- import { ServerRequest } from './server/request.js';
6
+ import { ServerRequest } from './server/request.ts';
7
7
  import { WebSocketServer } from 'ws';
8
8
  type ListenArgs = any[];
9
9
  /**
@@ -28,6 +28,11 @@ export declare class Server {
28
28
  * Maximum number of requests socket can handle before closing keep alive connection, defaults to `0`.
29
29
  */
30
30
  maxRequestsPerSocket: number | undefined;
31
+ /**
32
+ * Maximum WebSocket message size in bytes, defaults to `262144` (256 KiB). Connections exceeding the limit are closed
33
+ * with status `1009`.
34
+ */
35
+ maxWebSocketSize: number;
31
36
  /**
32
37
  * Limit the amount of time for receiving the entire request from the client, defaults to `300000` (300 seconds).
33
38
  */