Skip to content

Commit a68c6ac

Browse files
it’s better to install all dependencies, including devDependencies, by omitting the --production flag during the build process and updated README.md
1 parent e81a291 commit a68c6ac

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ response:
4646
- You could use for example the following service: `https://countriesnow.space/`.
4747
6. Test the implementation as well as it's needed from your perspective.
4848
7. All the implementations must be runnable locally with our own computer. Write needed instructions to README.md file.
49-
8. Publish all sources code and relevant files in github or similar service and send the link to the repo so that the implementation can be reviewed.
49+
8. Publish all sources code and relevant files in GitHub or similar service and send the link to the repo so that the implementation can be reviewed.
5050

5151
You get bonus points if:
5252

5353
- You use and understand [Reactor](https://www.baeldung.com/reactor-core).
54-
- You create a separate wep application which utilizes the created REST API and shows the relevant country information in a browser.
54+
- You create a separate web application which utilizes the created REST API and shows the relevant country information in a browser.
5555

5656
## Architecture Explanation.
5757

@@ -67,18 +67,18 @@ You get bonus points if:
6767
- [![Lombok](https://img.shields.io/badge/Lombok-green?style=for-the-badge)](https://docs.spring.io/spring-framework/reference/web/webflux.html).
6868
-**Lombok**✅ For reducing boilerplate code.
6969

70-
- We are making `application.yml` for this microservices.
70+
- We are making `application.yml` for these microservices.
7171
- If this microservice would ran in different environment, it would pick up appropriate configurations.
7272

7373
- Domain classes represents classes inside business logic.
7474

75-
- DTO classes represents REST API and are modeled using `countriesnow.space` API nesting structure. Meaning package names is from API paths and DTO class names tries to represent the given thing. I chose not make DTO classes as reusable as possible, every DTO is unique. [ReadMore](https://www.baeldung.com/java-dto-pattern#common-mistakes).
75+
- DTO classes represents REST API and are modeled using `countriesnow.space` API nesting structure. Meaning package names is from API paths and DTO class names tries to represent the given thing. I chose not to make DTO classes as reusable as possible, every DTO is unique. [Read More](https://www.baeldung.com/java-dto-pattern#common-mistakes).
7676

7777
> We also want to avoid trying to use a single class for many scenarios.
7878
79-
- I have decided to use **ResponseEntity** in **Controller** class. [ReadMore](https://www.baeldung.com/spring-response-entity).
79+
- I have decided to use **ResponseEntity** in **Controller** class. [Read More](https://www.baeldung.com/spring-response-entity).
8080

81-
> While **ResponseEntity** is very powerful, we shouldn’t overuse it. In simple cases, there are other options that satisfy our needs and they result in much cleaner code.
81+
> While **ResponseEntity** is very powerful, we shouldn’t overuse it. In simple cases, there are other options that satisfy our needs, and they result in much cleaner code.
8282
8383
- We are making tests!
8484
- **Unit Tests**:
@@ -92,36 +92,36 @@ You get bonus points if:
9292
-**WireMock**✅ for testing external APIs. In progress ♻️ **Could not get this working, for now** ♻️.
9393
- [![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com/)
9494
-**Docker**✅ for easy deployment.
95-
- ⚠️**Although**⚠️, this task should be approached as microservice as possible. This solution have been dockerize under one `.yml` file for sake of simplicity.
95+
- ⚠️**Although**⚠️, this task should be approached as microservice as possible. This solution has been dockerized under one `.yml` file for sake of simplicity.
9696

9797
- [![Apache-Maven](https://img.shields.io/badge/apache%20maven-gray?style=for-the-badge&logo=apachemaven&logoColor=red)](https://maven.apache.org/)
98-
-**Maven**✅ Building tool, because i like it and it was in specifications!
98+
-**Maven**✅ Building tool, because I like it, and it was in specifications!
9999

100100
- [![Angular](https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white)](https://angular.dev/)
101-
-**Angular** front end, because i like it!
101+
-**Angular**✅ front end, because I like it!
102102

103-
- [![nginx](https://img.shields.io/badge/nginx-grey?style=for-the-badge&logo=nginx)](https://nginx.org/en/)
103+
- [![Nginx](https://img.shields.io/badge/nginx-grey?style=for-the-badge&logo=nginx)](https://nginx.org/en/)
104104
-**Nginx**✅ for hosting front end.
105105

106106
- API versioning:
107107
-**URI Path Versioning**✅, were chosen for its popularity.
108108
-**Query Parameter Versioning**❌.
109109
-**Header Versioning**❌.
110110

111-
- All **API:s** are implementing **resilience** with **retrying pattern**.
111+
- All **APIs** are implementing **resilience** with **retrying pattern**.
112112
- Retry only **5xx** errors.
113113

114114
- Country letter representation "**two letters**" [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) will be used, since it was in specifications.
115115

116116
### Prerequisites:
117-
- Lates java JDK is fine to run commands.
117+
- Latest Java JDK is fine to run commands.
118118
- Latest Docker.
119119

120120
# Not sure things ⚠️👀?
121121

122-
- I am not sure that, am i utilizing the **.subscribe** rightly. Like in this example, i don't have any of such in code directly `.subscribe(this::someFunction, this::someFunctionIfErrorHappened);`. My service is simple passing data to front end by means of **Project Reactor**. Well, yes if there would be db attached, then this would be suitable approach, but i didn't come any use for such case.
122+
- I am not sure that, am I utilizing the **.subscribe** rightly. Like in this example, I don't have any of such in code directly `.subscribe(this::someFunction, this::someFunctionIfErrorHappened);`. My service is simple passing data to front end by means of **Project Reactor**. Well, yes if there would be db attached, then this would be suitable approach, but I didn't come any use for such case.
123123

124-
- Other thing is the **Subscriptions** itself, i should make SSE end point to back end and Angular app would listen this stream for new countries? Now its just service for REST api call in world of **Project Reactor**.
124+
- Other thing is the **Subscriptions** itself, I should make SSE end point to back end and Angular app would listen this stream for new countries? Now its just service for REST API call in world of **Project Reactor**.
125125

126126
# How to run!
127127

@@ -160,7 +160,7 @@ docker-compose up --build
160160
ng serve
161161
```
162162

163-
- Check console for website! Normally its `http://localhost:4200/`.
163+
- Check console for the website! Normally its `http://localhost:4200/`.
164164

165165
# Back end.
166166

@@ -237,16 +237,16 @@ java -jar target/country-service-backend-0.0.1-SNAPSHOT.jar
237237

238238
- I came to notice when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/population` it would work for **Postman**, but not for **Reactor Netty**.
239239

240-
- Tool to catch the request were **Request Catcher**, it helped me to distinguish if there were some error in the request what **Reactor Netty** was making. URL of catcher `https://test.requestcatcher.com/`. **POST** didn't work for some reason and could not get any stream of data back from **Web Client** using DTO classes.
241-
- I noticed the only difference mainly was headers. Upper picture from **Reactor Netty** request and below it is from **Postman**, which worked. I tried to change **User-Agent** to `User-Agent: PostmanRuntime/7.42.0` in **Reactor Netty** so it would work, but my luck failed.
240+
- Tool to catch the request was **Request Catcher**, it helped me to distinguish if there were some error in the request what **Reactor Netty** was making. URL of catcher `https://test.requestcatcher.com/`. **POST** didn't work for some reason and could not get any stream of data back from **Web Client** using DTO classes.
241+
- I noticed the only difference mainly was in headers. Upper picture from **Reactor Netty** request and below it is from **Postman**, which worked. I tried to change **User-Agent** to `User-Agent: PostmanRuntime/7.42.0` in **Reactor Netty** so it would work, but my luck failed.
242242

243243
<img src="doneFromNettyHeaders.PNG" width="500" height="300">
244244

245245
<img src="doneFromPostManHeaders.PNG" width="500" height="300">
246246

247-
- Due to the inspections how Postman had it working with this API. It had following settings `Accept: */*`.
247+
- Due to the inspections how Postman had it working with this API. It had the following settings `Accept: */*`.
248248

249-
- Luckily returning `Mono<String>` from **POST** function and setting `@Data` for DTO class which was for serving as param class. Also i changed **Reactor Netty** headers to `"Accept", MediaType.ALL_VALUE` from `"Accept", MediaType.APPLICATION_JSON_VALUE`(since API gives JSON), gave me positive surprise.
249+
- Luckily returning `Mono<String>` from **POST** function and setting `@Data` for DTO class which was for serving as param class. Also, I changed **Reactor Netty** headers to `"Accept", MediaType.ALL_VALUE` from `"Accept", MediaType.APPLICATION_JSON_VALUE`(since API gives JSON), gave me positive surprise.
250250

251251
```
252252
@Bean
@@ -273,15 +273,15 @@ public class ParamClass {
273273
274274
- Also, WebClient started to worked normally after right Header information `.doOnSuccess(result -> System.out.println("Response: " + result));` gave me `Response: Moved Permanently. Redirecting to /api/v0.1/countries/population/q?country=Finland`.
275275
276-
- All thought it was saying **redirecting**, i could not catch redirect message in network tab. Maybe it was due **Reactor Netty** needs to be configured to process these one, but for now i decided to just use this **hint** as API query and move forward with the task :)
276+
- All thought it was saying **redirecting**, I could not catch redirect message in network tab. Maybe it was a due **Reactor Netty** needs to be configured to process these one, but for now I just decided to use this **hint** as API query and move forward with the task :)
277277
278278
<img src="noRedirectCaptured.PNG" alt="alt text" width="600"/>
279279
280280
</details>
281281
<details>
282282
<summary id="problem2">Weird Feature 2.</summary>
283283
284-
- I came to same conclusion as last error message when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/flag/images` it would work for **Postman**, but not for **Reactor Netty**. This time message was `"Moved Permanently. Redirecting to /api/v0.1/countries/flag/images/q?country=NG"` and i had much fun clicking eastern egg like 5 minutes :D. No redirect messages again.
284+
- I came to same conclusion as last error message when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/flag/images` it would work for **Postman**, but not for **Reactor Netty**. This time message was `"Moved Permanently. Redirecting to /api/v0.1/countries/flag/images/q?country=NG"` and I had much fun clicking eastern egg like 5 minutes :D. No redirect messages again.
285285
286286
<img src="positveSupriseAboutPOSTapiKauneutta.PNG" alt="alt text" width="600"/>
287287

country-service-front/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ WORKDIR /app
88
COPY package.json package-lock.json ./
99

1010
# Install dependencies
11-
RUN npm install --production
11+
RUN npm install
1212

1313
# Copy the rest of the application code
1414
COPY . .

0 commit comments

Comments
 (0)