yhay81 / developer-quiz-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Developer Quiz API

This API provides four-choice quizzes. And you can add quizzes.

Requirements

  • node
  • npm/yarn
  • postgres

Setup

Initialize node dependencies.

yarn install

Create developer quiz database.

psql -f createdb.sql

Create database tables.

yarn migrate

Insert some data.

psql -d developer_quiz -f dataset.sql

Launch the server.

yarn start

Methods

GET /api/quizzes/

Get all quizzes.

POST /api/quizzes/

Add one quiz.

  • Data Params
{
  "quiz": "string",
  "correct_answer": "string",
  "wrong_answer1": "string",
  "wrong_answer2": "string",
  "wrong_answer3": "string",
  "authour": "string(OPTIONAL)",
  "password": "string(OPTIONAL)"
}

GET /api/quizzes/random

Get one random quiz.

GET /api/quizzes/:id

Get particuler quiz.

DELETE /api/quizzes/:id

Delete particuler quiz.

  • Data Params
{
  "authour": "string",
  "password": "string"
}

GET /api/genre/

Get all genre.

GET /api/users/

Get all users.

POST /api/users/

Regester as a user.

  • Data Params
{
  "username": "string",
  "password": "string"
}

GET /api/users/:username

Regester as a user.

PUT/PATCH /api/users/:username

Update user information.

  • Data Params
{
  "password": "string",
  "newUsername": "string(OPTIONAL)",
  "newPassword": "string(OPTIONAL)"
}

DELETE /api/users/:username

Delete a user.

  • Data Params
{
  "password": "string"
}

Contribution

Feel free to send a pull request.

Licence

MIT

About

License:MIT License


Languages

Language:JavaScript 83.5%Language:CSS 7.2%Language:PLpgSQL 4.7%Language:HTML 4.5%