Skip to content

Commit 6e1a24d

Browse files
committed
fix: details
1 parent 968c4c7 commit 6e1a24d

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

README.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,17 @@ bun install
3232
cp .env.example .env
3333
```
3434

35-
4. Up Apollo GraphQL server
35+
4. Up docker-compose redis
3636
```
37-
bun run server
37+
docker-compose up -d
3838
```
3939

40-
41-
## [Single-file executable](https://bun.sh/docs/bundler/executables)
42-
43-
- Building Server
40+
5. Up Apollo GraphQL server
4441
```
45-
bun build --compile --minify ./src/server.ts --outfile server
42+
bun run server
4643
```
4744

48-
- Executing binary
49-
```
50-
./server
51-
```
45+
6. Go to: [http://localhost:3000/graphql](http://localhost:3000/graphql)
5246

5347

5448
## License

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"server": "bun run --watch src/server.ts",
55
"format": "prettier --write \"src/**/*.ts\"",
66
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
7-
"husky": "husky install",
8-
"build": "bun build --compile --minify ./src/server.ts --outfile server",
9-
"prod:server": "./server"
7+
"husky": "husky install"
108
},
119
"dependencies": {
1210
"@apollo/server": "^4.10.4",

src/controllers/ToDo.controller.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class ToDoController {
77
static async isUserLoggedIn(authorization: string): Promise<{ id: string; email: string }> {
88
const jwt_token = authorization;
99

10-
if (!jwt_token) throw new Error("Header authorization token missing");
10+
if (!jwt_token) throw new Error("Header authorization token missing");
1111

1212
const decodedToken = jsonwebtoken.verify(jwt_token, process.env.JWT_SECRET_KEY) as {
1313
userId: string;
@@ -28,9 +28,9 @@ export default class ToDoController {
2828
return userFound;
2929
}
3030

31-
static async getToDoById({id}: GetToDoByIdDTO, { authorization }) {
31+
static async getToDoById({ id }: GetToDoByIdDTO, { authorization }) {
3232
try {
33-
const userFound = await ToDoController.isUserLoggedIn(authorization);
33+
const userFound = await ToDoController.isUserLoggedIn(authorization);
3434

3535
const todoFound = JSON.parse(await redis.get(`todo:${id}`));
3636

@@ -44,15 +44,15 @@ export default class ToDoController {
4444
}
4545
}
4646

47-
static async newToDo({title}: NewToDoDTO, { authorization }) {
47+
static async newToDo({ title }: NewToDoDTO, { authorization }) {
4848
try {
4949
const userFound = await ToDoController.isUserLoggedIn(authorization);
5050

5151
const todo = {
5252
id: randomUUID(),
5353
user_id: userFound.id,
5454
user_email: userFound.email,
55-
title,
55+
title,
5656
done: false,
5757
updated_at: null,
5858
created_at: new Date().toISOString(),
@@ -68,9 +68,9 @@ export default class ToDoController {
6868
}
6969
}
7070

71-
static async updateToDo({id, title, done}: UpdateToDoDTO, { authorization }) {
71+
static async updateToDo({ id, title, done }: UpdateToDoDTO, { authorization }) {
7272
try {
73-
const userFound = await ToDoController.isUserLoggedIn(authorization);
73+
const userFound = await ToDoController.isUserLoggedIn(authorization);
7474

7575
const todoFound = JSON.parse(await redis.get(`todo:${id}`));
7676

@@ -96,9 +96,9 @@ export default class ToDoController {
9696
}
9797
}
9898

99-
static async deleteToDo({id}: DeleteToDoDTO, { authorization }) {
99+
static async deleteToDo({ id }: DeleteToDoDTO, { authorization }) {
100100
try {
101-
const userFound = await ToDoController.isUserLoggedIn(authorization);
101+
const userFound = await ToDoController.isUserLoggedIn(authorization);
102102

103103
const todoFound = JSON.parse(await redis.get(`todo:${id}`));
104104

@@ -116,9 +116,9 @@ export default class ToDoController {
116116
}
117117
}
118118

119-
static async allToDos({authorization}) {
119+
static async allToDos({ authorization }) {
120120
try {
121-
const userFound = await ToDoController.isUserLoggedIn(authorization);
121+
const userFound = await ToDoController.isUserLoggedIn(authorization);
122122

123123
const todoIds = await redis.smembers(`user:${userFound.email}:todos`);
124124

src/models/todo.dto.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export interface GetToDoByIdDTO {
2-
id: string;
2+
id: string;
33
}
44

55
export interface NewToDoDTO {
6-
title: string;
6+
title: string;
77
}
88

99
export interface UpdateToDoDTO {
10-
id: string;
11-
title: string;
12-
done: boolean
10+
id: string;
11+
title: string;
12+
done: boolean;
1313
}
1414

1515
export interface DeleteToDoDTO {
16-
id: string;
16+
id: string;
1717
}

0 commit comments

Comments
 (0)