A RESTful quiz application built with NestJS and Fastify.
Prerequisites:
- Docker
- Docker Compose
To run the application, use either:
./start.sh
or
docker-compose up
That's it! The application will be available at http://localhost:3000
Swagger will be available at http://localhost:3000/api/docs
- POST /quiz - Create a new quiz
- GET /quiz/:id - Get a specific quiz
- POST /quiz/:quizId/questions/:questionId/answer - Submit an answer
- GET /quiz/:quizId/:userId - Get quiz results
Create a quiz:
curl -X POST http://localhost:3000/quiz \
-H "Content-Type: application/json" \
-d '{
"title": "Math Quiz",
"description": "Basic math questions",
"questions": [
{
"id": "q1",
"text": "What is 2+2?",
"options": ["3", "4", "5", "6"],
"correct_option": 1
}
]
}'
Sample Data:
{
"id": 1,
"title": "Random Quiz",
"questions": [
{
"id": 1,
"question": "What is the capital of France?",
"options": ["Berlin", "Madrid", "Paris", "Rome"],
"correct_option": 3
},
{
"id": 2,
"question": "Which planet is known as the Red Planet?",
"options": ["Earth", "Mars", "Jupiter", "Saturn"],
"correct_option": 2
},
{
"id": 3,
"question": "Who developed the theory of relativity?",
"options": ["Isaac Newton", "Albert Einstein", "Galileo Galilei", "Nikola Tesla"],
"correct_option": 2
},
{
"id": 4,
"question": "What is the largest ocean on Earth?",
"options": ["Atlantic Ocean", "Indian Ocean", "Arctic Ocean", "Pacific Ocean"],
"correct_option": 4
},
{
"id": 5,
"question": "Which element has the chemical symbol 'O'?",
"options": ["Oxygen", "Osmium", "Ozone", "Oxygenium"],
"correct_option": 1
}
]
}
# Unit tests
docker-compose exec api npm run test
# E2E tests
docker-compose exec api npm run test:e2e