@lwrjs/server 0.6.0-alpha.9 → 0.6.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.
@@ -27,6 +27,15 @@ var ExpressRequest = class {
27
27
  get query() {
28
28
  return this.req.query;
29
29
  }
30
+ get body() {
31
+ return this.req.body;
32
+ }
33
+ get method() {
34
+ return this.req.method;
35
+ }
36
+ get protocol() {
37
+ return this.req.protocol;
38
+ }
30
39
  get locale() {
31
40
  return this.req.locale;
32
41
  }
@@ -36,6 +45,14 @@ var ExpressRequest = class {
36
45
  acceptsLanguages() {
37
46
  return this.req.acceptsLanguages();
38
47
  }
48
+ get(field) {
49
+ return this.req.get(field);
50
+ }
51
+ cookie(key) {
52
+ const rawCookies = (this.req.headers.cookie?.split(";") || []).map((c) => c.trim());
53
+ const rawCookie = rawCookies.find((c) => c.startsWith(`${key}=`));
54
+ return rawCookie ? decodeURIComponent(rawCookie.replace(`${key}=`, "")) : void 0;
55
+ }
39
56
  hasJsonParam() {
40
57
  return this.req.query.json !== void 0;
41
58
  }
@@ -61,5 +61,9 @@ var ExpressResponse = class {
61
61
  this.res.type(type);
62
62
  return this;
63
63
  }
64
+ cookie(name, value, options) {
65
+ this.res.cookie(name, value, options);
66
+ return this;
67
+ }
64
68
  };
65
69
  var express_response_default = ExpressResponse;
@@ -43,5 +43,8 @@ var FsResponse = class {
43
43
  this.context.fs.type = type;
44
44
  return this;
45
45
  }
46
+ cookie(name, value, options) {
47
+ return this;
48
+ }
46
49
  };
47
50
  var fs_response_default = FsResponse;
