@tramvai/tokens-server-private 2.134.0 → 2.139.2

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/lib/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { Server } from 'http';
3
4
  import type { FastifyError, FastifyInstance, FastifyReply, FastifyRequest as OriginalFastifyRequest } from 'fastify';
4
5
  import type { Papi } from '@tramvai/papi';
6
+ import type { Duplex } from 'stream';
5
7
  type FastifyRequest = OriginalFastifyRequest & {
6
8
  cookies: Record<string, string>;
7
9
  };
@@ -21,6 +23,27 @@ export declare const FASTIFY_REQUEST: OriginalFastifyRequest<import("fastify").R
21
23
  export declare const FASTIFY_RESPONSE: FastifyReply<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown> & {
22
24
  __type?: "base token" | undefined;
23
25
  };
26
+ /**
27
+ * @description
28
+ * Read/Write stream, will be passed to FASTIFY_RESPONSE, method .send()
29
+ * https://lirantal.com/blog/avoid-fastify-reply-raw-and-reply-hijack-despite-being-a-powerful-http-streams-tool/
30
+ */
31
+ export declare const SERVER_RESPONSE_STREAM: Duplex & {
32
+ __type?: "base token" | undefined;
33
+ };
34
+ export type ServerResponseTask = () => Promise<any>;
35
+ export interface ServerResponseTaskManager {
36
+ push(task: ServerResponseTask): void;
37
+ processQueue(): void;
38
+ closeQueue(): Promise<any>;
39
+ }
40
+ /**
41
+ * @description
42
+ * Response stream to client will not be closed before all tasks in queue will be processed
43
+ */
44
+ export declare const SERVER_RESPONSE_TASK_MANAGER: ServerResponseTaskManager & {
45
+ __type?: "base token" | undefined;
46
+ };
24
47
  /**
25
48
  * @description
26
49
  * Creates new server instance
package/lib/index.es.js CHANGED
@@ -10,6 +10,17 @@ const FASTIFY_REQUEST = createToken('fastify request');
10
10
  * Direct reference to response object
11
11
  */
12
12
  const FASTIFY_RESPONSE = createToken('fastify response');
13
+ /**
14
+ * @description
15
+ * Read/Write stream, will be passed to FASTIFY_RESPONSE, method .send()
16
+ * https://lirantal.com/blog/avoid-fastify-reply-raw-and-reply-hijack-despite-being-a-powerful-http-streams-tool/
17
+ */
18
+ const SERVER_RESPONSE_STREAM = createToken('tramvai server response stream');
19
+ /**
20
+ * @description
21
+ * Response stream to client will not be closed before all tasks in queue will be processed
22
+ */
23
+ const SERVER_RESPONSE_TASK_MANAGER = createToken('tramvai server response task manager');
13
24
  /**
14
25
  * @description
15
26
  * Creates new server instance
@@ -89,4 +100,4 @@ const PAPI_FASTIFY_INIT_TOKEN = createToken('papi fastify init', {
89
100
  multi: true,
90
101
  });
91
102
 
92
- export { EARLY_HINTS_MANAGER_TOKEN, FASTIFY_REQUEST, FASTIFY_RESPONSE, PAPI_EXECUTOR, PAPI_FASTIFY_INIT_TOKEN, SERVER_FACTORY_TOKEN, UTILITY_SERVER_TOKEN, UTILITY_WEB_FASTIFY_APP_TOKEN, WEB_FASTIFY_APP_AFTER_ERROR_TOKEN, WEB_FASTIFY_APP_AFTER_INIT_TOKEN, WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN, WEB_FASTIFY_APP_BEFORE_INIT_TOKEN, WEB_FASTIFY_APP_FACTORY_TOKEN, WEB_FASTIFY_APP_INIT_TOKEN, WEB_FASTIFY_APP_LIMITER_TOKEN, WEB_FASTIFY_APP_METRICS_TOKEN, WEB_FASTIFY_APP_TOKEN };
103
+ export { EARLY_HINTS_MANAGER_TOKEN, FASTIFY_REQUEST, FASTIFY_RESPONSE, PAPI_EXECUTOR, PAPI_FASTIFY_INIT_TOKEN, SERVER_FACTORY_TOKEN, SERVER_RESPONSE_STREAM, SERVER_RESPONSE_TASK_MANAGER, UTILITY_SERVER_TOKEN, UTILITY_WEB_FASTIFY_APP_TOKEN, WEB_FASTIFY_APP_AFTER_ERROR_TOKEN, WEB_FASTIFY_APP_AFTER_INIT_TOKEN, WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN, WEB_FASTIFY_APP_BEFORE_INIT_TOKEN, WEB_FASTIFY_APP_FACTORY_TOKEN, WEB_FASTIFY_APP_INIT_TOKEN, WEB_FASTIFY_APP_LIMITER_TOKEN, WEB_FASTIFY_APP_METRICS_TOKEN, WEB_FASTIFY_APP_TOKEN };
package/lib/index.js CHANGED
@@ -14,6 +14,17 @@ const FASTIFY_REQUEST = dippy.createToken('fastify request');
14
14
  * Direct reference to response object
15
15
  */
16
16
  const FASTIFY_RESPONSE = dippy.createToken('fastify response');
17
+ /**
18
+ * @description
19
+ * Read/Write stream, will be passed to FASTIFY_RESPONSE, method .send()
20
+ * https://lirantal.com/blog/avoid-fastify-reply-raw-and-reply-hijack-despite-being-a-powerful-http-streams-tool/
21
+ */
22
+ const SERVER_RESPONSE_STREAM = dippy.createToken('tramvai server response stream');
23
+ /**
24
+ * @description
25
+ * Response stream to client will not be closed before all tasks in queue will be processed
26
+ */
27
+ const SERVER_RESPONSE_TASK_MANAGER = dippy.createToken('tramvai server response task manager');
17
28
  /**
18
29
  * @description
19
30
  * Creates new server instance
@@ -99,6 +110,8 @@ exports.FASTIFY_RESPONSE = FASTIFY_RESPONSE;
99
110
  exports.PAPI_EXECUTOR = PAPI_EXECUTOR;
100
111
  exports.PAPI_FASTIFY_INIT_TOKEN = PAPI_FASTIFY_INIT_TOKEN;
101
112
  exports.SERVER_FACTORY_TOKEN = SERVER_FACTORY_TOKEN;
113
+ exports.SERVER_RESPONSE_STREAM = SERVER_RESPONSE_STREAM;
114
+ exports.SERVER_RESPONSE_TASK_MANAGER = SERVER_RESPONSE_TASK_MANAGER;
102
115
  exports.UTILITY_SERVER_TOKEN = UTILITY_SERVER_TOKEN;
103
116
  exports.UTILITY_WEB_FASTIFY_APP_TOKEN = UTILITY_WEB_FASTIFY_APP_TOKEN;
104
117
  exports.WEB_FASTIFY_APP_AFTER_ERROR_TOKEN = WEB_FASTIFY_APP_AFTER_ERROR_TOKEN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/tokens-server-private",
3
- "version": "2.134.0",
3
+ "version": "2.139.2",
4
4
  "description": "Tramvai private tokens for @tramvai/module-server",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.es.js",
@@ -18,7 +18,7 @@
18
18
  "watch": "tsc -w"
19
19
  },
20
20
  "dependencies": {
21
- "@tramvai/papi": "2.134.0"
21
+ "@tramvai/papi": "2.139.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@tinkoff/dippy": "0.8.15",