GithubHelp home page GithubHelp logo

quiz-api's Introduction

Quiz API

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.

Run API

Setup Database

docker compose up -d

Install Dependencies

npm install

Create Schema

npx prisma migrate dev --name init

Build API

npm run build

Start API (make sure to build first)

npm start

API

The API endpoints' request and response are described below.

Create Quiz

Request E.g.

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
                }
            ]
        }
    ]
}

Response E.g.

201

{
   "success": true,
   "errors": [],
   "data": null
}

Read Quizzes

Request E.g.

GET /api/quizzes

Response E.g.

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"
        }
    ]
}

Request E.g.

GET /api/quizzes/id

Response E.g.

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"
                    }
                ]
            }
        ]
    }
}

quiz-api's People

Contributors

lafbelmonte avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.