Skip to content

backend for master quiz website implemented using node.js, MongoDB and uses socket.io

License

Notifications You must be signed in to change notification settings

rameziophobia/masterquiz-backend

Repository files navigation

MasterQuiz API

GitHub Release License

REST API for MasterQuiz Frontend app. The API provides CRUD functionality for required endpoints as well as session (Socket) for mutli-user real time quizzes.

Deployed: masterquiz-api.digitalphoenixx.live.

View Endpoints Docs & Sockets Docs.

Run the code locally

  1. Clone the repo

    git clone https://github.com/rameziophobia/masterquiz-backend.git
    cd masterquiz-backend/
  2. Duplicate .env.example file and rename it to .env and fill in the required fields.

  3. Install requiremnets and start the server.

    npm install
    npm start

Deployment

To deploy the api to a live/production server. You can either use docker, docker-compose or K8s.

Docker

Duplicate .env.example file and rename it to .env and fill in the required fields or pass it through command line arguemnts when running docker run. Change the first part of the tag to your dockerhub id)

docker build -t digitalphoenixx/masterquiz-api:latest .
docker run -p 8000:8000 digitalphoenixx/masterquiz-api:latest

Replace build tag and port used with appropriate values.

Docker-compose

Duplicate the .env file and fill in the data. Replace the port number in the docker-compose.yml file with preferred port. Then run

docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d

K8s

  1. Build the image. (change the first part of the tag to your dockerhub id)

    docker build -t digitalphoenixx/masterquiz-api:latest .
  2. Change the image name in the .k8s/kustomization.yml to the tag used in the build step.

  3. Change the hostname in the .k8s/ingress.yml to your domain.

  4. Create deployment.

    kubectl apply -k .k8s/
  5. Create the secret with the mongo connection string.

    kubectl create secret generic masterquiz-api-secret --from-literal=MONGO_URI="CONNECTION_STRING_HERE" -n masterquiz
  6. Check the everything is running, might take a second. Note: Ready is 1/1.

    > kubectl get -n masterquiz all
    
    NAME                                             READY   STATUS    RESTARTS   AGE
    pod/masterquiz-api-deployment-85866cc8cf-7rrfj   1/1     Running   0          4h39m
    
    NAME                             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
    service/masterquiz-api-service   ClusterIP   10.108.229.143   <none>        8000/TCP   4h39m
    
    NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/masterquiz-api-deployment   1/1     1            1           4h39m
    
    NAME                                                   DESIRED   CURRENT   READY   AGE
    replicaset.apps/masterquiz-api-deployment-85866cc8cf   1         1         1       4h39m

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project and their work in CONTRIBUTORS.md.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments