-
Clone the Repository:
git clone https://github.com/code-with-parth/faq-api-bharatfd.git cd faq-api-bharatfd
-
Install Dependencies:
npm install
-
Set Up Environment Variables: Create a .env file in the root of your project and add the following environment variables:
PORT=3000 MONGO_URI=mongodb://localhost:27017/faqdb REDIS_URL=redis://localhost:6379 JWT_SECRET=your_jwt_secret
-
Start the Application:
npm start
-
Run with Docker: Ensure Docker is installed and running on your machine. Then, build and run the Docker containers:
docker-compose up --build
- Endpoint:
GET /api/faqs
- Description: Fetch all FAQs.
- Example:
curl -X GET http://localhost:3000/api/faqs
- Endpoint:
GET /api/faqs?lang=es
- Description: Fetch all FAQs translated to Spanish.
- Example:
curl -X GET http://localhost:3000/api/faqs?lang=es
- Endpoint:
GET /api/faqs/:id
- Description: Fetch a single FAQ by ID.
- Example:
curl -X GET http://localhost:3000/api/faqs/faq_id
- Endpoint:
POST /api/faqs
- Description: Create a new FAQ.
- Headers:
x-auth-token
: Your JWT token.
- Body (JSON):
{ "question": "What is Node.js?", "answer": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine." }
- Example:
curl -X POST http://localhost:3000/api/faqs \ -H "x-auth-token: your_jwt_token" \ -H "Content-Type: application/json" \ -d '{"question": "What is Node.js?", "answer": "Node.js is a JavaScript runtime built on Chrome\'s V8 JavaScript engine."}'
- Endpoint:
PUT /api/faqs/:id
- Description: Update an existing FAQ.
- Headers:
x-auth-token
: Your JWT token.
- Body (JSON):
{ "question": "What is Express.js?", "answer": "Express.js is a web application framework for Node.js." }
- Example:
curl -X PUT http://localhost:3000/api/faqs/faq_id \ -H "x-auth-token: your_jwt_token" \ -H "Content-Type: application/json" \ -d '{"question": "What is Express.js?", "answer": "Express.js is a web application framework for Node.js."}'
- Endpoint:
DELETE /api/faqs/:id
- Description: Delete an existing FAQ.
- Headers:
x-auth-token
: Your JWT token.
- Example:
curl -X DELETE http://localhost:3000/api/faqs/faq_id \ -H "x-auth-token: your_jwt_token"
-
Fork the Repository:
- Click the "Fork" button at the top right of the repository page.
-
Clone Your Fork:
git clone https://github.com/yourusername/faq-management-system.git cd faq-management-system
-
Create a Branch:
git checkout -b feature/your-feature-name
-
Make Your Changes:
- Implement your feature or fix the bug.
-
Commit Your Changes:
git add . git commit -m "Add your commit message here"
-
Push to Your Fork:
git push origin feature/your-feature-name
-
Create a Pull Request:
- Go to the original repository on GitHub.
- Click the "New Pull Request" button.
- Select your branch and submit the pull request.
-
Review Process:
- Your pull request will be reviewed by the maintainers.
- Make any requested changes.
- Once approved, your changes will be merged into the main branch.
Thank you for contributing!