Skip to content

Treflor/backend

Repository files navigation

Treflor NodeJS backend

Treflor APIs deployed app on heroku

Description

This is a expressJS server app for treflor backend.We used google APIs for authentication and many things will be there in future.As the database we used mongoDB which is hosted on mongoDB.You can find hosted app on Heroku by this Link.

Instructions to run the project

clone the repository

$ git clone https://github.com/Treflor/backend

then create a new project and enable google+ API and create credentials on Google APIs.

Tutorial to setup Google OAuth

Copy the client id and client secret key.Create a .env file in the root directory.
Create IAM Admin credentials at google api and copy project_id,private_key and client_id from the json and paste them in .env file
Structure should like be bellow.

JWT_SECRET=[String]
CLIENT_ID=[String]
CLIENT_SECRET=[String]
DATABASE_URL=[String]
PROJECT_ID=[String]
PRIVATE_KEY=[String]
CLIENT_EMAIL=[String]
Key Type Description
JWT_SECRET String Can be any string for generate jwt
CLIENT_ID String Can be obtain from google APIs
CLIENT_SECRET String Can be obtain from google APIs
DATABASE_URL String Mongodb url for database
PROJECT_ID String Can be obtain from google apis IAM admin json
PRIVATE_KEY String Can be obtain from google apis IAM admin json
CLIENT_EMAIL String Can be obtain from google apis IAM admin json

run the project in production environment

$ npm start

run the project in production environment

$ npm run dev

project will starts at localhost:3000/ in development environment.

APIs

Google oauth api

Exchange access token with profile details and store it in mongodb Database.Then convert mongodb document id into jwt and send it back.

Type API Response
post /oauth/google json web token with id and method

required fields

  • body
    • access_token : required : from google sign in

Local sign up oauth api

Create a user according to the user email and password in mongodb Database.Password will store after encrypt using bcryptjs.Then convert mongodb document id into jwt and send it back.

Type API Response
post /oauth/signup json web token with id and method

required fields

  • body
    • email : required
    • password : required
    • family_name : required
    • given_name : required
    • photo :

Local Sign in oauth api

Find user according to the email and password and convert mongodb document id into jwt and send it back.

Type API Response
post /oauth/signin json web token with id and method

required fields

  • body
    • email : required
    • password : required

Current user api

return current user according to the jwt and method used to sign in

Type API Response
get /user current user

required fields

  • headers
    • Authorization : jwt from sign in

Overview

  • Google signin api
  • Local signup api
  • Local signin api
  • get user api

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages