Skip to content

Commit fd28fa4

Browse files
Jaime Salas ZancadaJaime Salas Zancada
authored andcommitted
added node stacl
1 parent 5d2ebcc commit fd28fa4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

01-contenedores/lemoncode-challenge/node-stack/backend/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,25 @@ PORT=
1919

2020
Notice that `HOST` is set by default on `localhost` and `PORT` on `5000`. These are the settings to stablish where the HTTP application is listening. You don't need to change it.
2121

22-
With the database running you can check the appliaction by running:
22+
With the database running on local, you can check the appliaction by running:
23+
24+
> NOTE: If is the first time that you run it, no data will be available
2325
2426
```bash
2527
npm start
2628
```
2729

28-
And then call it with;
30+
And then call it with:
2931

3032
```bash
3133
curl http://localhost:5000/api/topics
3234
```
3335

36+
If you want to feed some data you can try:
37+
38+
```bash
39+
curl -d '{"Name":"Devops"}' -H "Content-Type: application/json" -X POST http://localhost:5000/api/topics
40+
curl -d '{"Name":"K8s"}' -H "Content-Type: application/json" -X POST http://localhost:5000/api/topics
41+
curl -d '{"Name":"Docker"}' -H "Content-Type: application/json" -X POST http://localhost:5000/api/topics
42+
curl -d '{"Name":"Prometheus"}' -H "Content-Type: application/json" -X POST http://localhost:5000/api/topics
43+
```

01-contenedores/lemoncode-challenge/node-stack/backend/src/services/mappers.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@ function isTopicEntity(topic: TopicEntity | TopicDatabase): topic is TopicEntity
1818

1919
export function mapTopic(topic: TopicEntity | TopicDatabase): TopicEntity | TopicDatabase {
2020
if (isTopicDatabase(topic)) {
21-
return {
21+
const t = {
2222
...topic,
2323
id: topic._id.toString(),
24-
}
24+
};
25+
26+
delete t['_id'];
27+
return t;
2528
}
2629

2730
if(isTopicEntity(topic)) {
28-
return {
31+
const t = {
2932
...topic,
3033
_id: new ObjectId(topic.id),
31-
}
34+
};
35+
delete t['id'];
36+
return t;
3237
}
3338
}
3439

0 commit comments

Comments
 (0)