Skip to content

Tiny quiz api. experimenting with a structured and maintainable backend architecture

Notifications You must be signed in to change notification settings

josephtesla/quiz-api

Repository files navigation

Quick start

  1. Change to the root directory of the project.
  2. Run npm install. This should install all dependencies.
  3. Copy .env.example to .env and fill in the variables.
  4. You NEED MongoDB replica set, If you don’t have them installed but have Docker and Docker-compose you can run npm run infra in the root.
  5. Now run npm run dev. This should launch the server
  6. Server is now running on http://localhost:{PORT}.

API Endpoints

Auth

  • POST /signup Sign Up
  • POST /login Log in

Quiz

  • POST /quiz creates a new quiz

  • GET /quizzes Gets all quizzes.

    • Pass ?createdBy={:userId} query to get all quizzes created by a user
  • GET /quiz/[:quizId] Get Single quiz (with questions)

  • PATCH /quiz/[:quizId] Updates a quiz

  • DELETE /quiz/[:quizId] Deletes a quiz

Questions

  • POST /quiz/[:quizId]/questions Creates and Adds a question to a quiz
  • GET /quiz/[:quizId]/questions/[:questionId] Gets a question
  • PATCH /quiz/[:quizId]/questions/[:questionId] Updates a question
  • DELETE /quiz/[:quizId]/questions/[:questionId] Deletes a question

Submissions

  • POST /quiz/[:quizId]/submissions Creates a submission for a quiz

  • GET /quiz/[:quizId]/submissions Gets all submissions for a quiz.

    • Pass ?byCurrentUser=1 query to get all submissions of the current user for the quiz
  • GET /quiz/[:quizId]/submissions/[:submissionId] Gets single submission details with breakdown/analysis

  • GET /submissions/by-user Gets all submissions made by the current/signed in user (on any quiz)

About

Tiny quiz api. experimenting with a structured and maintainable backend architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published