peterhanania / quiz-app-backend

The backend for the quiz app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quiz App {Backend}

Made using express, mongoose, and node.js.

Getting Started

You can start setting up your server by filling the .env file with your own credentials.

  • MONGO_URL= your mongo database url
  • MAIN_WEBSITE_URL= your main website url, used for redirecting users to the main website after they log in. You can set that up later once you run your frontend. default: http://localhost:3000
  • SESSION_SECRET= The secret key for your session (random characters)

Then, you can get started by installing the dependencies and running the following command:

npm install
# or
yarn install

then

npm run dev
# or
yarn dev

What does this do?

The backend is responsible for handling all the logic for the quiz app:

  • Creating the questions.
  • Validating the user's answers.
  • Generating a random question when requested.
  • Creating and Logging in users.
  • Keeping track of user scores.
  • Keeping track of the user's old used questions so that they can't be used again.

Updating the default questions

Note: The questions get added to the database once the first request is made to the server.

You can update the default questions at src/other/defaultQuestions.json.

But the questions should be in the format of

{ 
id: string, 
question: string, 
options: Array<{ 
               label: string, 
               value: string, 
               isCorrect: boolean }> 
}  

About

The backend for the quiz app.


Languages

Language:TypeScript 99.4%Language:Shell 0.6%