@@ -62,7 +62,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
62
62
- In a terminal, make sure you are inside the ` springboot-react-basic-auth ` root folder;
63
63
64
64
- Run the following command to start docker compose containers:
65
- ```
65
+ ``` bash
66
66
docker compose up -d
67
67
```
68
68
@@ -73,7 +73,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
73
73
- Open a terminal and navigate to the ` springboot-react-basic-auth/book-api ` folder;
74
74
75
75
- Run the following ` Maven ` command to start the application:
76
- ```
76
+ ``` bash
77
77
./mvnw clean spring-boot:run
78
78
```
79
79
@@ -82,12 +82,12 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
82
82
- Open another terminal and navigate to the ` springboot-react-basic-auth/book-ui` folder;
83
83
84
84
- Run the command below if you are running the application for the first time:
85
- ```
85
+ ` ` ` bash
86
86
npm install
87
87
` ` `
88
88
89
89
- Run the ` npm` command below to start the application:
90
- ```
90
+ ` ` ` bash
91
91
npm start
92
92
` ` `
93
93
@@ -127,31 +127,31 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
127
127
- Open a terminal:
128
128
129
129
- Call ` GET /public/numberOfBooks` :
130
- ```
130
+ ` ` ` bash
131
131
curl -i localhost:8080/public/numberOfBooks
132
132
` ` `
133
133
It should return
134
- ```
134
+ ` ` ` text
135
135
HTTP/1.1 200
136
136
70
137
137
` ` `
138
138
139
139
- Call ` GET /api/books` without credentials:
140
- ```
140
+ ` ` ` bash
141
141
curl -i localhost:8080/api/books
142
142
` ` `
143
143
As this endpoint requires authentication, it should return:
144
- ```
144
+ ` ` ` text
145
145
HTTP/1.1 401
146
146
{ " timestamp" : " ..." , " status" : 401, " error" : " Unauthorized" , " message" : " Unauthorized" , " path" : " /api/books" }
147
147
` ` `
148
148
149
149
- Call again ` GET /api/books` but now with ` user` credentials:
150
- ```
150
+ ` ` ` bash
151
151
curl -i -u user:user localhost:8080/api/books
152
152
` ` `
153
153
It should return:
154
- ```
154
+ ` ` ` text
155
155
HTTP/1.1 200
156
156
[
157
157
{" isbn" :" 978-1-60309-445-0" ," title" :" A Shining Beacon" },
@@ -161,23 +161,23 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
161
161
` ` `
162
162
163
163
- Call ` POST /api/books` with ` user` credentials:
164
- ```
164
+ ` ` ` bash
165
165
curl -i -u user:user -X POST localhost:8080/api/books \
166
166
-H " Content-Type: application/json" -d ' {"isbn": "9781617292545", "title": "Spring Boot in Action"}'
167
167
` ` `
168
168
As ` user` doesn' t have the role `ADMIN`, it should return:
169
- ```
169
+ ```text
170
170
HTTP/1.1 403
171
171
{ "timestamp": "...", "status": 403, "error": "Forbidden", "message": "Forbidden", "path": "/api/books" }
172
172
```
173
173
174
174
- Call `POST /api/books` with `admin` credentials:
175
- ```
175
+ ```bash
176
176
curl -i -u admin:admin -X POST localhost:8080/api/books \
177
177
-H "Content-Type: application/json" -d ' {" isbn" : " 9781617292545" , " title" : " Spring Boot in Action" }'
178
178
```
179
179
It should return:
180
- ```
180
+ ```text
181
181
HTTP/1.1 201
182
182
{ "isbn":"9781617292545","title":"Spring Boot in Action" }
183
183
```
@@ -187,11 +187,11 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
187
187
- Open a terminal and make sure you are in the `springboot-react-basic-auth` root folder;
188
188
189
189
- Run the following script:
190
- ```
190
+ ```bash
191
191
./book-api/test-endpoints.sh
192
192
```
193
193
It should return something like the output below, where it shows the http code for different requests:
194
- ```
194
+ ```text
195
195
POST auth/authenticate
196
196
======================
197
197
admin Auth Resp: {"id":1,"name":"Admin","role":"ADMIN"}
@@ -226,7 +226,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
226
226
## Util Commands
227
227
228
228
- **Postgres**
229
- ```
229
+ ```bash
230
230
docker exec -it postgres psql -U postgres -d bookdb
231
231
\dt
232
232
```
@@ -236,7 +236,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
236
236
- To stop `book-api` and `book-ui`, go to the terminals where they are running and press `Ctrl+C`;
237
237
238
238
- To stop and remove Docker Compose containers, network, and volumes, go to a terminal and, inside the `springboot-react-basic-auth` root folder, run the command below:
239
- ```
239
+ ```bash
240
240
docker compose down -v
241
241
```
242
242
@@ -245,7 +245,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
245
245
- In a terminal, make sure you are in the `springboot-react-basic-auth/book-ui` folder;
246
246
247
247
- Run the following commands:
248
- ```
248
+ ```bash
249
249
npm upgrade
250
250
npm i -g npm-check-updates
251
251
ncu -u
0 commit comments