@thisisagile/easy 14.0.0 → 14.1.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.
@@ -1,13 +1,14 @@
1
- import { Id, Json, JsonValue, PageOptions, Text } from '../types';
1
+ import { Id, Json, JsonValue, OneOrMore, PageOptions, Text } from '../types';
2
2
  export declare class Req implements Omit<PageOptions, 'sort'> {
3
3
  readonly path: Json;
4
4
  readonly query: Json;
5
5
  readonly body: unknown;
6
- constructor(path: Json, query: Json, body: unknown);
7
- get id(): Id;
8
- get q(): JsonValue;
6
+ readonly headers: Record<string, OneOrMore<string>>;
9
7
  readonly skip: import("../types").Optional<number>;
10
8
  readonly take: import("../types").Optional<number>;
9
+ constructor(path: Json, query: Json, body: unknown, headers: Record<string, OneOrMore<string>>);
10
+ get id(): Id;
11
+ get q(): JsonValue;
11
12
  get: (key: Text) => any;
12
13
  }
13
14
  export declare const toReq: (req: {
@@ -18,4 +19,5 @@ export declare const toReq: (req: {
18
19
  q?: unknown;
19
20
  };
20
21
  body?: unknown;
22
+ headers?: unknown;
21
23
  }) => Req;
@@ -4,10 +4,11 @@ exports.toReq = exports.Req = void 0;
4
4
  const types_1 = require("../types");
5
5
  const utils_1 = require("../utils");
6
6
  class Req {
7
- constructor(path = {}, query = {}, body) {
7
+ constructor(path = {}, query = {}, body, headers) {
8
8
  this.path = path;
9
9
  this.query = query;
10
10
  this.body = body;
11
+ this.headers = headers;
11
12
  this.skip = (0, utils_1.ifDefined)(this.query?.skip, (0, types_1.asNumber)(this.query?.skip));
12
13
  this.take = (0, utils_1.ifDefined)(this.query?.take, (0, types_1.asNumber)(this.query?.take));
13
14
  this.get = (key) => this.path[key.toString()] ?? this.query[key.toString()];
@@ -20,6 +21,6 @@ class Req {
20
21
  }
21
22
  }
22
23
  exports.Req = Req;
23
- const toReq = (req) => new Req(req.params, req.query, req.body);
24
+ const toReq = (req) => new Req(req.params, req.query, req.body, req.headers);
24
25
  exports.toReq = toReq;
25
26
  //# sourceMappingURL=Req.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Req.js","sourceRoot":"","sources":["../../src/resources/Req.ts"],"names":[],"mappings":";;;AAAA,oCAA4E;AAC5E,oCAAqC;AAErC,MAAa,GAAG;IACd,YAAqB,OAAa,EAAE,EAAW,QAAc,EAAE,EAAW,IAAa;QAAlE,SAAI,GAAJ,IAAI,CAAW;QAAW,UAAK,GAAL,KAAK,CAAW;QAAW,SAAI,GAAJ,IAAI,CAAS;QAU9E,SAAI,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,gBAAQ,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/D,SAAI,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,gBAAQ,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAExE,QAAG,GAAG,CAAC,GAAS,EAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAbQ,CAAC;IAE3F,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CAMF;AAfD,kBAeC;AAEM,MAAM,KAAK,GAAG,CAAC,GAA2E,EAAO,EAAE,CACxG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAc,EAAE,GAAG,CAAC,KAAa,EAAE,GAAG,CAAC,IAAY,CAAC,CAAC;AADtD,QAAA,KAAK,SACiD"}
1
+ {"version":3,"file":"Req.js","sourceRoot":"","sources":["../../src/resources/Req.ts"],"names":[],"mappings":";;;AAAA,oCAAuF;AACvF,oCAAqC;AAErC,MAAa,GAAG;IAId,YAAqB,OAAa,EAAE,EAAW,QAAc,EAAE,EAAW,IAAa,EAAW,OAA0C;QAAvH,SAAI,GAAJ,IAAI,CAAW;QAAW,UAAK,GAAL,KAAK,CAAW;QAAW,SAAI,GAAJ,IAAI,CAAS;QAAW,YAAO,GAAP,OAAO,CAAmC;QAHnI,SAAI,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,gBAAQ,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/D,SAAI,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,gBAAQ,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAaxE,QAAG,GAAG,CAAC,GAAS,EAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAVlF,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CAGF;AAhBD,kBAgBC;AAEM,MAAM,KAAK,GAAG,CAAC,GAKrB,EAAO,EAAE,CACR,IAAI,GAAG,CAAC,GAAG,CAAC,MAAc,EAAE,GAAG,CAAC,KAAa,EAAE,GAAG,CAAC,IAAY,EAAE,GAAG,CAAC,OAA4C,CAAC,CAAC;AANxG,QAAA,KAAK,SAMmG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "14.0.0",
3
+ "version": "14.1.0",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "14.0.0",
34
+ "@thisisagile/easy-test": "14.1.0",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^9.0.2",
37
37
  "@types/luxon": "3.2.0",
@@ -1,8 +1,12 @@
1
- import { asNumber, Id, Json, JsonValue, PageOptions, Text } from '../types';
1
+ import { asNumber, Id, Json, JsonValue, OneOrMore, PageOptions, Text } from '../types';
2
2
  import { ifDefined } from '../utils';
3
3
 
4
4
  export class Req implements Omit<PageOptions, 'sort'> {
5
- constructor(readonly path: Json = {}, readonly query: Json = {}, readonly body: unknown) {}
5
+ readonly skip = ifDefined(this.query?.skip, asNumber(this.query?.skip));
6
+ readonly take = ifDefined(this.query?.take, asNumber(this.query?.take));
7
+
8
+ constructor(readonly path: Json = {}, readonly query: Json = {}, readonly body: unknown, readonly headers: Record<string, OneOrMore<string>>) {
9
+ }
6
10
 
7
11
  get id(): Id {
8
12
  return this.get('id');
@@ -12,11 +16,13 @@ export class Req implements Omit<PageOptions, 'sort'> {
12
16
  return this.get('q');
13
17
  }
14
18
 
15
- readonly skip = ifDefined(this.query?.skip, asNumber(this.query?.skip));
16
- readonly take = ifDefined(this.query?.take, asNumber(this.query?.take));
17
-
18
19
  get = (key: Text): any => this.path[key.toString()] ?? this.query[key.toString()];
19
20
  }
20
21
 
21
- export const toReq = (req: { params?: { id?: unknown }; query?: { q?: unknown }; body?: unknown }): Req =>
22
- new Req(req.params as Json, req.query as Json, req.body as Json);
22
+ export const toReq = (req: {
23
+ params?: { id?: unknown };
24
+ query?: { q?: unknown };
25
+ body?: unknown;
26
+ headers?: unknown
27
+ }): Req =>
28
+ new Req(req.params as Json, req.query as Json, req.body as Json, req.headers as Record<string, OneOrMore<string>>);