Base URL: http://localhost:3000
All routes are mounted under /api.
Base path: /api/users
Create a new user account.
Endpoint: POST /api/users/register
Required fields: firstName, lastName, email, password
Optional: avatar (file upload)
curl -X POST http://localhost:3000/api/users/register \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"password": "123456"
}'With avatar (multipart):
curl -X POST http://localhost:3000/api/users/register \
-F "firstName=John" \
-F "lastName=Doe" \
-F "email=john@example.com" \
-F "password=123456" \
-F "avatar=@/path/to/avatar.png"Authenticate a user and receive a JWT token.
Endpoint: POST /api/users/login
Required fields: email, password
curl -X POST http://localhost:3000/api/users/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "123456"
}'Returns a paginated list of users. Admin only.
Endpoint: GET /api/users
Query parameters:
| Parameter | Default | Description |
|---|---|---|
page |
1 |
Page number |
perPage |
10 |
Items per page |
Headers: Authorization: Bearer <token>
curl -X GET "http://localhost:3000/api/users?page=1&perPage=10" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"Base path: /api/courses
Returns a paginated list of courses.
Endpoint: GET /api/courses
Query parameters:
| Parameter | Default | Description |
|---|---|---|
page |
1 |
Page number |
perPage |
1 |
Items per page |
curl -X GET "http://localhost:3000/api/courses?page=1&perPage=10"Endpoint: GET /api/courses/:courseId
curl -X GET http://localhost:3000/api/courses/COURSE_ID_HEREEndpoint: POST /api/courses
Required fields: name, price
curl -X POST http://localhost:3000/api/courses \
-H "Content-Type: application/json" \
-d '{
"name": "Node.js Basics",
"price": 99
}'Endpoint: PATCH /api/courses/:courseId
curl -X PATCH http://localhost:3000/api/courses/COURSE_ID_HERE \
-H "Content-Type: application/json" \
-d '{
"name": "Advanced Node.js",
"price": 149
}'Endpoint: DELETE /api/courses/:courseId
curl -X DELETE http://localhost:3000/api/courses/COURSE_ID_HERE# 1. Register a user
curl -X POST http://localhost:3000/api/users/register \
-H "Content-Type: application/json" \
-d '{"firstName":"John","lastName":"Doe","email":"john@example.com","password":"123456"}'
# 2. Login and copy the token from the response
curl -X POST http://localhost:3000/api/users/login \
-H "Content-Type: application/json" \
-d '{"email":"john@example.com","password":"123456"}'
# 3. Create a course
curl -X POST http://localhost:3000/api/courses \
-H "Content-Type: application/json" \
-d '{"name":"Docker 101","price":50}'- Use
/api/users/register, not/register. - Register requires
firstNameandlastNamein addition toemailandpassword. GET /api/usersrequires an ADMIN role and a validAuthorization: Bearer <token>header.- Set
JWT_SECRET_KEYin your environment (.envor Docker) for register and login to work.