A basic backend project built using Node.js, Express, and MongoDB to simulate an online course selling platform.
- User and Admin authentication using JWT
- Role-based access control (Admin/User)
- Course creation (admin only)
- Course purchase (user only)
- MongoDB for data storage
- Protected routes via middleware
- Postman tested endpoints
- Node.js
- Express
- MongoDB (Compass)
- Mongoose
- JSON Web Tokens (JWT)
-
Clone the repo:
git clone https://github.com/om272004/course-selling-api.git cd course-selling-api
-
Install dependencies:
npm install
-
Update MongoDB URL:
- Open
index.js
and paste your MongoDB connection string in the appropriate section where it saysMONGO_URI
.
- Open
-
Run the server:
node index.js
Method | Route | Access | Description |
---|---|---|---|
POST | /users/signup | Public | Register as a user |
POST | /users/login | Public | Login as a user |
GET | /users/courses | User | View all courses |
POST | /users/courses/:courseId | User | Purchase a course |
GET | /users/purchasedCourses | User | View purchased courses |
POST | /admin/signup | Public | Register as an admin |
POST | /admin/login | Public | Login as an admin |
POST | /admin/courses | Admin | Create a course |
GET | /admin/courses | Admin | View all courses |
made by om.