https://github.com/sandeepguptax2003/gurucool-assignment
Quiz Application Backend is a backend application built using Node.js, Express.js, and MongoDB. It provides a RESTful API for creating, managing, and participating in timed quizzes.
https://github.com/sandeepguptax2003/gurucool-assignment
mongodb node-cron nodejs
Last synced: 2 months ago
JSON representation
Quiz Application Backend is a backend application built using Node.js, Express.js, and MongoDB. It provides a RESTful API for creating, managing, and participating in timed quizzes.
- Host: GitHub
- URL: https://github.com/sandeepguptax2003/gurucool-assignment
- Owner: sandeepguptax2003
- Created: 2024-08-07T13:21:46.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-09T06:32:42.000Z (10 months ago)
- Last Synced: 2025-02-01T22:47:53.299Z (4 months ago)
- Topics: mongodb, node-cron, nodejs
- Language: JavaScript
- Homepage: https://gurucool-assignment-zobq.onrender.com/
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Quiz Application Backend
Quiz Application Backend is a backend application built using Node.js, Express.js, and MongoDB. It provides a RESTful API for creating, managing, and participating in timed quizzes.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [API Endpoints](#api-endpoints)
- [Authentication](#authentication)
- [Quiz Management](#quiz-management)
- [Technologies Used](#technologies-used)
- [Contributing](#contributing)
- [License](#license)## Features
- Users can create timed quizzes with questions, options, and correct answers.
- The application automatically manages the status of quizzes (inactive, active, finished).
- Users can retrieve the currently active quiz.
- Users can retrieve the result of a quiz after 5 minutes of the quiz's end time.
- Users can retrieve a list of all quizzes (including inactive and finished).
- Secure access to the API endpoints using JWT-based authentication.
- Rate limiting to prevent abuse of the API.## Technologies Used
- Node.js: A JavaScript runtime environment for server-side development.
- Express.js: A web application framework for Node.js, used for building the RESTful API.
- MongoDB: A NoSQL database, used for storing quiz and user data.
- Mongoose: An Object Document Mapping (ODM) library, used for interacting with MongoDB.
- Bcryptjs: A library for hashing passwords.
- JsonWebToken (JWT): A library for generating and verifying JSON Web Tokens for authentication.
- Express Rate Limit: A middleware that limits repeated requests to public APIs and endpoints.
- Node Cron: A library for scheduling tasks (used for updating quiz statuses).## API Endpoints
# Authentication
- POST /api/auth/register: Register a new user.
- POST /api/auth/login: Login and receive a JWT token.
# Quiz Management
- POST /api/quizzes: Create a new quiz.
- GET /api/quizzes/active: Retrieve the currently active quiz.
- GET /api/quizzes/:id/result: Retrieve the result of a quiz.
- GET /api/quizzes/all: Retrieve a list of all quizzes.
- For detailed information about the request and response formats, please refer to the API Documentation:## Installation
1. Clone the repository:
git clone2. Change into the project directory:
cd Gurucool-Assignment
Install the dependencies:
npm install3. Set up the environment variables:
Create a .env file in the root directory.
Add the following variables:
env
PORT=3800
MONGODB_URI=your-mongodb-url
JWT_SECRET=your_jwt_secret_here4. Start the server:
nodemon server.js
The server will start running on the specified port (default is 3800)## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.## License
This project is licensed under the MIT License.