Skip to content

Node.js / Express Server side for Cryptogame where players can simulate buying and selling coins with a ranking feature that shows the players who won most money with tradings.

Notifications You must be signed in to change notification settings

GuilhermeCarra/cryptogame-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CryptoGame Backend

Build Setup

# install dependencies
npm install

# serve with hot reload
npm run dev

# serve for production
npm run start

# migrate the database from 0
npm run migrate

General API Information

  • All endpoints return a JSON object with the following format
// If everything went ok
{
  data: [{...}],
  error: null
}

// In case of an error occours
{
  data: null,
  error: "Error message"
}

HTTP Return Codes

  • HTTP 400 return code is used for malformed requests; the issue is on the sender's side.
  • HTTP 401 return code is used when trying to access a protected endpoint without providing a JWT.
  • HTTP 403 return code is used when trying to access a protected endpoint with an invalid JWT.
  • HTTP 500 return code is used for internal errors; the issue is on the API side.

Public API Endpoints

Register

POST /register

Registers a new user.

Parameters:

{
  "email" : "valid@email.com",
  "name" : "Username",
  "password" : "anypassword"
}

Response:

{
  "data": "Congratulation, you have successfully registered!",
  "error": null
}

Login

POST /login

Returns a JWT for an existing user.

Parameters:

{
  "email" : "registered@email.com",
  "password" : "validpassword"
}

Response:

{
  "data": {
    "accessToken": "...",
    "role": 0 // 0 for normal users, 1 for admin users
  },
  "error": null
}

Protected API Endpoints

About

Node.js / Express Server side for Cryptogame where players can simulate buying and selling coins with a ranking feature that shows the players who won most money with tradings.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •