@tramvai/module-router 1.46.10 → 1.48.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.es.js +3 -1
- package/lib/index.js +3 -1
- package/lib/modules/tokens/server/routerOptions.d.ts +4 -3
- package/package.json +16 -16
package/lib/index.es.js
CHANGED
|
@@ -491,7 +491,7 @@ const serverHooks = [
|
|
|
491
491
|
},
|
|
492
492
|
];
|
|
493
493
|
|
|
494
|
-
const routerOptions = ({ responseManager, }) => {
|
|
494
|
+
const routerOptions = ({ requestManager, responseManager, }) => {
|
|
495
495
|
const throwError = (defaultStatus) => {
|
|
496
496
|
return throwHttpError({
|
|
497
497
|
httpStatus: responseManager.getStatus() >= 300 ? responseManager.getStatus() : defaultStatus,
|
|
@@ -511,6 +511,7 @@ const routerOptions = ({ responseManager, }) => {
|
|
|
511
511
|
onBlock: async () => {
|
|
512
512
|
throwError(500);
|
|
513
513
|
},
|
|
514
|
+
defaultRedirectCode: requestManager.getMethod() === 'GET' ? 301 : 308,
|
|
514
515
|
};
|
|
515
516
|
};
|
|
516
517
|
|
|
@@ -541,6 +542,7 @@ const serverTokens = [
|
|
|
541
542
|
provide: additionalRouterParameters,
|
|
542
543
|
useFactory: routerOptions,
|
|
543
544
|
deps: {
|
|
545
|
+
requestManager: REQUEST_MANAGER_TOKEN,
|
|
544
546
|
responseManager: RESPONSE_MANAGER_TOKEN,
|
|
545
547
|
},
|
|
546
548
|
},
|
package/lib/index.js
CHANGED
|
@@ -503,7 +503,7 @@ const serverHooks = [
|
|
|
503
503
|
},
|
|
504
504
|
];
|
|
505
505
|
|
|
506
|
-
const routerOptions = ({ responseManager, }) => {
|
|
506
|
+
const routerOptions = ({ requestManager, responseManager, }) => {
|
|
507
507
|
const throwError = (defaultStatus) => {
|
|
508
508
|
return errors.throwHttpError({
|
|
509
509
|
httpStatus: responseManager.getStatus() >= 300 ? responseManager.getStatus() : defaultStatus,
|
|
@@ -523,6 +523,7 @@ const routerOptions = ({ responseManager, }) => {
|
|
|
523
523
|
onBlock: async () => {
|
|
524
524
|
throwError(500);
|
|
525
525
|
},
|
|
526
|
+
defaultRedirectCode: requestManager.getMethod() === 'GET' ? 301 : 308,
|
|
526
527
|
};
|
|
527
528
|
};
|
|
528
529
|
|
|
@@ -553,6 +554,7 @@ const serverTokens = [
|
|
|
553
554
|
provide: additionalRouterParameters,
|
|
554
555
|
useFactory: routerOptions,
|
|
555
556
|
deps: {
|
|
557
|
+
requestManager: tokensCommon.REQUEST_MANAGER_TOKEN,
|
|
556
558
|
responseManager: tokensCommon.RESPONSE_MANAGER_TOKEN,
|
|
557
559
|
},
|
|
558
560
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { RESPONSE_MANAGER_TOKEN } from '@tramvai/tokens-common';
|
|
1
|
+
import type { REQUEST_MANAGER_TOKEN, RESPONSE_MANAGER_TOKEN } from '@tramvai/tokens-common';
|
|
2
2
|
import type { Router } from '@tinkoff/router';
|
|
3
|
-
declare type RouterOptions = Pick<ConstructorParameters<typeof Router>[0], 'onRedirect' | 'onNotFound' | 'onBlock'>;
|
|
4
|
-
export declare const routerOptions: ({ responseManager, }: {
|
|
3
|
+
declare type RouterOptions = Pick<ConstructorParameters<typeof Router>[0], 'onRedirect' | 'onNotFound' | 'onBlock' | 'defaultRedirectCode'>;
|
|
4
|
+
export declare const routerOptions: ({ requestManager, responseManager, }: {
|
|
5
|
+
requestManager: typeof REQUEST_MANAGER_TOKEN;
|
|
5
6
|
responseManager: typeof RESPONSE_MANAGER_TOKEN;
|
|
6
7
|
}) => RouterOptions;
|
|
7
8
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git@github.com:
|
|
17
|
+
"url": "git@github.com:Tinkoff/tramvai.git"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tramvai-build --for-publish",
|
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@tinkoff/errors": "0.2.18",
|
|
26
|
-
"@tinkoff/router": "0.1.
|
|
26
|
+
"@tinkoff/router": "0.1.65",
|
|
27
27
|
"@tinkoff/url": "0.7.37",
|
|
28
|
-
"@tramvai/tokens-render": "1.
|
|
29
|
-
"@tramvai/tokens-router": "1.
|
|
30
|
-
"@tramvai/tokens-server": "1.
|
|
31
|
-
"@tramvai/experiments": "1.
|
|
28
|
+
"@tramvai/tokens-render": "1.48.2",
|
|
29
|
+
"@tramvai/tokens-router": "1.48.2",
|
|
30
|
+
"@tramvai/tokens-server": "1.48.2",
|
|
31
|
+
"@tramvai/experiments": "1.48.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@tinkoff/utils": "^2.1.2",
|
|
35
|
-
"@tramvai/cli": "1.
|
|
36
|
-
"@tramvai/core": "1.
|
|
37
|
-
"@tramvai/module-log": "1.
|
|
38
|
-
"@tramvai/module-server": "1.
|
|
39
|
-
"@tramvai/papi": "1.
|
|
40
|
-
"@tramvai/state": "1.
|
|
41
|
-
"@tramvai/test-helpers": "1.
|
|
42
|
-
"@tramvai/test-mocks": "1.
|
|
43
|
-
"@tramvai/tokens-common": "1.
|
|
35
|
+
"@tramvai/cli": "1.48.2",
|
|
36
|
+
"@tramvai/core": "1.48.2",
|
|
37
|
+
"@tramvai/module-log": "1.48.2",
|
|
38
|
+
"@tramvai/module-server": "1.48.2",
|
|
39
|
+
"@tramvai/papi": "1.48.2",
|
|
40
|
+
"@tramvai/state": "1.48.2",
|
|
41
|
+
"@tramvai/test-helpers": "1.48.2",
|
|
42
|
+
"@tramvai/test-mocks": "1.48.2",
|
|
43
|
+
"@tramvai/tokens-common": "1.48.2",
|
|
44
44
|
"@tinkoff/dippy": "0.7.36",
|
|
45
45
|
"react": "*",
|
|
46
46
|
"tslib": "^2.0.3"
|