starlight-server 1.7.5 → 1.7.6

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.
@@ -7,7 +7,7 @@ declare class RequestHelpers {
7
7
  readonly request: Request;
8
8
  readonly pathParameters: PathParameters;
9
9
  constructor(request: Request, pathParameters: PathParameters);
10
- validatePathParameters<Definition extends Record<string, ValidatorDefinition>>(struct: Definition): import("@anjianshi/utils/validators/base.js").Validated<{
10
+ validatePathParameters<const Definition extends Record<string, ValidatorDefinition>>(struct: Definition): import("@anjianshi/utils/validators/base.js").Validated<{
11
11
  readonly type: "struct";
12
12
  readonly struct: Definition;
13
13
  } extends infer T ? T extends {
@@ -24,7 +24,7 @@ declare class RequestHelpers {
24
24
  } : T_1 extends import("@anjianshi/utils/validators/factory.js").RecordDefinition ? Omit<T_1, "record"> & {
25
25
  record: import("@anjianshi/utils/validators/factory.js").ValidatorForDefinition<T_1["record"]>;
26
26
  } : T_1 : never : never>;
27
- validateQuery<Definition extends Record<string, ValidatorDefinition>>(struct: Definition): import("@anjianshi/utils/validators/base.js").Validated<{
27
+ validateQuery<const Definition extends Record<string, ValidatorDefinition>>(struct: Definition): import("@anjianshi/utils/validators/base.js").Validated<{
28
28
  readonly type: "struct";
29
29
  readonly struct: Definition;
30
30
  } extends infer T ? T extends {
@@ -41,7 +41,7 @@ declare class RequestHelpers {
41
41
  } : T_1 extends import("@anjianshi/utils/validators/factory.js").RecordDefinition ? Omit<T_1, "record"> & {
42
42
  record: import("@anjianshi/utils/validators/factory.js").ValidatorForDefinition<T_1["record"]>;
43
43
  } : T_1 : never : never>;
44
- validateBody<Definition extends Record<string, ValidatorDefinition>>(struct: Definition): Promise<import("@anjianshi/utils/validators/base.js").Validated<{
44
+ validateBody<const Definition extends Record<string, ValidatorDefinition>>(struct: Definition): Promise<import("@anjianshi/utils/validators/base.js").Validated<{
45
45
  readonly type: "struct";
46
46
  readonly struct: Definition;
47
47
  } extends infer T ? T extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-server",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Simple But Powerful Node.js HTTP Server",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -14,7 +14,7 @@ class RequestHelpers {
14
14
  readonly pathParameters: PathParameters,
15
15
  ) {}
16
16
 
17
- validatePathParameters<Definition extends Record<string, ValidatorDefinition>>(
17
+ validatePathParameters<const Definition extends Record<string, ValidatorDefinition>>(
18
18
  struct: Definition,
19
19
  ) {
20
20
  const result = getValidator({ type: 'struct', struct })(
@@ -25,13 +25,15 @@ class RequestHelpers {
25
25
  throw new HTTPError(400, result.message)
26
26
  }
27
27
 
28
- validateQuery<Definition extends Record<string, ValidatorDefinition>>(struct: Definition) {
28
+ validateQuery<const Definition extends Record<string, ValidatorDefinition>>(struct: Definition) {
29
29
  const result = getValidator({ type: 'struct', struct })('query', this.request.query)
30
30
  if (result.success) return result.data
31
31
  throw new HTTPError(400, result.message)
32
32
  }
33
33
 
34
- async validateBody<Definition extends Record<string, ValidatorDefinition>>(struct: Definition) {
34
+ async validateBody<const Definition extends Record<string, ValidatorDefinition>>(
35
+ struct: Definition,
36
+ ) {
35
37
  const body = await this.request.body.json()
36
38
  if (typeof body !== 'object' || body === null || Array.isArray(body))
37
39
  throw new HTTPError(400, 'Invalid JSON body, should be an object.')