This is the backend for the Course Selling App. It provides user authentication, course management, and purchasing functionality for users and admins.
-
User Functionality:
- Signup
- Login
- View Courses
- Make Purchases
-
Admin Functionality:
- Create courses
- Update courses
- Delete courses
- Get all courses created by the admin
Before you start, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/karan-vaishnav/course-selling-app.git cd course-selling-app
-
Install dependencies:
npm install
-
Copy
.env.example
to.env
and add your MongoDB credentials and JWT secret:cp .env.example .env
-
Update the
.env
file with your credentials:MONGO_URI=mongodb+srv://your-mongo-credentials JWT_USER_SECRET=your-jwt-secret JWT_ADMIN_SECRET=your-admin-jwt-secret
-
Start the development server:
npm run dev
-
The server should now be running at
http://localhost:4000
.
- POST /signup: Create a new user.
- Required fields:
email
,password
,firstName
,lastName
- Required fields:
- POST /login: User login and get a JWT token.
- Required fields:
email
,password
- Required fields:
- POST /purchases: Get all purchases made by the user (requires authentication).
- Headers:
Authorization
- Headers:
- POST /admin/course: Create a new course (requires admin authentication).
- Required fields:
title
,description
,price
,imageUrl
- Required fields:
- PUT /admin/course: Update an existing course (requires admin authentication).
- Required fields:
courseId
,title
,description
,price
,imageUrl
- Required fields:
- DELETE /admin/course: Delete a course (requires admin authentication).
- Required fields:
courseId
- Required fields:
- GET /admin/course: Get all courses created by the admin (requires admin authentication).
- All the routes under
/user/purchases
require a user to be authenticated via a JWT token, which should be included in the request header.
- All the routes under
/admin/*
require an admin to be authenticated via theJWT_ADMIN_SECRET
.
This project is licensed under the MIT License - see the LICENSE file for details.