Curso de Node da RocketSeat.
Construção de APIs REST utilizando o NodeJS, back-end utilizando o JavaScript.
- Uso de NPM.
- Uso de Docker.
- Criação de rotas.
- Criação de Controllers.
- CRUD no Mongo.
- Utilizar as libs: 'nodemon', 'require-dir', 'mongoose', 'express', 'cors'.
You will need Node/npm to run this project.
After install, open your prompt:
npm install
Start Server (static server):
node server.js
Start Server (Dynamic server with nodemon devDependencies
):
npm run dev
Download docker: https://hub.docker.com/editions/community/docker-ce-desktop-windows
Ps: You'll need account in Docker for download.
-> Install Docker-CE
Ps:
If you use Windows 10 Home Edition
and get this error when install Docker-CE
You should download DockerToolbox instead of Docker-CE and fallow this steps:
docker pull mongo
docker run --name mongodb -p 27017:27017 -d mongo
Access URL in Chrome: http://192.168.56.1:1111
to test, you should recive this response:
Download and install: DockerToolbox.
-> Because Nobody
Open Docker Quickstart Terminal
In prompt of Docker Quickstart Terminal
pull mongo:
docker pull mongo
Run mongo with this params:
docker run --name database -d -p 27017:27017 mongo --noauth --bind_ip=0.0.0.0
In Oracle VM VirtualBox, get conf:
in prompt, ipconfig
, you need check IPv4 of: 'VirtualBox#1', 'VirtualBox#2':
Adaptador Ethernet VirtualBox Host-Only Network:
...
Endereço IPv4. . . . . . . . . . . . . . . : 192.168.56.1
...
Adaptador Ethernet VirtualBox Host-Only Network #2:
...
Endereço IPv4. . . . . . . . . . . . . . . : 192.168.99.1
...
Just enter one of then [http://IP:PORT]
in Chrome.
In my case http://192.168.99.1:1111
I received this response:
Work like a charm in Win 10 Home 😆 😃 😆
More troubleshooting in this site:
https://codehangar.io/mongodb-image-instance-with-docker-toolbox-tutorial/
docker ps
-a
<- list all, include turnOff dockers
docker stop [IMAGE_ID]
docker rm [IMAGE_ID]
It's good when you restart your machine.
docker start [NAME_OF_IMAGE]
You can get a nice client of REST: https://insomnia.rest/download/
Or just use buttons of sender.html
to test CREATE,UPDATE,DELETE routes, after all, cors
already enable in project.