Skip to content

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]
KeyTypeDescription
JWT_SECRETStringCan be any string for generate jwt
CLIENT_IDStringCan be obtain from google APIs
CLIENT_SECRETStringCan be obtain from google APIs
DATABASE_URLStringMongodb url for database
PROJECT_IDStringCan be obtain from google apis IAM admin json
PRIVATE_KEYStringCan be obtain from google apis IAM admin json
CLIENT_EMAILStringCan 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.

TypeAPIResponse
post/oauth/googlejson 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.

TypeAPIResponse
post/oauth/signupjson 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.

TypeAPIResponse
post/oauth/signinjson 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

TypeAPIResponse
get/usercurrent user

required fields

  • headers
    • Authorization : jwt from sign in

Overview

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

About

expressJS backend for treflor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages