@@ -19,6 +19,7 @@ Table of contents
19
19
* [ Documentation] ( #documentation )
20
20
* [ Beginning] ( #beginning )
21
21
* [ Adding new route] ( #adding-new-route )
22
+ * [ Route authentication] ( #route-authentication )
22
23
* [ Calling routes] ( #calling-routes )
23
24
* [ Authors] ( #authors )
24
25
* [ Contributors] ( #contributors )
@@ -111,6 +112,50 @@ logRequestPaths # Live logging requested paths, can be disabled since consol
111
112
Adding new route
112
113
-----
113
114
115
+ Adding new router or route starts from ` /routes ` folder via copy paste existing router like ` ExampleRouter.ts `
116
+ to a new name like ` NewRouter.ts `
117
+
118
+ ![ 'NewRouter1'] ( ./images/new_router_1.PNG )
119
+
120
+ Then you need to create new component which has required method logic
121
+
122
+ ![ 'NewRouter2'] ( ./images/new_router_2.PNG )
123
+
124
+ Inside ` index.ts ` has again copy pasted content from Example component which is returning json result ok for post request
125
+
126
+ ![ 'NewRouter3'] ( ./images/new_router_3.PNG )
127
+
128
+ Now go to following index.ts file under ` /routes ` folder
129
+
130
+ ![ 'NewRouter4'] ( ./images/new_router_4.PNG )
131
+
132
+ At the routes index file you create base route for your new ` NewRouter ` route like this:
133
+
134
+ ![ 'NewRouter5'] ( ./images/new_router_5.PNG )
135
+
136
+ Also you need to import this ` NewRouter `
137
+
138
+ ![ 'NewRouter6'] ( ./images/new_router_6.PNG )
139
+
140
+ Since this is post method which was defined at ` NewRouter.ts ` , result will be for post request:
141
+
142
+ ![ 'NewRouter7'] ( ./images/new_router_7.PNG )
143
+
144
+
145
+
146
+ Route authentication
147
+ -----
148
+
149
+ See ` ExampleRouter.ts ` for good example how you can define part of route under authentication.
150
+ ![ 'JwtAuth1'] ( ./images/jwt_auth_1.PNG )
151
+
152
+ This means that you can access ` http:localhost:port/example ` without authentication and then define under this path
153
+ which components require authentication.
154
+
155
+ Or you define whole in this case ` http:localhost:port/new ` route requiring always authentication no matter
156
+ which method is called behind it.
157
+ ![ 'JwtAuth2'] ( ./images/jwt_auth_2.PNG )
158
+
114
159
115
160
116
161
0 commit comments