1
1
## Create a course selling website
2
2
3
3
### Description
4
+
4
5
Same as the last assignment but you need to use jwts for authentication.
5
6
We have introduced the signgin endpoints for both users and admins.
6
7
For this one, in every authenticated requests, you need to send the jwt in headers (Authorization : "Bearer <actual token >").
7
8
You need to use mongodb to store all the data persistently.
8
9
9
10
## Routes
11
+
10
12
### Admin Routes:
13
+
11
14
- POST /admin/signup
12
15
Description: Creates a new admin account.
13
16
Input Body: { username: 'admin', password: 'pass' }
14
17
Output: { message: 'Admin created successfully' }
15
18
- POST /admin/signin
16
- Description: Creates a new admin account.
19
+ Description: Logs in an admin account.
17
20
Input Body: { username: 'admin', password: 'pass' }
18
21
Output: { token: 'your-token' }
19
22
- POST /admin/courses
@@ -26,12 +29,13 @@ You need to use mongodb to store all the data persistently.
26
29
Output: { courses: [ { id: 1, title: 'course title', description: 'course description', price: 100, imageLink: 'https://linktoimage.com ', published: true }, ... ] }
27
30
28
31
### User routes
32
+
29
33
- POST /users/signup
30
34
Description: Creates a new user account.
31
35
Input: { username: 'user', password: 'pass' }
32
36
Output: { message: 'User created successfully' }
33
37
- POST /users/signin
34
- Description: Creates a new user account.
38
+ Description: Logs in a user account.
35
39
Input: { username: 'user', password: 'pass' }
36
40
Output: { token: 'your-token' }
37
41
- GET /users/courses
@@ -45,4 +49,4 @@ You need to use mongodb to store all the data persistently.
45
49
- GET /users/purchasedCourses
46
50
Description: Lists all the courses purchased by the user.
47
51
Input: Headers: { 'Authorization': 'Bearer <your-token >' }
48
- Output: { purchasedCourses: [ { id: 1, title: 'course title', description: 'course description', price: 100, imageLink: 'https://linktoimage.com ', published: true }, ... ] }
52
+ Output: { purchasedCourses: [ { id: 1, title: 'course title', description: 'course description', price: 100, imageLink: 'https://linktoimage.com ', published: true }, ... ] }
0 commit comments