-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (26 loc) · 999 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Import the JongRouter class
import JongRouter, { IRoute } from './src/jong-router';
import { authencationGuard, sessionGuard } from './src/guard';
// Configurable variables
const routes: IRoute[] = [
{ pattern: '/nestedroutes/c1', component: import('./samples/nestedroutes/sample-nestedroutes') },
{ pattern: '/tryguard1/:teamId',
component: import('./src/team-component'),
guards: [authencationGuard, sessionGuard],
redirect: '/login'
},
{ pattern: '/tryguard2/:teamId',
component: import('./src/team-component'),
redirect: '/login'
},
{ pattern: '/login', html: ` Pls login first! `},
{ pattern: '/profile/:username',
component: import('./src/profile-component'),
data: { abc: 1}
},
{ pattern: '**', html: ` Page not found!` }
];
// Create an instance of the WebComponentsRouter class
const router = new JongRouter(routes, document.getElementById('app')!);
// Initialize the router
router.init();