The API runs on Node.js and is fully written in TypeScript.
It utilizes PostgreSQL for fetching and storing of data, which is being ran in docker. (see docker-compose.yml
)
It follows the Route-Controller-Service structure for ExpressJS.
Node version used: v16.19.0.
docker compose up -d
npm install
npx prisma migrate dev --name init
npm run build
npm start
The API endpoints' request and response are described below.
POST /api/quizzes
{
"title": "Final Quiz",
"description": "Final quiz before prelims.",
"status": "PUBLISHED",
"questions": [
{
"description": "What does the fox say?",
"mandatory": true,
"choices": [
{
"description": "Sheesh",
"correct": true
},
{
"description": "Meow",
"correct": false
}
]
}
]
}
201
{
"success": true,
"errors": [],
"data": null
}
GET /api/quizzes
200
{
"success": true,
"errors": [],
"data": [
{
"id": "edea2869-2705-4813-bbfa-51213dccddda",
"title": "Final Quiz",
"description": "Final quiz before prelims.",
"status": "PUBLISHED"
},
{
"id": "22260ad0-b4ea-4607-80f7-ada3e7317c67",
"title": "Surprise Quiz",
"description": "Surprise quiz for students.",
"status": "DRAFT"
}
]
}
GET /api/quizzes/id
200
{
"success": true,
"errors": [],
"data": {
"id": "edea2869-2705-4813-bbfa-51213dccddda",
"title": "Final Quiz",
"description": "Final quiz before prelims.",
"status": "PUBLISHED",
"questions": [
{
"id": "0c90404b-4d7c-454e-bdce-199a21bd6ac3",
"description": "What does the fox say?",
"mandatory": true,
"quizId": "edea2869-2705-4813-bbfa-51213dccddda",
"choices": [
{
"id": "0a54a1c0-e153-4d1c-b6cf-ffc742988ef5",
"description": "Sheesh",
"correct": true,
"questionId": "0c90404b-4d7c-454e-bdce-199a21bd6ac3"
},
{
"id": "b237e388-35f5-4cd3-920b-5f2090e80bb4",
"description": "Meow",
"correct": false,
"questionId": "0c90404b-4d7c-454e-bdce-199a21bd6ac3"
}
]
}
]
}
}