@tramvai/module-router 1.91.1 → 1.92.3
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 +8 -7
- package/lib/index.js +7 -6
- package/package.json +15 -15
package/lib/index.es.js
CHANGED
|
@@ -15,7 +15,7 @@ import replace from '@tinkoff/utils/string/replace';
|
|
|
15
15
|
import { jsx } from 'react/jsx-runtime';
|
|
16
16
|
import { isFileSystemPageComponent, fileSystemPagesEnabled, getStaticFileSystemPages, fileSystemPageToRoute } from '@tramvai/experiments';
|
|
17
17
|
import uniq from '@tinkoff/utils/array/uniq';
|
|
18
|
-
import { isRedirectFoundError, isNotFoundError,
|
|
18
|
+
import { isRedirectFoundError, isNotFoundError, RedirectFoundError, makeErrorSilent, HttpError } from '@tinkoff/errors';
|
|
19
19
|
import { SERVER_MODULE_PAPI_PUBLIC_ROUTE } from '@tramvai/tokens-server';
|
|
20
20
|
import prop from '@tinkoff/utils/object/prop';
|
|
21
21
|
import { createPapiMethod } from '@tramvai/papi';
|
|
@@ -501,29 +501,30 @@ const serverHooks = [
|
|
|
501
501
|
|
|
502
502
|
const routerOptions = ({ requestManager, responseManager, }) => {
|
|
503
503
|
const getUrl = (navigation) => { var _a, _b; return (_b = (_a = navigation.url) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : requestManager.getUrl(); };
|
|
504
|
-
const throwError = ({ defaultStatus, url
|
|
504
|
+
const throwError = ({ defaultStatus, url }) => {
|
|
505
505
|
const error = new HttpError({
|
|
506
506
|
url,
|
|
507
507
|
httpStatus: responseManager.getStatus() >= 300 ? responseManager.getStatus() : defaultStatus,
|
|
508
508
|
});
|
|
509
|
-
|
|
510
|
-
makeErrorSilent(error);
|
|
511
|
-
}
|
|
509
|
+
makeErrorSilent(error);
|
|
512
510
|
throw error;
|
|
513
511
|
};
|
|
514
512
|
return {
|
|
515
513
|
onNotFound: async (navigation) => {
|
|
516
514
|
// isSilent is used to prevent command line error logs,
|
|
517
515
|
// because 404 errors is expected behavior
|
|
518
|
-
throwError({ defaultStatus: 404, url: getUrl(navigation)
|
|
516
|
+
throwError({ defaultStatus: 404, url: getUrl(navigation) });
|
|
519
517
|
},
|
|
520
518
|
onRedirect: async (navigation) => {
|
|
521
519
|
const { fromUrl, url, code } = navigation;
|
|
522
|
-
|
|
520
|
+
const error = new RedirectFoundError({
|
|
523
521
|
url: getUrl(navigation),
|
|
524
522
|
nextUrl: fromUrl.origin !== url.origin ? url.href : url.path,
|
|
525
523
|
httpStatus: code,
|
|
524
|
+
silent: true,
|
|
526
525
|
});
|
|
526
|
+
makeErrorSilent(error);
|
|
527
|
+
throw error;
|
|
527
528
|
},
|
|
528
529
|
onBlock: async (navigation) => {
|
|
529
530
|
throwError({ defaultStatus: 500, url: getUrl(navigation) });
|
package/lib/index.js
CHANGED
|
@@ -512,29 +512,30 @@ const serverHooks = [
|
|
|
512
512
|
|
|
513
513
|
const routerOptions = ({ requestManager, responseManager, }) => {
|
|
514
514
|
const getUrl = (navigation) => { var _a, _b; return (_b = (_a = navigation.url) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : requestManager.getUrl(); };
|
|
515
|
-
const throwError = ({ defaultStatus, url
|
|
515
|
+
const throwError = ({ defaultStatus, url }) => {
|
|
516
516
|
const error = new errors.HttpError({
|
|
517
517
|
url,
|
|
518
518
|
httpStatus: responseManager.getStatus() >= 300 ? responseManager.getStatus() : defaultStatus,
|
|
519
519
|
});
|
|
520
|
-
|
|
521
|
-
errors.makeErrorSilent(error);
|
|
522
|
-
}
|
|
520
|
+
errors.makeErrorSilent(error);
|
|
523
521
|
throw error;
|
|
524
522
|
};
|
|
525
523
|
return {
|
|
526
524
|
onNotFound: async (navigation) => {
|
|
527
525
|
// isSilent is used to prevent command line error logs,
|
|
528
526
|
// because 404 errors is expected behavior
|
|
529
|
-
throwError({ defaultStatus: 404, url: getUrl(navigation)
|
|
527
|
+
throwError({ defaultStatus: 404, url: getUrl(navigation) });
|
|
530
528
|
},
|
|
531
529
|
onRedirect: async (navigation) => {
|
|
532
530
|
const { fromUrl, url, code } = navigation;
|
|
533
|
-
errors.
|
|
531
|
+
const error = new errors.RedirectFoundError({
|
|
534
532
|
url: getUrl(navigation),
|
|
535
533
|
nextUrl: fromUrl.origin !== url.origin ? url.href : url.path,
|
|
536
534
|
httpStatus: code,
|
|
535
|
+
silent: true,
|
|
537
536
|
});
|
|
537
|
+
errors.makeErrorSilent(error);
|
|
538
|
+
throw error;
|
|
538
539
|
},
|
|
539
540
|
onBlock: async (navigation) => {
|
|
540
541
|
throwError({ defaultStatus: 500, url: getUrl(navigation) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.92.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"@tinkoff/errors": "0.2.20",
|
|
26
26
|
"@tinkoff/router": "0.1.72",
|
|
27
27
|
"@tinkoff/url": "0.7.37",
|
|
28
|
-
"@tramvai/tokens-child-app": "1.
|
|
29
|
-
"@tramvai/tokens-render": "1.
|
|
30
|
-
"@tramvai/tokens-router": "1.
|
|
31
|
-
"@tramvai/tokens-server": "1.
|
|
32
|
-
"@tramvai/experiments": "1.
|
|
28
|
+
"@tramvai/tokens-child-app": "1.92.3",
|
|
29
|
+
"@tramvai/tokens-render": "1.92.3",
|
|
30
|
+
"@tramvai/tokens-router": "1.92.3",
|
|
31
|
+
"@tramvai/tokens-server": "1.92.3",
|
|
32
|
+
"@tramvai/experiments": "1.92.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@tinkoff/utils": "^2.1.2",
|
|
36
|
-
"@tramvai/cli": "1.
|
|
37
|
-
"@tramvai/core": "1.
|
|
38
|
-
"@tramvai/module-log": "1.
|
|
39
|
-
"@tramvai/module-server": "1.
|
|
40
|
-
"@tramvai/papi": "1.
|
|
41
|
-
"@tramvai/state": "1.
|
|
42
|
-
"@tramvai/test-helpers": "1.
|
|
43
|
-
"@tramvai/test-mocks": "1.
|
|
44
|
-
"@tramvai/tokens-common": "1.
|
|
36
|
+
"@tramvai/cli": "1.92.3",
|
|
37
|
+
"@tramvai/core": "1.92.3",
|
|
38
|
+
"@tramvai/module-log": "1.92.3",
|
|
39
|
+
"@tramvai/module-server": "1.92.3",
|
|
40
|
+
"@tramvai/papi": "1.92.3",
|
|
41
|
+
"@tramvai/state": "1.92.3",
|
|
42
|
+
"@tramvai/test-helpers": "1.92.3",
|
|
43
|
+
"@tramvai/test-mocks": "1.92.3",
|
|
44
|
+
"@tramvai/tokens-common": "1.92.3",
|
|
45
45
|
"@tinkoff/dippy": "0.7.39",
|
|
46
46
|
"react": "*",
|
|
47
47
|
"tslib": "^2.0.3"
|