plaitse / a-nodejs-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js API

Visit https://a-nodejs-api.herokuapp.com

Routes:

  • /todos

To deploy on Heroku

Connect DB online

  • Create a "free" new DB on https://mlab.com
  • Add a database user
  • Copy the the URI using the database user credentials
  • heroku config:set MONGODB_URI="URI"

Push project on Heroku

  • git push heroku master

To test the API via Postman

  • NB: It can take up to 1 minute for the server to charge

Todos routes

{
    "text": "Test via postman"
}

-> NB: Be sure to select JSON (application/json) when writing the body in Postman

{
	"text": "New test"
}

Users routes

{
	"email": "email@test.com",
	"password": "pass123!"
}

To test on local machine

  • Install MongoDB and create a mongo-data folder next to it
  • ./mongod --dbpath ~/.../mongo-data in mongo/bin root folder
  • if port already used: sudo lsof -i :portNumberand kill -9 PID
  • npm run testWatch to run units tests
  • npm start to run server
  • Use Robomongo to check data

About


Languages

Language:JavaScript 91.3%Language:HTML 5.0%Language:CSS 3.8%