Skip to content

Hellrasier/genesis-praxis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

genesis-praxis

Description

Node js api for retrieving information about current Bitcoin rate with user sign up and authentification.

Dependecies: used only native node js libraries http, https, fs, crypto and one external library dotenv

Current Bitcoin currency rate is being taken from https://www.coinapi.io/

API

  • Signing up

    POST user/create

      body: {
          email: "[email protected]",
          password: "examplepassword"
      }
    

    Query for creating new user. After creating user unque token is generated for this user. Users are saved in users_data.json

    Possible responses:

    • 201: Created user with E-mail: [email protected]
    • 400: Error, your E-mail or password field is empty
    • 400: Error, incorrect email
    • 409: Error, user with this E-mail adress already exists
  • Signing in

    POST user/login

      body: {
          email: "[email protected]",
          password: "examplepassword"
      }
    

    Query to authenticate and get user token. Possible responses:

    • 200: "68dd5aef0c**********************" - user token
    • 400: Error, your E-mail or password field is empty
    • 400: Error, user with this email does not exist
    • 400: Error, password is invalid
  • Get BTC rate

    GET btc/Rate

    headers: {
      Authorization: "68dd5aef0c**********************"
    }
    

    With this query you should provide headers with token to tell server that you are authorized.

    Possible responses:

    • 200: {cryptoCurrency: "BTC", rate: *BTC rate in UAH*}
    • 401: Error, user is unauthorized - if token is invalid or does not exist

Aplication structure

  • index.js - main file with server
  • api- server api
    • api.js - main api module with endpoints
    • cryptoCurrency.js - module with https response to https://www.coinapi.io/
    • security.js - module with functions that create token, hash passwords and verify passwords
  • storage- storage that emulates database. Data is saved in users_data.json, storage api is written in storage/storage.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published