@@ -54,16 +54,16 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
54
54
## Prerequisites
55
55
56
56
- [ ` npm ` ] ( https://docs.npmjs.com/downloading-and-installing-node-js-and-npm )
57
- - [ ` Java 21+ ` ] ( https://www.oracle.com/java/technologies/downloads/#java21 )
58
- - Some containerization tool [ ` Docker ` ] ( https://www.docker.com/ ) , [ ` Podman ` ] ( https://podman.io/ ) , etc.
57
+ - [ ` Java 21 ` ] ( https://www.oracle.com/java/technologies/downloads/#java21 ) or higher;
58
+ - A containerization tool (e.g., [ ` Docker ` ] ( https://www.docker.com ) , [ ` Podman ` ] ( https://podman.io ) , etc.)
59
59
- [ ` jq ` ] ( https://jqlang.github.io/jq/ )
60
60
61
61
## Start Environment
62
62
63
63
- In a terminal, make sure you are inside the ` springboot-react-jwt-token ` root folder;
64
64
65
65
- Run the following command to start Docker Compose containers:
66
- ```
66
+ ``` bash
67
67
docker compose up -d
68
68
```
69
69
@@ -74,7 +74,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
74
74
- Open a terminal and navigate to the ` springboot-react-jwt-token/order-api ` folder;
75
75
76
76
- Run the following ` Maven ` command to start the application:
77
- ```
77
+ ``` bash
78
78
./mvnw clean spring-boot:run
79
79
```
80
80
@@ -83,12 +83,12 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
83
83
- Open another terminal and navigate to the ` springboot-react-jwt-token/order-ui` folder;
84
84
85
85
- Run the command below if you are running the application for the first time:
86
- ```
86
+ ` ` ` bash
87
87
npm install
88
88
` ` `
89
89
90
90
- Run the ` npm` command below to start the application:
91
- ```
91
+ ` ` ` bash
92
92
npm start
93
93
` ` `
94
94
@@ -120,12 +120,12 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
120
120
- Click ` POST /auth/authenticate` and then, click ` Try it out` button;
121
121
122
122
- Provide the ` user` credentials ` username` and ` password` :
123
- ```
123
+ ` ` ` json
124
124
{ " password" : " user" , " username" : " user" }
125
125
` ` `
126
126
127
127
- Click the ` Execute` button. It should return something like:
128
- ```
128
+ ` ` ` text
129
129
Code: 200
130
130
{ " accessToken" : " eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9..." }
131
131
` ` `
@@ -144,12 +144,12 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
144
144
- To create an order, click ` POST /api/orders` and then, click the ` Try it out` button;
145
145
146
146
- Provide the ` description` of the order:
147
- ```
147
+ ` ` ` json
148
148
{ " description" : " Buy two iPhones" }
149
149
` ` `
150
150
151
151
- Click the ` Execute` button. It should return something like:
152
- ```
152
+ ` ` ` text
153
153
Code: 200
154
154
{
155
155
" id" : " 718c9f40-5c06-4571-bc3e-3f888c52eff2" ,
@@ -164,48 +164,48 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
164
164
- Open a terminal;
165
165
166
166
- Call ` GET /public/numberOfUsers` :
167
- ```
167
+ ` ` ` bash
168
168
curl -i localhost:8080/public/numberOfUsers
169
169
` ` `
170
170
It should return:
171
- ```
171
+ ` ` ` text
172
172
HTTP/1.1 200
173
173
2
174
174
` ` `
175
175
176
176
- Call ` GET /api/orders` without JWT access token:
177
- ```
177
+ ` ` ` bash
178
178
curl -i localhost:8080/api/orders
179
179
` ` `
180
180
As for this endpoint a valid JWT access token is required, it should return:
181
- ```
181
+ ` ` ` text
182
182
HTTP/1.1 401
183
183
` ` `
184
184
185
185
- Call ` POST /auth/authenticate` to get the ` admin` JWT access token:
186
- ```
186
+ ` ` ` bash
187
187
ADMIN_ACCESS_TOKEN=" $( curl -s -X POST http://localhost:8080/auth/authenticate \
188
188
-H ' Content-Type: application/json' \
189
189
-d ' {"username": "admin", "password": "admin"}' | jq -r .accessToken) "
190
190
echo $ADMIN_ACCESS_TOKEN
191
191
` ` `
192
192
193
193
- Call ` GET /api/orders` again, now with the ` admin` JWT access token:
194
- ```
194
+ ` ` ` bash
195
195
curl -i -H " Authorization: Bearer $ADMIN_ACCESS_TOKEN " localhost:8080/api/orders
196
196
` ` `
197
197
It should return an empty array or an array with orders:
198
- ```
198
+ ` ` ` text
199
199
HTTP/1.1 200
200
200
[ ... ]
201
201
` ` `
202
202
203
203
- Call ` GET /api/users/me` to get more information about the ` admin` :
204
- ```
204
+ ` ` ` bash
205
205
curl -i -H " Authorization: Bearer $ADMIN_ACCESS_TOKEN " localhost:8080/api/users/me
206
206
` ` `
207
207
It should return:
208
- ```
208
+ ` ` ` text
209
209
HTTP/1.1 200
210
210
{
211
211
" id" : 1, " username" : " admin" , " name" : " Admin" , " email" : " admin@mycompany.com" , " role" : " ADMIN" ,
@@ -218,11 +218,11 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
218
218
- Open a terminal and make sure you are in the ` springboot-react-jwt-token` root folder;
219
219
220
220
- Run the following script:
221
- ```
221
+ ` ` ` bash
222
222
./order-api/test-endpoints.sh
223
223
` ` `
224
224
It should return something like the output below, where it shows the http code for different requests:
225
- ```
225
+ ` ` ` text
226
226
POST auth/authenticate
227
227
======================
228
228
admin access token
@@ -261,7 +261,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
261
261
# # Util Commands
262
262
263
263
- ** Postgres**
264
- ```
264
+ ` ` ` bash
265
265
docker exec -it postgres psql -U postgres -d orderdb
266
266
\d t
267
267
` ` `
@@ -275,7 +275,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
275
275
- To stop ` order-api` and ` order-ui` , go to the terminals where they are running and press ` Ctrl+C` ;
276
276
277
277
- To stop and remove Docker Compose containers, network, and volumes, go to a terminal and, inside the ` springboot-react-jwt-token` root folder, run the command below:
278
- ```
278
+ ` ` ` bash
279
279
docker compose down -v
280
280
` ` `
281
281
@@ -284,7 +284,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
284
284
- In a terminal, make sure you are in the ` springboot-react-jwt-token/order-ui` folder;
285
285
286
286
- Run the following commands:
287
- ```
287
+ ` ` ` bash
288
288
npm upgrade
289
289
npm i -g npm-check-updates
290
290
ncu -u
0 commit comments