Games A P I Documentation

Games API

All Optional Routers:

HTTP Method Route Description Parameters / Request Body
GET /games Returns a list of games according to the query parameters you use.
  1. page (optional): page number to display (default: 1). Example-
    https://noa-project3-nodejs.cyclic.app/games?page=1
  2. perPage (optional): number of games per page (default: 10). Example-
    https://noa-project3-nodejs.cyclic.app/games?perPage=8
  3. sort (optional): field to sort by (default: price). Example-
    https://noa-project3-nodejs.cyclic.app/games?sort=price
  4. reverse (optional): if set to yes, sorts in descending order. Example-
    https://noa-project3-nodejs.cyclic.app/games?sort=price&reverse=yes
GET /games/search Returns a list of games matching to the search query.
  1. s : the search query to match against games names or information. Example-
    https://noa-project3-nodejs.cyclic.app/games/search?s=board
GET /games/category/:catname Returns a list of games by category
  1. catname: the name of the category to display games for. Example-
    https://noa-project3-nodejs.cyclic.app/games/category/Children's
GET /games/prices Returns a list of games filtered by price range. Example-
  1. min (optional): minimum price to filter by (default: 0).
  2. max (optional): maximum price to filter by (default: 150). Example-
    https://noa-project3-nodejs.cyclic.app/games/prices?min=20&&max=25
GET /games/single/:id Returns a single game by its ID.
  1. id: the ID of the game to display. Example-
    https://noa-project3-nodejs.cyclic.app/games/single/6409f3d330b3331281d002d9
POST /games Adds a new game.
Token is required!
  1. Request Body: Game data to be added in the following format-
    {
    "name": "string",
    "info": "string",
    "category": "string",
    "price": number,
    "img_url": "string"
    }
    img_url is allowed and not required
PUT /games/:editId Updates an existing game.
Token is required!
  1. editId: the ID of the game to update.
  2. Request Body: Game data to be updated in the following format-
    {
    "name": "string",
    "info": "string",
    "category": "string",
    "price": number,
    "img_url": "string"
    }
    img_url is allowed and not required
DELETE /games/:delId Deletes a toy by its ID.
is required!
  1. delId: the ID of the toy to delete.

Users API

All Optional Routers:

HTTP Method Route Description Request Body
GET /users Test endpoint to check if the server is running N/A
GET /users/userInfo Get the information for the authenticated user (requires authentication) N/A
POST /users Create a new user
  1. Request Body: User data to be post in the following format-
    {
    "name": "string",
    "email": "String",
    "password": "string",
    "role": "string"
    }
    role is allowed and not required (default: user).
POST /users/login Authenticate a user and receive a JWT token in response
  1. Request Body: User data to be loged in in the following format-
    {
    "email": "String",
    "password": "string"
    }

Users/Admin Token Abillities

All Abillities:

Admin Default User
Has the ability to add new games to the system Has the ability to add new games to the system
Can edit all information related to any game in the system Can only edit information related to games they have created or are associated with their account(by his user_id)
Has the ability to delete all games from the system Can only delete games that they have created or are associated with their account(by his user_id)