Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 7c39e2f

Browse files
committed
docs: add api docs to notifications routes
1 parent 04bd70a commit 7c39e2f

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

api-service/api/src/real-time/notifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const notificationEvent = "new-notification"
77
const noticeTime: number = 60_000;
88

99
export async function loadAllScheduledNotifications() {
10-
// TODO: load all ScheduledNotifications
10+
// TODO: load all ScheduledNotifications at server startup
1111
console.debug("Loading all scheduled notifications")
1212
}
1313

@@ -52,5 +52,5 @@ async function emitNotification(io: Server, event: EventType, body: string) {
5252
type: event,
5353
text: body,
5454
})
55-
await notification.save(); // TODO: catch possible errors
55+
await notification.save();
5656
}

api-service/api/src/routes/notifications.route.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,93 @@ const API_LIMITER_RULES: ApiLimiterEntry = {
1616

1717
notificationsRoute.use(apiLimiter(API_LIMITER_RULES, limitStorage));
1818

19+
/**
20+
* @openapi
21+
*
22+
* paths:
23+
* /notifications/all:
24+
* get:
25+
* summary: Return all the notifications for the user
26+
* responses:
27+
* '200':
28+
* description: Ok
29+
* content:
30+
* application/json:
31+
* schema:
32+
* allOf:
33+
* - $ref: '#/components/schemas/CommonResponse'
34+
* '400':
35+
* description: Bad Request
36+
* content:
37+
* application/json:
38+
* schema:
39+
* allOf:
40+
* - $ref: '#/components/schemas/BadRequestError'
41+
*
42+
* '429':
43+
* description: Too many requests
44+
* content:
45+
* application/json:
46+
* schema:
47+
* allOf:
48+
* - $ref: '#/components/schemas/TooManyRequestError'
49+
* '500':
50+
* description: Generic server error
51+
* content:
52+
* application/json:
53+
* schema:
54+
* allOf:
55+
* - $ref: '#/components/schemas/InternalServerError'
56+
*
57+
*/
1958
notificationsRoute.get("/all", authenticationHandler, getAllNotifications);
2059

60+
/**
61+
* @openapi
62+
*
63+
* paths:
64+
* /notifications/{notificationId}:
65+
* put:
66+
* summary: Mark a notification as read
67+
* parameters:
68+
* - name: notificationId
69+
* in: path
70+
* description: The id of the notification to mark as read
71+
* required: true
72+
* schema:
73+
* type: string
74+
* responses:
75+
* '201':
76+
* description: Created
77+
* content:
78+
* application/json:
79+
* schema:
80+
* allOf:
81+
* - $ref: '#/components/schemas/CommonResponse'
82+
* '400':
83+
* description: Bad Request
84+
* content:
85+
* application/json:
86+
* schema:
87+
* allOf:
88+
* - $ref: '#/components/schemas/BadRequestError'
89+
*
90+
* '429':
91+
* description: Too many requests
92+
* content:
93+
* application/json:
94+
* schema:
95+
* allOf:
96+
* - $ref: '#/components/schemas/TooManyRequestError'
97+
* '500':
98+
* description: Generic server error
99+
* content:
100+
* application/json:
101+
* schema:
102+
* allOf:
103+
* - $ref: '#/components/schemas/InternalServerError'
104+
*
105+
*/
21106
notificationsRoute.put("/:notificationId", authenticationHandler, readNotification);
22107

23108
export default notificationsRoute;

0 commit comments

Comments
 (0)