@@ -27,6 +27,15 @@ var KoaRequest = class {
27
27
  get query() {
28
28
  return this.ctx.request.query;
29
29
  }
30
+ get protocol() {
31
+ return this.ctx.protocol;
32
+ }
33
+ get body() {
34
+ return this.ctx.body;
35
+ }
36
+ get method() {
37
+ return this.ctx.method;
38
+ }
30
39
  get locale() {
31
40
  return this.ctx.locale;
32
41
  }
@@ -39,6 +48,12 @@ var KoaRequest = class {
39
48
  acceptsLanguages() {
40
49
  return this.ctx.request.acceptsLanguages();
41
50
  }
51
+ get(field) {
52
+ return this.ctx.get(field);
53
+ }
54
+ cookie(key) {
55
+ return this.ctx.cookies.get(key);
56
+ }
42
57
  hasJsonParam() {
43
58
  return this.ctx.query.json !== void 0;
44
59
  }
@@ -78,5 +78,9 @@ var KoaResponse = class {
78
78
  this.ctx.type = type;
79
79
  return this;
80
80
  }
81
+ cookie(name, value, options) {
82
+ this.ctx.cookies.set(name, value, options);
83
+ return this;
84
+ }
81
85
  };
82
86
  var koa_response_default = KoaResponse;
@@ -8,9 +8,14 @@ export default class ExpressRequest implements MiddlewareRequest {
8
8
  get originalUrl(): string;
9
9
  get path(): string;
10
10
  get query(): any;
11
+ get body(): any;
12
+ get method(): string;
13
+ get protocol(): any;
11
14
  get locale(): string;
12
15
  set locale(l: string);
13
16
  acceptsLanguages(): string[];
17
+ get(field: string): string | undefined;
18
+ cookie(key: string): string | undefined;
14
19
  hasJsonParam(): boolean;
15
20
  isJsonRequest(): boolean;
16
21
  isSiteGeneration(): boolean;
@@ -15,6 +15,16 @@ export default class ExpressRequest {
15
15
  get query() {
16
16
  return this.req.query;
17
17
  }
18
+ get body() {
19
+ // requires body parsing middleware
20
+ return this.req.body;
21
+ }
22
+ get method() {
23
+ return this.req.method;
24
+ }
25
+ get protocol() {
26
+ return this.req.protocol;
27
+ }
18
28
  get locale() {
19
29
  return this.req.locale;
20
30
  }
@@ -24,6 +34,15 @@ export default class ExpressRequest {
24
34
  acceptsLanguages() {
25
35
  return this.req.acceptsLanguages();
26
36
  }
37
+ get(field) {
38
+ return this.req.get(field);
39
+ }
40
+ cookie(key) {
41
+ // Does not require the cookie-parser middleware
42
+ const rawCookies = (this.req.headers.cookie?.split(';') || []).map((c) => c.trim());
43
+ const rawCookie = rawCookies.find((c) => c.startsWith(`${key}=`));
44
+ return rawCookie ? decodeURIComponent(rawCookie.replace(`${key}=`, '')) : undefined;
45
+ }
27
46
  hasJsonParam() {
28
47
  return this.req.query.json !== undefined;
29
48
  }
@@ -15,5 +15,6 @@ export default class ExpressResponse implements MiddlewareResponse {
15
15
  sendStatus(httpCode: number): void;
16
16
  stream(stream: Readable): void;
17
17
  type(type: string): MiddlewareResponse;
18
+ cookie(name: string, value: string, options: any): MiddlewareResponse;
18
19
  }
19
20
  //# sourceMappingURL=express-response.d.ts.map
@@ -54,5 +54,10 @@ export default class ExpressResponse {
54
54
  this.res.type(type);
55
55
  return this;
56
56
  }
57
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
58
+ cookie(name, value, options) {
59
+ this.res.cookie(name, value, options);
60
+ return this;
61
+ }
57
62
  }
58
63
  //# sourceMappingURL=express-response.js.map
@@ -13,5 +13,6 @@ export default class FsResponse implements MiddlewareResponse {
13
13
  sendStatus(httpCode: number): void;
14
14
  stream(stream: Readable): void;
15
15
  type(type: string): MiddlewareResponse;
16
+ cookie(name: string, value: string, options: any): MiddlewareResponse;
16
17
  }
17
18
  //# sourceMappingURL=fs-response.d.ts.map
@@ -33,5 +33,9 @@ export default class FsResponse {
33
33
  this.context.fs.type = type;
34
34
  return this;
35
35
  }
36
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
37
+ cookie(name, value, options) {
38
+ return this;
39
+ }
36
40
  }
37
41
  //# sourceMappingURL=fs-response.js.map
@@ -8,10 +8,15 @@ export default class KoaRequest implements MiddlewareRequest {
8
8
  get originalUrl(): string;
9
9
  get path(): string;
10
10
  get query(): any;
11
+ get protocol(): any;
12
+ get body(): any;
13
+ get method(): string;
11
14
  get locale(): string;
12
15
  set locale(l: string);
13
16
  isSiteGeneration(): boolean;
14
17
  acceptsLanguages(): string[];
18
+ get(field: string): string | undefined;
19
+ cookie(key: string): string | undefined;
15
20
  hasJsonParam(): boolean;
16
21
  isJsonRequest(): boolean;
17
22
  validateJsonRequest(): boolean;
@@ -15,6 +15,15 @@ export default class KoaRequest {
15
15
  get query() {
16
16
  return this.ctx.request.query;
17
17
  }
18
+ get protocol() {
19
+ return this.ctx.protocol;
20
+ }
21
+ get body() {
22
+ return this.ctx.body;
23
+ }
24
+ get method() {
25
+ return this.ctx.method;
26
+ }
18
27
  get locale() {
19
28
  return this.ctx.locale;
20
29
  }
@@ -27,6 +36,12 @@ export default class KoaRequest {
27
36
  acceptsLanguages() {
28
37
  return this.ctx.request.acceptsLanguages();
29
38
  }
39
+ get(field) {
40
+ return this.ctx.get(field);
41
+ }
42
+ cookie(key) {
43
+ return this.ctx.cookies.get(key);
44
+ }
30
45
  hasJsonParam() {
31
46
  return this.ctx.query.json !== undefined;
32
47
  }
@@ -15,5 +15,6 @@ export default class KoaResponse implements MiddlewareResponse {
15
15
  sendStatus(httpCode: number): void;
16
16
  stream(stream: Readable): void;
17
17
  type(type: string): MiddlewareResponse;
18
+ cookie(name: string, value: string, options: any): MiddlewareResponse;
18
19
  }
19
20
  //# sourceMappingURL=koa-response.d.ts.map
@@ -55,5 +55,10 @@ export default class KoaResponse {
55
55
  this.ctx.type = type;
56
56
  return this;
57
57
  }
58
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
59
+ cookie(name, value, options) {
60
+ this.ctx.cookies.set(name, value, options);
61
+ return this;
62
+ }
58
63
  }
59
64
  //# sourceMappingURL=koa-response.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.0-alpha.9",
7
+ "version": "0.6.0",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "devDependencies": {
33
- "@lwrjs/types": "0.6.0-alpha.9",
33
+ "@lwrjs/types": "0.6.0",
34
34
  "@types/koa-compress": "^4.0.1",
35
35
  "@types/koa__router": "^8.0.4",
36
36
  "@types/spdy": "^3.4.4",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@koa/router": "^10.0.0",
41
- "@lwrjs/shared-utils": "0.6.0-alpha.9",
41
+ "@lwrjs/shared-utils": "0.6.0",
42
42
  "@types/express": "^4.17.11",
43
43
  "@types/koa": "^2.11.7",
44
44
  "express": "^4.17.1",
@@ -51,5 +51,5 @@
51
51
  "engines": {
52
52
  "node": ">=14.15.4 <17"
53
53
  },
54
- "gitHead": "9cb371a5d01ef345660138a48fe0b3f0119d0799"
54
+ "gitHead": "31769655f0155ad7e54cf37bccdf72d0baaf44ab"
55
55
  }