Skip to content

gabrieldarezzo/nodejs-curso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Install Docker (Windows 10 Professional Edition:Mode)

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 Docker-Error
You should download DockerToolbox instead of Docker-CE and fallow this steps:

Run Docker:

Add Mongo in docker

docker pull mongo

Run mongo

docker run --name mongodb -p 27017:27017 -d mongo

Simple Test Mongo over HTTP:

Access URL in Chrome: http://192.168.56.1:1111 to test, you should recive this response:
Response HTTP Mongo


Install Docker ToolBox (Windows 10 Home Edition:Mode)

Download and install: DockerToolbox.
-> Because Nobody $likes$ Win10-Pro

Run Docker:

Open Docker Quickstart Terminal
Icon Quickstart Terminal

Wait for this screen:
Icon 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:
Port Forwarding

  • Now in Tab Network, you'll need port forwarding:
    Port Host: 27017 Guest Host: 1111 Port Forwarding

Simple Test Mongo over HTTP:

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:
Response HTTP Mongo

Work like a charm in Win 10 Home 😆 😃 😆

More troubleshooting in this site:
https://codehangar.io/mongodb-image-instance-with-docker-toolbox-tutorial/


Commands in Docker:

List all dockers (actives)

docker ps
  • -a <- list all, include turnOff dockers

Stop Img

docker stop [IMAGE_ID]

Remover Img

docker rm [IMAGE_ID]

Start docker

It's good when you restart your machine.

docker start [NAME_OF_IMAGE]

Client for MongoDb:

Download Robo 3T

To test

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.

Releases

No releases published

Packages

No packages published