@tramvai/module-server 5.49.1 → 6.59.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.
package/README.md CHANGED
@@ -26,7 +26,7 @@ createApp({
26
26
 
27
27
  ### Processing the users requests
28
28
 
29
- `ServerModule` creates [express.js](https://expressjs.com/) application, handles user requests, runs [commandLineRunner](concepts/command-line-runner.md), and sends responses to users with data, headers and status from `RESPONSE_MANAGER_TOKEN` token.
29
+ `ServerModule` creates [fastify.js](https://fastify.dev/) application, handles user requests, runs [commandLineRunner](concepts/command-line-runner.md), and sends responses to users with data, headers and status from `RESPONSE_MANAGER_TOKEN` token.
30
30
 
31
31
  ### Request proxying
32
32
 
@@ -42,7 +42,7 @@ To enable proxying, create a file `proxy.conf.js` or `proxy.conf.json` in the ro
42
42
  const testStand = 'https://example.org';
43
43
 
44
44
  module.exports = {
45
- // The key is the path pattern for the `express` to be passed to `app.use`
45
+ // The key is the path pattern for the `fastify` to be passed to `app.use`
46
46
  // value can be a string, in order to proxy all urls starting with `/login/`
47
47
  '/login/': testStand,
48
48
  // or can be a config object for [http-proxy](https://github.com/chimurai/http-proxy-middleware#http-proxy-options)
@@ -115,7 +115,7 @@ Module will not serve the newly added file on the filesystem, works only for all
115
115
 
116
116
  ### PAPI
117
117
 
118
- Papi - API routes for the `tramvai` application. More information is available in [Papi](03-features/016-papi.md)
118
+ Papi - API routes for the `tramvai` application. More information is available in [Papi](03-features/017-papi.md)
119
119
 
120
120
  ### Emulation of network/backends problems in the application
121
121
 
@@ -10,10 +10,8 @@ import http from 'http';
10
10
  import https from 'https';
11
11
 
12
12
  class Interceptor {
13
- constructor() {
14
- this.intercepted = false;
15
- this.delay = 0;
16
- }
13
+ intercepted = false;
14
+ delay = 0;
17
15
  setIntercept(intercept) {
18
16
  this.intercepted = intercept;
19
17
  }
@@ -20,10 +20,8 @@ var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
20
20
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
21
21
 
22
22
  class Interceptor {
23
- constructor() {
24
- this.intercepted = false;
25
- this.delay = 0;
26
- }
23
+ intercepted = false;
24
+ delay = 0;
27
25
  setIntercept(intercept) {
28
26
  this.intercepted = intercept;
29
27
  }
@@ -1,6 +1,9 @@
1
1
  class EarlyHintsManager {
2
+ sentHints = new Set();
3
+ response;
4
+ resourcesRegistry;
5
+ earlyHintsEnabled;
2
6
  constructor(payload) {
3
- this.sentHints = new Set();
4
7
  this.response = payload.response;
5
8
  this.resourcesRegistry = payload.resourcesRegistry;
6
9
  this.earlyHintsEnabled = payload.earlyHintsEnabled;
@@ -3,8 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  class EarlyHintsManager {
6
+ sentHints = new Set();
7
+ response;
8
+ resourcesRegistry;
9
+ earlyHintsEnabled;
6
10
  constructor(payload) {
7
- this.sentHints = new Set();
8
11
  this.response = payload.response;
9
12
  this.resourcesRegistry = payload.resourcesRegistry;
10
13
  this.earlyHintsEnabled = payload.earlyHintsEnabled;
@@ -1,9 +1,7 @@
1
1
  class ServerResponseTaskManager {
2
- constructor() {
3
- this.tasks = [];
4
- this.processedTasks = [];
5
- this.status = 'idle';
6
- }
2
+ tasks = [];
3
+ processedTasks = [];
4
+ status = 'idle';
7
5
  push(task) {
8
6
  if (this.status === 'closed') {
9
7
  return;
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  class ServerResponseTaskManager {
6
- constructor() {
7
- this.tasks = [];
8
- this.processedTasks = [];
9
- this.status = 'idle';
10
- }
6
+ tasks = [];
7
+ processedTasks = [];
8
+ status = 'idle';
11
9
  push(task) {
12
10
  if (this.status === 'closed') {
13
11
  return;
@@ -122,8 +122,9 @@ const webAppInitCommand = ({ app, logger, commandLineRunner, executionContextMan
122
122
  });
123
123
  }
124
124
  catch (err) {
125
- if (err.di) {
126
- const responseManager = err.di.get(RESPONSE_MANAGER_TOKEN);
125
+ const storage = asyncLocalStorage.getStore();
126
+ if (storage && storage.tramvaiRequestDi) {
127
+ const responseManager = storage.tramvaiRequestDi.get(RESPONSE_MANAGER_TOKEN);
127
128
  if (responseManager && !reply.sent) {
128
129
  reply.headers(responseManager.getHeaders());
129
130
  }
@@ -131,8 +131,9 @@ const webAppInitCommand = ({ app, logger, commandLineRunner, executionContextMan
131
131
  });
132
132
  }
133
133
  catch (err) {
134
- if (err.di) {
135
- const responseManager = err.di.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
134
+ const storage = asyncLocalStorage.getStore();
135
+ if (storage && storage.tramvaiRequestDi) {
136
+ const responseManager = storage.tramvaiRequestDi.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
136
137
  if (responseManager && !reply.sent) {
137
138
  reply.headers(responseManager.getHeaders());
138
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-server",
3
- "version": "5.49.1",
3
+ "version": "6.59.0",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -21,37 +21,37 @@
21
21
  "watch": "tsc -w"
22
22
  },
23
23
  "dependencies": {
24
- "afterframe": "^1.0.2",
25
- "@tinkoff/errors": "0.6.2",
26
- "@tinkoff/monkeypatch": "5.0.2",
27
- "@tinkoff/terminus": "0.4.2",
28
- "@tinkoff/url": "0.11.2",
29
- "@tramvai/module-cache-warmup": "5.49.1",
30
- "@tramvai/module-metrics": "5.49.1",
31
- "@tramvai/papi": "5.49.1",
32
- "@tramvai/tokens-server": "5.49.1",
33
- "@tramvai/tokens-router": "5.49.1",
34
- "@tramvai/tokens-server-private": "5.49.1",
35
- "@tramvai/safe-strings": "0.8.4",
36
- "fastify": "^4.14.1",
37
- "@fastify/cookie": "^8.3.0",
38
24
  "@fastify/compress": "^6.2.0",
25
+ "@fastify/cookie": "^8.3.0",
39
26
  "@fastify/formbody": "^7.4.0",
40
27
  "@fastify/static": "^6.9.0",
41
28
  "@loadable/server": "^5.15.0",
29
+ "@tinkoff/errors": "0.7.1",
30
+ "@tinkoff/monkeypatch": "6.0.0",
31
+ "@tinkoff/terminus": "0.5.1",
32
+ "@tinkoff/url": "0.12.1",
33
+ "@tramvai/module-cache-warmup": "6.59.0",
34
+ "@tramvai/module-metrics": "6.59.0",
35
+ "@tramvai/papi": "6.59.0",
36
+ "@tramvai/safe-strings": "0.9.0",
37
+ "@tramvai/tokens-router": "6.59.0",
38
+ "@tramvai/tokens-server": "6.59.0",
39
+ "@tramvai/tokens-server-private": "6.59.0",
40
+ "afterframe": "^1.0.2",
41
+ "fastify": "^4.14.1",
42
42
  "http-proxy-middleware": "^2.0.2"
43
43
  },
44
44
  "peerDependencies": {
45
- "@tinkoff/dippy": "0.11.4",
45
+ "@tinkoff/dippy": "0.12.3",
46
46
  "@tinkoff/utils": "^2.1.2",
47
- "@tramvai/cli": "5.49.1",
48
- "@tramvai/core": "5.49.1",
49
- "@tramvai/react": "5.49.1",
50
- "@tramvai/module-common": "5.49.1",
51
- "@tramvai/module-environment": "5.49.1",
52
- "@tramvai/tokens-common": "5.49.1",
53
- "@tramvai/tokens-core-private": "5.49.1",
54
- "@tramvai/tokens-render": "5.49.1",
47
+ "@tramvai/cli": "6.59.0",
48
+ "@tramvai/core": "6.59.0",
49
+ "@tramvai/module-common": "6.59.0",
50
+ "@tramvai/module-environment": "6.59.0",
51
+ "@tramvai/react": "6.59.0",
52
+ "@tramvai/tokens-common": "6.59.0",
53
+ "@tramvai/tokens-core-private": "6.59.0",
54
+ "@tramvai/tokens-render": "6.59.0",
55
55
  "react": ">=16.14.0",
56
56
  "react-dom": ">=16.14.0",
57
57
  "tslib": "^2.4.0"