Skip to content

madkoding/node-mongo-api

Repository files navigation

Node.js Mongo RESTful API

Total alerts Language grade: JavaScript

Docker API and Mongo

This command will lauch a docker image with mongo and the api server to test locally

$ docker-compose up -d

To check the logs for the api response

$ docker logs -f api

To kill docker instances

$ docker kill api
$ docker kill mongo-express
$ docker kill mongo

Node.js API without Mongo

Raise de development instance with

$ npm start

When you commit your code, automaticly fix it any linter problems. If you wish to check them just run npm run lint If you wish to auto fix them just npm run lint:fix If you wish to modify the code, fork this repo and replace the api endpoints, and don't forget to star it ;>

And then just hit the endpoint to the port 5000 as is the default setted in code, or the alternative is to set the PORT in the environment vars

Endpoints

Method URL What is Sample Data
GET http://localhost:5000/colaborator Get list
GET http://localhost:5000/colaborator/1 Get one by id
POST http://localhost:5000/colaborator Post data {"name":"blah", "rut": "1234"}
PUT http://localhost:5000/colaborator/1 Update data by id {"name":"blah","rut":"4321","age": 22}
DELETE http://localhost:5000/colaborator/1 Delete data by id

Mongo Dashboard (when using docker image)

Open your browser at http://localhost:8081

Troubleshooting

If you have mongo connection timeouts or issues, just re run the image

$ docker-compose restart api

Environment vars

Env Sample data
PORT  5000
URI mongodb://root:root@localhost:27017/example

About

Node mongo api example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published