GithubHelp home page GithubHelp logo

linkapi-node's Introduction

Docs: linkapi-node

About the project:

API developed for integration between PipedriveAPI and BlingAPI. Requesting and sending data from one platform to another is done through the crons.

Postman Collection

Import the Teste - LinkApi.postman_collection.json on Postman App.

Requirements:

How to start:

Environment variables -

  • BCRYPT_SALT: Salt used by bcrypt to increase hash security
  • SERVER_PORT: Port where the application runs (Ex.: 3000)
  • JWT_SECRET: The secret of the application, which guarantees the uniqueness of the tokens (Ex.:asdybhq47qrdb)
  • DB_URL: MongoDB URL (Ex.: mongodb://example:27017/example-db)
  • PIPE_TOKEN: Access token for PipedriveAPI
  • BLING_TOKEN: Access token for BlingAPI
  • PIPE_COMPANY_DOMAIN: Company domain on Pipedrive
  • BLING_URL: BlingAPI URL
  • DEALS_CRON_TIME: Cron time that looks for deals in the PipedriveAPI (Ex.: "* * * * *") Obs.: In this example the cron will run every minute
  • ORDERS_CRON_TIME: Cron time that send the orders to BlingAPI (Ex.: "* * * * *") Obs.: In this example the cron will run every minute

I recommend using CronTab to deal with the times of the crons

Create the .env file

$ cp .env.example .env

Set with YOUR environment variables.

Install the dependencies

$ yarn

To start the server in a development environment

Run the application:

$ yarn dev:server

Run the crons in a different terminal:

$ yarn dev:schedule

To start the server in a production environment

Run the application:

$ yarn start

Run the crons in a different terminal:

$ yarn schedule

Routes:

URL: http://localhost:3000/ Returns a JSON in this format, containing the server status.

{
	"Author": "Augusto Vinicius",
	"Github": "https://github.com/adoidadox2",
	"Project": "linkapi-node",
	"Version": "1.0.0",
	"Status": "Online"
}

User Routes

Store -POST-

/users

Register new users

  {
	"name":"Augusto",
	"email":"[email protected]",
	"password":"1234"
  }

If everything goes well, the answer will be status 200 and the registered data will return.

 {
	"message": "User created successfully",
	"data": {
		"name": "Augusto",
		"email": "[email protected]"
	}
 }

Index -GET-

/users

Returns registered users

  {
	"message": "Successfully listed users",
	"data": [
		{
			"_id": "60739299591f682a685fb9b1",
			"name": "Augusto",
			"email": "[email protected]",
			"createdAt": "2021-04-12T00:21:45.371Z"
		},
		{
			"_id": "60751f73bb361b0140d2ef31",
			"name": "Vinicius",
			"email": "[email protected]",
			"createdAt": "2021-04-13T04:34:59.097Z"
		}
	]
}

Session Routes

Store -POST-

/session

Creates a new session, generating a token, which will be used to access protected routes

  {
	"email":"[email protected]",
	"password":"1234"
  }

If all goes well, the answer will be status 200 and will return the user's data and a valid token.

{
	"message": "Session created successfully",
	"data": {
		"user": {
			"_id": "60739299591f682a685fb9b1",
			"name": "Augusto",
			"email": "[email protected]"
		},
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDczOTI5OTU5MWY2ODJhNjg1ZmI5YjEiLCJlbWFpbCI6ImF1Z3VzdG9AZW1haWwuY29tIiwiaWF0IjoxNjE4MjgwNTk4fQ.VriX_-6ucf7xcaBLw9WatqtxO6MnmJS2g-9p_SJp9Dw"
	}
}

Balance Routes

These routes require Authentication using Bearer Token, generated on the route/session .

Index -GET-

/balances

Returns registered balances

  {
	"message": "Successfully listed balances",
	"data": [
		{
			"_id": "60739299591f682a685fb9b1",
			"date": "12/04/2021",
			"value": 600
		},
		{
			"_id": "60751f73bb361b0140d2ef31",
			"date": "13/04/2021",
			"value": 1240.5
		}
	],
	"last_update": "2021-04-13T04:13:00.434Z"
}

linkapi-node's People

Contributors

adoidadox2 avatar

Stargazers

Dheyson Alves avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.