Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dzencot committed Oct 27, 2024
1 parent e804ffa commit 82b8591
Show file tree
Hide file tree
Showing 27 changed files with 241 additions and 232 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGE_ID := ghcr.io/hexlet-components/rest-api-example
PORT := 5000
PORT := 5037

setup:
npm ci
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See [Makefile](./Makefile)

```bash
make docker-build
make docker-run # Open http://localhost:5000
make docker-run # Open http://localhost:5037
```

---
Expand Down
6 changes: 3 additions & 3 deletions typespec/http-api/services/commentsService.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ interface CommentService {
@query select?: string
): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@post
op create(...NewCommentDto): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@patch
@opExample(
#{ parameters: #{ id: "238593a0-b8d4-4bf6-beda-48ce6ba093bc" } }
)
op update(@path id: string, ...EditCommentDto): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@delete
@opExample(
#{ parameters: #{ id: "238593a0-b8d4-4bf6-beda-48ce6ba093bc" } }
Expand Down
6 changes: 3 additions & 3 deletions typespec/http-api/services/postsService.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ interface PostService {
@query select?: string
): Post;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@post
op create(...NewPostDto): Post;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@patch
@opExample(
#{ parameters: #{ id: "fb5e19a3-ab33-423b-9cec-8ee4ef211c61" } }
)
op update(@path id: string, ...EditPostDto): Post;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@delete
@opExample(
#{ parameters: #{ id: "fb5e19a3-ab33-423b-9cec-8ee4ef211c61" } }
Expand Down
4 changes: 2 additions & 2 deletions typespec/http-api/services/usersService.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ interface UserService {
@post
op create(...NewUserDto): User;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@patch
@opExample(
#{ parameters: #{ id: "a788f3fc-0d47-4d55-b18b-09bae52dac7b" } }
)
op update(@path id: string, ...EditUserDto): User;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@delete
@opExample(
#{ parameters: #{ id: "a788f3fc-0d47-4d55-b18b-09bae52dac7b" } }
Expand Down
15 changes: 11 additions & 4 deletions typespec/http-protocol/models/auth.tsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
@example(#{ email: "[email protected]", password: "password" }, #{ title: "Authentication data", description: "Login and password for authentication" })
import "../../examples/auth.tsp";

@example(
authDataExample,
#{
title:
"Authentication data",
description: "Login and password for authentication"
}
)
model AuthData {
@minLength(1)
email: string;
Expand All @@ -8,9 +17,7 @@ model AuthData {
}

@example(
#{
token: "secret_token"
},
authTokenExample,
#{ title: "Authorisation data", description: "Token for authorisation" }
)
model AuthToken {
Expand Down
28 changes: 14 additions & 14 deletions typespec/http-protocol/models/comment.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import "../../examples/comments.tsp";

@example(
#{
postId: "some_post_id",
body: "new comment body"
},
newCommentDtoExample,
#{ title: "New comment" }
)
model NewCommentDto {
Expand All @@ -13,10 +12,7 @@ model NewCommentDto {
}

@example(
#{
postId: "some_post_id",
body: "edit comment body"
},
editCommentDtoExample,
#{ title: "Edit comment" }
)
model EditCommentDto {
Expand All @@ -27,12 +23,7 @@ model EditCommentDto {
}

@example(
#{
id: "some-post-id",
authorId: "some_user_id",
postId: "some_post_id",
body: "comment body"
},
commentExample,
#{ title: "Comment" }
)
model Comment {
Expand All @@ -46,6 +37,15 @@ model Comment {
body: string;
}

@example(
#{
comments: commentsExample,
total: totalCommentsExample,
skip: skipCommentsExample,
limit: limitCommentsExample,
},
#{ title: "Comments" }
)
model Comments {
comments: Comment[];
total: integer;
Expand Down
27 changes: 14 additions & 13 deletions typespec/http-protocol/models/course.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import "../../examples/courses.tsp";

@example(
#{
title: "New course",
description: "description"
},
newCourseDtoExample,
#{ title: "New Course" }
)
model NewCourseDto {
Expand All @@ -15,10 +14,7 @@ model NewCourseDto {
}

@example(
#{
title: "Edited course",
description: "new description",
},
editCourseDtoExample,
#{ title: "Edit Course" }
)
model EditCourseDto {
Expand All @@ -30,11 +26,7 @@ model EditCourseDto {
}

@example(
#{
id: "some-id",
title: "Edited course",
description: "new description"
},
courseExample,
#{ title: "Course" }
)
model Course {
Expand All @@ -49,6 +41,15 @@ model Course {

}

@example(
#{
courses: coursesExample,
total: totalCoursesExample,
skip: skipCoursesExample,
limit: limitCoursesExample,
},
#{ title: "Courses" }
)
model Courses {
courses: Course[];
total: integer;
Expand Down
28 changes: 14 additions & 14 deletions typespec/http-protocol/models/post.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import "../../examples/posts.tsp";

@example(
#{
title: "new post title",
body: "new post body"
},
newPostDtoExample,
#{ title: "New Post" }
)
model NewPostDto {
Expand All @@ -14,10 +13,7 @@ model NewPostDto {
}

@example(
#{
title: "edit post title",
body: "edit post body"
},
editPostDtoExample,
#{ title: "Edit Post" }
)
model EditPostDto {
Expand All @@ -29,12 +25,7 @@ model EditPostDto {
}

@example(
#{
id: "fb5e19a3-ab33-423b-9cec-8ee4ef211c61",
authorId: "some_user_id",
title: "post title",
body: "post body"
},
postExample,
#{ title: "Post" }
)
model Post {
Expand All @@ -50,6 +41,15 @@ model Post {
body: string;
}

@example(
#{
posts: postsExample,
total: totalPostsExample,
skip: skipPostsExample,
limit: limitPostsExample,
},
#{ title: "posts" }
)
model Posts {
posts: Post[];
total: integer;
Expand Down
30 changes: 14 additions & 16 deletions typespec/http-protocol/models/task.tsp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import "../../examples/tasks.tsp";

@example(
#{
title: "New Task",
description: "description",
status: Status.Ready,
},
newTaskDtoExample,
#{ title: "New Task" }
)
model NewTaskDto {
Expand All @@ -17,11 +15,7 @@ model NewTaskDto {
}

@example(
#{
title: "Edited Task",
description: "new description",
status: Status.Ready,
},
editTaskDtoExample,
#{ title: "Edit Task" }
)
model EditTaskDto {
Expand All @@ -35,12 +29,7 @@ model EditTaskDto {
}

@example(
#{
id: "some-id",
title: "Edited Task",
description: "new description",
status: Status.Ready,
},
taskExample,
#{ title: "Task" }
)
model Task {
Expand All @@ -56,6 +45,15 @@ model Task {
status: Status;
}

@example(
#{
tasks: tasksExample,
total: totalTasksExample,
skip: skipTasksExample,
limit: limitTasksExample,
},
#{ title: "Tasks" }
)
model Tasks {
tasks: Task[];
total: integer;
Expand Down
31 changes: 14 additions & 17 deletions typespec/http-protocol/models/user.tsp
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import "../../examples/users.tsp";

@example(
#{
email: "[email protected]",
firstName: "Max",
lastName: "Maxwell",
password: "password"
},
newUserDtoExample,
#{ title: "New User" }
)
model NewUserDto {
Expand All @@ -22,11 +19,7 @@ model NewUserDto {
}

@example(
#{
email: "[email protected]",
firstName: "Maria",
lastName: "Marvel"
},
editUserDtoExample,
#{ title: "Edit User" }
)
model EditUserDto {
Expand All @@ -41,12 +34,7 @@ model EditUserDto {
}

@example(
#{
id: "a788f3fc-0d47-4d55-b18b-09bae52dac7b",
email: "[email protected]",
firstName: "Max",
lastName: "Maxwell"
},
userExample,
#{ title: "User" }
)
model User {
Expand All @@ -63,6 +51,15 @@ model User {
lastName: string;
}

@example(
#{
users: usersExample,
total: totalUsersExample,
skip: skipUsersExample,
limit: limitUsersExample,
},
#{ title: "Users" }
)
model Users {
users: User[];
total: integer;
Expand Down
6 changes: 3 additions & 3 deletions typespec/http-protocol/services/commentsService.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ interface CommentService {
@query select?: string
): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@post
op create(...NewCommentDto): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@patch
@opExample(
#{ parameters: #{ id: "238593a0-b8d4-4bf6-beda-48ce6ba093bc" } }
)
op update(@path id: string, ...EditCommentDto): Comment;

@useAuth([BearerAuth, BasicAuth])
@useAuth(BearerAuth)
@delete
@opExample(
#{ parameters: #{ id: "238593a0-b8d4-4bf6-beda-48ce6ba093bc" } }
Expand Down
Loading

0 comments on commit 82b8591

Please sign in to comment.