Treflor APIs deployed app on heroku
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.
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.
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.
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
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
: requiredpassword
: requiredfamily_name
: requiredgiven_name
: requiredphoto
:
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
: requiredpassword
: required
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
- Google signin api
- Local signup api
- Local signin api
- get user api