@azure-net/kit 3.0.1 → 3.0.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { error, type Page, type RequestEvent } from '@sveltejs/kit';
|
|
1
|
+
import { type BeforeNavigate, error, type Page, type RequestEvent } from '@sveltejs/kit';
|
|
2
2
|
import { UniversalCookie } from '../cookie/index.js';
|
|
3
3
|
type RedirectStatus = 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;
|
|
4
4
|
export type IMiddleware = (middlewareData: {
|
|
@@ -14,5 +14,6 @@ export type IMiddleware = (middlewareData: {
|
|
|
14
14
|
export declare const createMiddlewareManager: (middlewares: IMiddleware[]) => {
|
|
15
15
|
serverMiddleware: () => Promise<void>;
|
|
16
16
|
clientMiddleware: () => void;
|
|
17
|
+
executeMiddlewares: (navigation?: BeforeNavigate) => Promise<void>;
|
|
17
18
|
};
|
|
18
19
|
export {};
|
|
@@ -6,8 +6,10 @@ import { EnvironmentUtil } from 'azure-net-tools';
|
|
|
6
6
|
import { UniversalCookie } from '../cookie/index.js';
|
|
7
7
|
export const createMiddlewareManager = (middlewares) => {
|
|
8
8
|
const universalRedirect = (location, status = 301, navigation) => {
|
|
9
|
-
if (EnvironmentUtil.isBrowser
|
|
10
|
-
navigation
|
|
9
|
+
if (EnvironmentUtil.isBrowser) {
|
|
10
|
+
if (navigation) {
|
|
11
|
+
navigation?.cancel();
|
|
12
|
+
}
|
|
11
13
|
return goto(location);
|
|
12
14
|
}
|
|
13
15
|
else {
|
|
@@ -64,5 +66,5 @@ export const createMiddlewareManager = (middlewares) => {
|
|
|
64
66
|
await executeMiddlewares(navigation);
|
|
65
67
|
});
|
|
66
68
|
};
|
|
67
|
-
return { serverMiddleware, clientMiddleware };
|
|
69
|
+
return { serverMiddleware, clientMiddleware, executeMiddlewares };
|
|
68
70
|
};
|