Skip to content

Commit d24280c

Browse files
committed
Readme instructions writing
1 parent 32fc5b4 commit d24280c

10 files changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Table of contents
1919
* [Documentation](#documentation)
2020
* [Beginning](#beginning)
2121
* [Adding new route](#adding-new-route)
22+
* [Route authentication](#route-authentication)
2223
* [Calling routes](#calling-routes)
2324
* [Authors](#authors)
2425
* [Contributors](#contributors)
@@ -111,6 +112,50 @@ logRequestPaths # Live logging requested paths, can be disabled since consol
111112
Adding new route
112113
-----
113114

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+
114159

115160

116161

images/jwt_auth_1.PNG

2.71 KB
Loading

images/jwt_auth_2.PNG

2.07 KB
Loading

images/new_router_1.PNG

10.7 KB
Loading

images/new_router_2.PNG

3.71 KB
Loading

images/new_router_3.PNG

15.7 KB
Loading

images/new_router_4.PNG

3.66 KB
Loading

images/new_router_5.PNG

4.53 KB
Loading

images/new_router_6.PNG

4.73 KB
Loading

images/new_router_7.PNG

17.3 KB
Loading

0 commit comments

Comments
 (0)