Welcome to the Quiz-app-backend repository! This project serves as the backend for a quiz application. It handles user authentication, quiz management, and result processing using Node.js, Express.js, and MongoDB.
- Features
- Technologies Used
- Getting Started
- Environment Variables
- API Documentation
- Contributing
- License
- User Authentication (Register/Login)
- Quiz CRUD Operations
- Question Management within Quizzes
- Quiz Submission and Result Generation
- Role-Based Access Control (Admin/User)
- RESTful APIs for seamless integration
- Node.js: Backend runtime
- Express.js: Web framework
- MongoDB: Database
- Mongoose: ODM for MongoDB
- JWT: For secure user authentication
- bcrypt.js: For password hashing
- dotenv: For environment variable management
- Joi: For input validation
Make sure you have the following installed:
- Node.js (v14 or higher)
- npm (Node Package Manager)
- MongoDB (local or cloud-based)
-
Fork and clone the repository:
git clone https://github.com/bidisha-15/Quiz-app-backend.git cd Quiz-app-backend
-
Install dependencies:
npm install
-
Set up your
.env
file (see Environment Variables). -
Start the development server:
npm run dev
Create a .env
file in the root directory and include the following:
PORT=5000
MONGO_URI=<your-mongodb-connection-string>
JWT_SECRET=<your-secret-key>
NODE_ENV=development
Replace <your-mongodb-connection-string>
and <your-secret-key>
with appropriate values.
Refer to the API Documentation (create this file for detailed endpoint descriptions).
- POST
/api/auth/register
- Register a new user. - POST
/api/auth/login
- Log in a user.
- GET
/api/quizzes
- Get all quizzes. - POST
/api/quizzes
- Create a quiz (Admin only).
- POST
/api/quizzes/:id/submit
- Submit answers to a quiz.
For detailed API information, check the documentation linked above.
We welcome contributions to improve this project! Here's how you can contribute:
-
Fork this repository.
-
Clone your forked repository:
git clone https://github.com/your-username/Quiz-app-backend.git
-
Create a new branch for your feature or bug fix:
git checkout -b feature-name
-
Make your changes and commit them:
git add . git commit -m "Add your message here"
-
Push your changes to your forked repository:
git push origin feature-name
-
Submit a pull request to the
main
branch of the original repository.
- Follow JavaScript Standard Style for code formatting.
- Write clear and concise commit messages.
- Add comments to explain complex code logic.
- Ensure all tests pass before submitting a PR.
- Update documentation as necessary.
This project is licensed under the MIT License.
If you encounter any issues, feel free to open an issue in the issues section.
Happy coding! 😊