├── .gitignore
├── 10_MVC
├── 10_enviando_dados_atualizacao
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ └── edit.handlebars
├── 11_completando_tarefa
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ └── edit.handlebars
├── 1_estrutura
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 2_criando_model
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ └── package.json
├── 3_criando_controller
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ └── create.handlebars
├── 4_criando_rotas
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 5_add_css
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 6_salvando_tasks
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 7_resgatando_dados
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 8_removendo_tarefa
│ ├── controllers
│ │ └── TaskController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── tasksRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── tasks
│ │ ├── all.handlebars
│ │ └── create.handlebars
└── 9_editar_tarefa
│ ├── controllers
│ └── TaskController.js
│ ├── db
│ └── conn.js
│ ├── index.js
│ ├── models
│ └── Task.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ ├── routes
│ └── tasksRoutes.js
│ └── views
│ ├── layouts
│ └── main.handlebars
│ └── tasks
│ ├── all.handlebars
│ ├── create.handlebars
│ └── edit.handlebars
├── 11_TOUGHTS
├── controllers
│ ├── AuthController.js
│ └── ToughtController.js
├── db
│ └── conn.js
├── helpers
│ └── auth.js
├── index.js
├── models
│ ├── Tought.js
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ ├── css
│ │ └── styles.css
│ └── img
│ │ ├── favicon.ico
│ │ └── toughts_logo.png
├── routes
│ ├── authRoutes.js
│ └── toughtsRoutes.js
└── views
│ ├── auth
│ ├── login.handlebars
│ └── register.handlebars
│ ├── layouts
│ └── main.handlebars
│ └── toughts
│ ├── create.handlebars
│ ├── dashboard.handlebars
│ ├── edit.handlebars
│ └── home.handlebars
├── 12_MONGODB
├── 1_instalacao
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 2_criando_mvc
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ └── all.handlebars
├── 3_inserindo_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 4_resgatando_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ └── create.handlebars
├── 5_resgatando_dado
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ └── product.handlebars
├── 6_excluindo_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ └── product.handlebars
├── 7_editando_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
└── 8_editando_dado_salvar
│ ├── controllers
│ └── ProductController.js
│ ├── db
│ └── conn.js
│ ├── index.js
│ ├── models
│ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ ├── routes
│ └── productsRoutes.js
│ └── views
│ ├── layouts
│ └── main.handlebars
│ └── products
│ ├── all.handlebars
│ ├── create.handlebars
│ ├── edit.handlebars
│ └── product.handlebars
├── 13_MONGOOSE
├── 1_instalacao
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 2_schema
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 3_inserindo_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 4_lendo_dados
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 5_dado_individual
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 6_editando_dado
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
├── 7_editando_dado_post
│ ├── controllers
│ │ └── ProductController.js
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── models
│ │ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── routes
│ │ └── productsRoutes.js
│ └── views
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── products
│ │ ├── all.handlebars
│ │ ├── create.handlebars
│ │ ├── edit.handlebars
│ │ └── product.handlebars
└── 8_remocao_de_dado
│ ├── controllers
│ └── ProductController.js
│ ├── db
│ └── conn.js
│ ├── index.js
│ ├── models
│ └── Product.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ ├── routes
│ └── productsRoutes.js
│ └── views
│ ├── layouts
│ └── main.handlebars
│ └── products
│ ├── all.handlebars
│ ├── create.handlebars
│ ├── edit.handlebars
│ └── product.handlebars
├── 14_API
├── 1_primeira_api
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 2_rota_com_post
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
└── 3_status_na_resposta
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 15_GETAPET
├── .gitignore
├── backend
│ ├── controllers
│ │ ├── PetController.js
│ │ └── UserController.js
│ ├── db
│ │ └── conn.js
│ ├── helpers
│ │ ├── check-token.js
│ │ ├── create-user-token.js
│ │ ├── get-token.js
│ │ ├── get-user-by-token.js
│ │ └── image-upload.js
│ ├── index.js
│ ├── models
│ │ ├── Pet.js
│ │ └── User.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── images
│ │ │ ├── pets
│ │ │ └── .gitkeep
│ │ │ └── users
│ │ │ └── .gitkeep
│ └── routes
│ │ ├── PetRoutes.js
│ │ └── UserRoutes.js
├── frontend
│ ├── .env.local
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── App.js
│ │ ├── assets
│ │ │ └── img
│ │ │ │ └── logo.png
│ │ ├── components
│ │ │ ├── form
│ │ │ │ ├── Form.module.css
│ │ │ │ ├── Input.js
│ │ │ │ ├── Input.module.css
│ │ │ │ ├── PetForm.js
│ │ │ │ ├── Select.js
│ │ │ │ └── Select.module.css
│ │ │ ├── layout
│ │ │ │ ├── Container.js
│ │ │ │ ├── Container.module.css
│ │ │ │ ├── Footer.js
│ │ │ │ ├── Footer.module.css
│ │ │ │ ├── Message.js
│ │ │ │ ├── Message.module.css
│ │ │ │ ├── Navbar.js
│ │ │ │ ├── Navbar.module.css
│ │ │ │ ├── RoundedImage.js
│ │ │ │ └── RoundedImage.module.css
│ │ │ └── pages
│ │ │ │ ├── Auth
│ │ │ │ ├── Login.js
│ │ │ │ └── Register.js
│ │ │ │ ├── Home.js
│ │ │ │ ├── Home.module.css
│ │ │ │ ├── Pet
│ │ │ │ ├── AddPet.js
│ │ │ │ ├── AddPet.module.css
│ │ │ │ ├── Dashboard.module.css
│ │ │ │ ├── EditPet.js
│ │ │ │ ├── MyAdoptions.js
│ │ │ │ ├── MyPets.js
│ │ │ │ ├── PetDetails.js
│ │ │ │ └── PetDetails.module.css
│ │ │ │ └── User
│ │ │ │ ├── Profile.js
│ │ │ │ └── Profile.module.css
│ │ ├── context
│ │ │ └── UserContext.js
│ │ ├── hooks
│ │ │ ├── useAuth.js
│ │ │ └── useFlashMessage.js
│ │ ├── index.css
│ │ ├── index.js
│ │ └── utils
│ │ │ ├── api.js
│ │ │ └── bus.js
│ └── yarn.lock
└── pets
│ ├── labra1.jpg
│ ├── labra2.jpg
│ ├── labra3.jpg
│ ├── pet1.jpg
│ ├── pet10.jpg
│ ├── pet2.jpg
│ ├── pet3.jpg
│ ├── pet4.jpg
│ ├── pet5.jpg
│ ├── pet6.jpg
│ ├── pet7.jpg
│ ├── pet8.jpg
│ └── pet9.jpg
├── 16_WHATSAPP_WEB_CLONE
├── img
│ ├── avatar1.png
│ ├── avatar2.png
│ ├── avatar3.png
│ ├── avatar4.png
│ └── background_whats.png
├── index.html
└── styles.css
├── 17_API_REST_NODE_MONGOOSE_YT
├── index.js
├── models
│ └── Person.js
├── package-lock.json
└── package.json
├── 18_AUTH_NODE_JWT
├── .gitignore
├── app.js
├── models
│ └── User.js
├── package-lock.json
└── package.json
├── 19_REACT_ROUTER_6
├── app
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ └── src
│ │ ├── App.js
│ │ ├── components
│ │ ├── Navbar.js
│ │ ├── Navbar.module.css
│ │ └── pages
│ │ │ ├── Contact.js
│ │ │ ├── Home.js
│ │ │ └── Users.js
│ │ ├── index.css
│ │ └── index.js
└── app_inicio
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ └── index.html
│ └── src
│ ├── App.js
│ ├── components
│ ├── Navbar.js
│ ├── Navbar.module.css
│ └── pages
│ │ ├── Contact.js
│ │ ├── Home.js
│ │ └── Users.js
│ ├── index.css
│ └── index.js
├── 1_INTRO
├── 1_primeiro_programa
│ └── arquivo.js
├── 2_utilizando_modulo
│ ├── arquivo.txt
│ └── index.js
└── 3_tarefa_01
│ └── programa.js
├── 2_FUNDAMENTOS
├── 10_abstracao_input
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 11_event_loop
│ └── index.js
├── 12_event_emitter
│ └── index.js
├── 13_sync_async
│ ├── arquivo.txt
│ ├── assincrono.js
│ └── sincrono.js
├── 14_erros
│ ├── throw.js
│ └── try_catch.js
├── 15_tarefa_02
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 1_modulo_interno
│ ├── index.js
│ └── meu_modulo.js
├── 2_export_import
│ ├── index.mjs
│ └── meu_modulo.mjs
├── 3_core_module
│ └── index.js
├── 4_ler_argumentos
│ └── index.js
├── 5_modulos_externos
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 6_pratica_com_args
│ ├── index.js
│ ├── meu_modulo.js
│ ├── package-lock.json
│ └── package.json
├── 7_explorando_console
│ └── index.js
├── 8_melhorando_visual
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
└── 9_lendo_input
│ └── index.js
├── 3_CORE_MODULES
├── 10_roteamento
│ ├── 404.html
│ ├── contato.html
│ ├── home.html
│ └── index.js
├── 11_detalhes_arquivos
│ ├── index.js
│ └── novoarquivo.txt
├── 12_path
│ └── index.js
├── 13_path_absoluto
│ ├── index.js
│ └── teste.txt
├── 14_trabalhando_com_dirs
│ └── index.js
├── 15_modulo_os
│ └── index.js
├── 1_http
│ └── index.js
├── 2_retornando_html
│ └── index.js
├── 3_url
│ └── index.js
├── 4_http_com_url
│ └── index.js
├── 5_fs
│ ├── index.js
│ └── mensagem.html
├── 6_escrevendo_arquivos
│ ├── arquivo.txt
│ ├── index.html
│ └── index.js
├── 7_atualizando_arquivos
│ ├── arquivo.txt
│ ├── index.html
│ └── index.js
├── 8_removendo_arquivos
│ └── index.js
└── 9_renomeando_arquivo
│ ├── index.js
│ └── novoarquivo.txt
├── 4_NPM_FUNDAMENTOS
├── 1_criando_projeto
│ └── package.json
├── 2_instalando_modulo
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 3_pacote_de_dev
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 4_criando_scripts
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 5_pacote_global
│ └── index.js
├── 6_executando_npx
│ └── arquivo.txt
└── 7_removendo_pacote
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 5_ACCOUNTS
├── accounts
│ ├── as.json
│ ├── teste.txt
│ ├── testematheus.json
│ ├── x.json
│ ├── y.json
│ └── z.json
├── index.js
├── package-lock.json
└── package.json
├── 6_EXPRESS
├── 10_404
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ ├── templates
│ │ ├── 404.html
│ │ ├── index.html
│ │ ├── userform.html
│ │ └── users.html
│ └── users
│ │ └── index.js
├── 11_tarefa_3
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── projects
│ │ └── index.js
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── templates
│ │ ├── project.html
│ │ └── projects.html
├── 1_instalacao
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 2_setup
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── 3_render_html
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── templates
│ │ └── index.html
├── 4_nodemon
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── templates
│ │ └── index.html
├── 5_middleware
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── templates
│ │ └── index.html
├── 6_parametro_na_rota
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── templates
│ │ ├── index.html
│ │ └── users.html
├── 7_post_de_dados
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── templates
│ │ ├── index.html
│ │ ├── userform.html
│ │ └── users.html
├── 8_modulo_rotas
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── templates
│ │ ├── index.html
│ │ ├── userform.html
│ │ └── users.html
│ └── users
│ │ └── index.js
└── 9_colocando_css
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ ├── templates
│ ├── index.html
│ ├── userform.html
│ └── users.html
│ └── users
│ └── index.js
├── 7_TEMPLATE_ENGINE
├── 10_tarefa_4
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── home.handlebars
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── product.handlebars
├── 1_instalacao_handle
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ └── home.handlebars
├── 2_criando_layouts
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 3_enviando_dados
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 4_condicionais
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── dashboard.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 5_else
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── dashboard.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 6_loops
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── dashboard.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 7_with
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── blogpost.handlebars
│ │ ├── dashboard.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 8_partials
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── blog.handlebars
│ │ ├── blogpost.handlebars
│ │ ├── dashboard.handlebars
│ │ ├── home.handlebars
│ │ ├── layouts
│ │ └── main.handlebars
│ │ └── partials
│ │ └── post.handlebars
└── 9_css_handlebars
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ └── views
│ ├── blog.handlebars
│ ├── blogpost.handlebars
│ ├── dashboard.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ └── partials
│ └── post.handlebars
├── 8_MYSQL
├── 1_instalacao_mysql
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── views
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 2_inserindo_dados
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 3_resgatando_dados
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── books.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 4_dado_especifico
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── book.handlebars
│ │ ├── books.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 5_editando_dado
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── book.handlebars
│ │ ├── books.handlebars
│ │ ├── editbook.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 6_realizando_update
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── book.handlebars
│ │ ├── books.handlebars
│ │ ├── editbook.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 7_removendo_dados
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── book.handlebars
│ │ ├── books.handlebars
│ │ ├── editbook.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
├── 8_connection_pool
│ ├── db
│ │ └── conn.js
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── css
│ │ │ └── styles.css
│ └── views
│ │ ├── book.handlebars
│ │ ├── books.handlebars
│ │ ├── editbook.handlebars
│ │ ├── home.handlebars
│ │ └── layouts
│ │ └── main.handlebars
└── 9_preparando_query
│ ├── db
│ └── conn.js
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ └── css
│ │ └── styles.css
│ └── views
│ ├── book.handlebars
│ ├── books.handlebars
│ ├── editbook.handlebars
│ ├── home.handlebars
│ └── layouts
│ └── main.handlebars
└── 9_SEQUELIZE
├── 10_add_relacionado
├── db
│ └── conn.js
├── index.js
├── models
│ ├── Address.js
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ ├── useredit.handlebars
│ └── userview.handlebars
├── 11_select_relacionados
├── db
│ └── conn.js
├── index.js
├── models
│ ├── Address.js
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ ├── useredit.handlebars
│ └── userview.handlebars
├── 12_delete_relacionados
├── db
│ └── conn.js
├── index.js
├── models
│ ├── Address.js
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ ├── useredit.handlebars
│ └── userview.handlebars
├── 1_instalacao
├── db
│ └── conn.js
├── index.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── home.handlebars
│ └── layouts
│ └── main.handlebars
├── 2_model
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── home.handlebars
│ └── layouts
│ └── main.handlebars
├── 3_insert
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ └── layouts
│ └── main.handlebars
├── 4_select
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ └── layouts
│ └── main.handlebars
├── 5_where
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ └── userview.handlebars
├── 6_delete
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ └── userview.handlebars
├── 7_edit
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ ├── useredit.handlebars
│ └── userview.handlebars
├── 8_update
├── db
│ └── conn.js
├── index.js
├── models
│ └── User.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── adduser.handlebars
│ ├── home.handlebars
│ ├── layouts
│ └── main.handlebars
│ ├── useredit.handlebars
│ └── userview.handlebars
└── 9_relacionamento
├── db
└── conn.js
├── index.js
├── models
├── Address.js
└── User.js
├── package-lock.json
├── package.json
├── public
└── css
│ └── styles.css
└── views
├── adduser.handlebars
├── home.handlebars
├── layouts
└── main.handlebars
├── useredit.handlebars
└── userview.handlebars
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/10_MVC/10_enviando_dados_atualizacao/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/10_enviando_dados_atualizacao/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/10_enviando_dados_atualizacao/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.post('/add', TaskController.createTaskSave)
7 | router.post('/remove', TaskController.removeTask)
8 | router.get('/edit/:id', TaskController.updateTask)
9 | router.post('/edit', TaskController.updateTaskPost)
10 | router.get('/', TaskController.showTasks)
11 |
12 | module.exports = router
13 |
--------------------------------------------------------------------------------
/10_MVC/10_enviando_dados_atualizacao/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 |
Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/11_completando_tarefa/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/11_completando_tarefa/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/11_completando_tarefa/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/1_estrutura/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | exports.default = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/1_estrutura/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 |
4 | const app = express()
5 |
6 | const conn = require('./db/conn')
7 |
8 | app.engine('handlebars', exphbs())
9 | app.set('view engine', 'handlebars')
10 |
11 | app.use(
12 | express.urlencoded({
13 | extended: true,
14 | }),
15 | )
16 |
17 | app.use(express.json())
18 |
19 | app.use(express.static('public'))
20 |
21 | app.listen(3000)
22 |
--------------------------------------------------------------------------------
/10_MVC/2_criando_model/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/2_criando_model/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/3_criando_controller/controllers/TaskController.js:
--------------------------------------------------------------------------------
1 | const Task = require('../models/Task')
2 |
3 | module.exports = class TaskController {
4 | static createTask(req, res) {
5 | res.render('tasks/create')
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/10_MVC/3_criando_controller/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/3_criando_controller/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/3_criando_controller/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | MVC
8 |
9 |
10 |
11 |
16 | {{{ body }}}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/10_MVC/3_criando_controller/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/controllers/TaskController.js:
--------------------------------------------------------------------------------
1 | const Task = require('../models/Task')
2 |
3 | module.exports = class TaskController {
4 | static createTask(req, res) {
5 | res.render('tasks/create')
6 | }
7 |
8 | static showTasks(req, res) {
9 | res.render('tasks/all')
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.get('/', TaskController.showTasks)
7 |
8 | module.exports = router
9 |
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/views/tasks/all.handlebars:
--------------------------------------------------------------------------------
1 | Todas as Tasks:
--------------------------------------------------------------------------------
/10_MVC/4_criando_rotas/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/5_add_css/controllers/TaskController.js:
--------------------------------------------------------------------------------
1 | const Task = require('../models/Task')
2 |
3 | module.exports = class TaskController {
4 | static createTask(req, res) {
5 | res.render('tasks/create')
6 | }
7 |
8 | static showTasks(req, res) {
9 | res.render('tasks/all')
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/10_MVC/5_add_css/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/5_add_css/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/5_add_css/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.get('/', TaskController.showTasks)
7 |
8 | module.exports = router
9 |
--------------------------------------------------------------------------------
/10_MVC/5_add_css/views/tasks/all.handlebars:
--------------------------------------------------------------------------------
1 | Todas as Tasks:
--------------------------------------------------------------------------------
/10_MVC/5_add_css/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/6_salvando_tasks/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/6_salvando_tasks/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/6_salvando_tasks/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.post('/add', TaskController.createTaskSave)
7 | router.get('/', TaskController.showTasks)
8 |
9 | module.exports = router
10 |
--------------------------------------------------------------------------------
/10_MVC/6_salvando_tasks/views/tasks/all.handlebars:
--------------------------------------------------------------------------------
1 | Todas as Tasks:
--------------------------------------------------------------------------------
/10_MVC/6_salvando_tasks/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/7_resgatando_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/7_resgatando_dados/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/7_resgatando_dados/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.post('/add', TaskController.createTaskSave)
7 | router.get('/', TaskController.showTasks)
8 |
9 | module.exports = router
10 |
--------------------------------------------------------------------------------
/10_MVC/7_resgatando_dados/views/tasks/all.handlebars:
--------------------------------------------------------------------------------
1 | Todas as Tasks:
2 |
3 | {{#each tasks}}
4 | -
5 | {{this.title}}
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{/each}}
13 |
--------------------------------------------------------------------------------
/10_MVC/7_resgatando_dados/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/8_removendo_tarefa/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/8_removendo_tarefa/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/8_removendo_tarefa/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.post('/add', TaskController.createTaskSave)
7 | router.post('/remove', TaskController.removeTask)
8 | router.get('/', TaskController.showTasks)
9 |
10 | module.exports = router
11 |
--------------------------------------------------------------------------------
/10_MVC/8_removendo_tarefa/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/10_MVC/9_editar_tarefa/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodemvc', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/10_MVC/9_editar_tarefa/models/Task.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const Task = db.define('Task', {
6 | title: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | description: {
11 | type: DataTypes.STRING,
12 | },
13 | done: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = Task
19 |
--------------------------------------------------------------------------------
/10_MVC/9_editar_tarefa/routes/tasksRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const TaskController = require('../controllers/TaskController')
4 |
5 | router.get('/add', TaskController.createTask)
6 | router.post('/add', TaskController.createTaskSave)
7 | router.post('/remove', TaskController.removeTask)
8 | router.get('/edit/:id', TaskController.updateTask)
9 | router.get('/', TaskController.showTasks)
10 |
11 | module.exports = router
12 |
--------------------------------------------------------------------------------
/10_MVC/9_editar_tarefa/views/tasks/create.handlebars:
--------------------------------------------------------------------------------
1 | Criando uma task
2 |
--------------------------------------------------------------------------------
/11_TOUGHTS/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('toughts', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/11_TOUGHTS/helpers/auth.js:
--------------------------------------------------------------------------------
1 | module.exports.checkAuth = function (req, res, next) {
2 | const userId = req.session.userid
3 |
4 | if (!userId) {
5 | res.redirect('/login')
6 | }
7 |
8 | next()
9 | }
10 |
--------------------------------------------------------------------------------
/11_TOUGHTS/models/Tought.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require("sequelize");
2 |
3 | const db = require("../db/conn");
4 |
5 | const User = require("../models/User");
6 |
7 | const Tought = db.define("Tought", {
8 | title: {
9 | type: DataTypes.STRING,
10 | allowNull: false,
11 | },
12 | });
13 |
14 | Tought.belongsTo(User);
15 | User.hasMany(Tought);
16 |
17 | module.exports = Tought;
18 |
--------------------------------------------------------------------------------
/11_TOUGHTS/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require("sequelize");
2 |
3 | const db = require("../db/conn");
4 |
5 | const User = db.define("User", {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | email: {
11 | type: DataTypes.STRING,
12 | allowNull: false,
13 | },
14 | password: {
15 | type: DataTypes.STRING,
16 | allowNull: false,
17 | },
18 | });
19 |
20 | module.exports = User;
21 |
--------------------------------------------------------------------------------
/11_TOUGHTS/public/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/11_TOUGHTS/public/img/favicon.ico
--------------------------------------------------------------------------------
/11_TOUGHTS/public/img/toughts_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/11_TOUGHTS/public/img/toughts_logo.png
--------------------------------------------------------------------------------
/11_TOUGHTS/routes/authRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const AuthController = require('../controllers/AuthController')
4 |
5 | router.get('/login', AuthController.login)
6 | router.post('/login', AuthController.loginPost)
7 | router.get('/register', AuthController.register)
8 | router.post('/register', AuthController.registerPost)
9 | router.get('/logout', AuthController.logout)
10 |
11 | module.exports = router
12 |
--------------------------------------------------------------------------------
/11_TOUGHTS/views/toughts/create.handlebars:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/11_TOUGHTS/views/toughts/edit.handlebars:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/12_MONGODB/1_instalacao/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/1_instalacao/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const exphbs = require("express-handlebars");
3 | const app = express();
4 |
5 | const conn = require("./db/conn").run;
6 |
7 | app.engine("handlebars", exphbs());
8 | app.set("view engine", "handlebars");
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | })
14 | );
15 |
16 | app.use(express.json());
17 |
--------------------------------------------------------------------------------
/12_MONGODB/1_instalacao/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/controllers/ProductController.js:
--------------------------------------------------------------------------------
1 | const Product = require("../models/Product");
2 |
3 | module.exports = class ToughController {
4 | static showProducts(req, res) {
5 | res.render("products/all");
6 | }
7 | };
8 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const conn = require('./db/conn').run
6 |
7 | const productsRoutes = require('./routes/productsRoutes')
8 |
9 | app.engine('handlebars', exphbs())
10 | app.set('view engine', 'handlebars')
11 |
12 | app.use(
13 | express.urlencoded({
14 | extended: true,
15 | }),
16 | )
17 |
18 | app.use(express.json())
19 |
20 | app.use(express.static('public'))
21 |
22 | app.use('/', productsRoutes)
23 |
24 | app.listen(3000)
25 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/public/css/styles.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: Helvetica, sans-serif;
3 | margin: 0;
4 | padding: 0;
5 | background-color: #222;
6 | color: #fff;
7 | }
8 |
9 | /* NAVBAR */
10 | #navbar {
11 | padding: 1.2em 2.4em;
12 | margin-bottom: 1em;
13 | display: flex;
14 | justify-content: space-between;
15 | align-items: center;
16 |
17 | border-bottom: 1px solid #fff;
18 | }
19 |
20 | #navbar ul {
21 | display: flex;
22 | list-style: none;
23 | }
24 |
25 | #navbar ul li {
26 | margin-left: 1em;
27 | }
28 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = express.Router();
3 | const ProductController = require("../controllers/ProductController");
4 |
5 | router.get("/", ProductController.showProducts);
6 |
7 | module.exports = router;
8 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Node.js + MongoDB
8 |
9 |
10 |
11 |
16 | {{{ body }}}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/12_MONGODB/2_criando_mvc/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const conn = require('./db/conn').run
6 |
7 | const productsRoutes = require('./routes/productsRoutes')
8 |
9 | app.engine('handlebars', exphbs())
10 | app.set('view engine', 'handlebars')
11 |
12 | app.use(
13 | express.urlencoded({
14 | extended: true,
15 | }),
16 | )
17 |
18 | app.use(express.json())
19 |
20 | app.use(express.static('public'))
21 |
22 | app.use('/', productsRoutes)
23 |
24 | app.listen(3000)
25 |
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/models/Product.js:
--------------------------------------------------------------------------------
1 | const conn = require('../db/conn')
2 |
3 | class Product {
4 | constructor(name, price, description) {
5 | this.name = name
6 | this.price = price
7 | this.description = description
8 | }
9 |
10 | save() {
11 | const product = conn.db().collection('products').insertOne({
12 | name: this.name,
13 | price: this.price,
14 | description: this.description,
15 | })
16 |
17 | return product
18 | }
19 | }
20 |
21 | module.exports = Product
22 |
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = express.Router();
3 | const ProductController = require("../controllers/ProductController");
4 |
5 | router.get("/", ProductController.showProducts);
6 | router.get("/create", ProductController.createProduct);
7 | router.post("/create", ProductController.createProductPost);
8 |
9 | module.exports = router;
10 |
--------------------------------------------------------------------------------
/12_MONGODB/3_inserindo_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
--------------------------------------------------------------------------------
/12_MONGODB/4_resgatando_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/4_resgatando_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/12_MONGODB/4_resgatando_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/4_resgatando_dados/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = express.Router();
3 | const ProductController = require("../controllers/ProductController");
4 |
5 | router.get("/", ProductController.showProducts);
6 | router.get("/create", ProductController.createProduct);
7 | router.post("/create", ProductController.createProductPost);
8 |
9 | module.exports = router;
10 |
--------------------------------------------------------------------------------
/12_MONGODB/4_resgatando_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
9 | {{/each}}
10 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const ProductController = require('../controllers/ProductController')
4 |
5 | router.get('/:id', ProductController.getProduct)
6 | router.get('/', ProductController.showProducts)
7 | router.get('/create', ProductController.createProduct)
8 | router.post('/create', ProductController.createProductPost)
9 |
10 | module.exports = router
11 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
11 |
12 | {{/each}}
13 |
--------------------------------------------------------------------------------
/12_MONGODB/5_resgatando_dado/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const ProductController = require('../controllers/ProductController')
4 |
5 | router.get('/:id', ProductController.getProduct)
6 | router.post('/remove/:id', ProductController.removeProduct)
7 | router.get('/', ProductController.showProducts)
8 | router.get('/create', ProductController.createProduct)
9 | router.post('/create', ProductController.createProductPost)
10 |
11 | module.exports = router
12 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
11 |
12 | {{/each}}
13 |
--------------------------------------------------------------------------------
/12_MONGODB/6_excluindo_dados/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require("mongodb");
2 | // Connection URI
3 | const uri = "mongodb://localhost:27017/testemongodb";
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri);
6 | async function run() {
7 | try {
8 | await client.connect();
9 | console.log("Conectado ao MongoDB!");
10 | } catch (err) {
11 | console.log(err);
12 | }
13 | }
14 |
15 | run();
16 |
17 | module.exports = client;
18 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/routes/productsRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const router = express.Router()
3 | const ProductController = require('../controllers/ProductController')
4 |
5 | router.get('/:id', ProductController.getProduct)
6 | router.post('/remove/:id', ProductController.removeProduct)
7 | router.get('/edit/:id', ProductController.editProduct)
8 | router.get('/', ProductController.showProducts)
9 | router.get('/create', ProductController.createProduct)
10 | router.post('/create', ProductController.createProductPost)
11 |
12 | module.exports = router
13 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/12_MONGODB/7_editando_dados/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/12_MONGODB/8_editando_dado_salvar/db/conn.js:
--------------------------------------------------------------------------------
1 | const { MongoClient } = require('mongodb')
2 | // Connection URI
3 | const uri = 'mongodb://localhost:27017/testemongodb'
4 | // Create a new MongoClient
5 | const client = new MongoClient(uri)
6 | async function run() {
7 | try {
8 | await client.connect()
9 | console.log('Conectado ao MongoDB!')
10 | } catch (err) {
11 | console.log(err)
12 | }
13 | }
14 |
15 | run()
16 |
17 | module.exports = client
18 |
--------------------------------------------------------------------------------
/12_MONGODB/8_editando_dado_salvar/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/12_MONGODB/8_editando_dado_salvar/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/12_MONGODB/8_editando_dado_salvar/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/12_MONGODB/8_editando_dado_salvar/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/1_instalacao/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/1_instalacao/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/1_instalacao/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/1_instalacao/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/1_instalacao/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/2_schema/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/3_inserindo_dados/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/4_lendo_dados/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/5_dado_individual/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/6_editando_dado/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/products', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/7_editando_dado_post/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/testemongoose')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 | const app = express()
4 |
5 | const productsRoutes = require('./routes/productsRoutes')
6 |
7 | app.engine('handlebars', exphbs())
8 | app.set('view engine', 'handlebars')
9 |
10 | app.use(
11 | express.urlencoded({
12 | extended: true,
13 | }),
14 | )
15 |
16 | app.use(express.json())
17 |
18 | app.use(express.static('public'))
19 |
20 | app.use('/products', productsRoutes)
21 |
22 | app.listen(3000)
23 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/models/Product.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../db/conn')
2 | const { Schema } = mongoose
3 |
4 | const Product = mongoose.model(
5 | 'Product',
6 | new Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | },
11 | price: {
12 | type: Number,
13 | required: true,
14 | },
15 | description: {
16 | type: String,
17 | required: true,
18 | },
19 | image: {
20 | type: String,
21 | required: true,
22 | },
23 | }),
24 | )
25 |
26 | module.exports = Product
27 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mongodb": "^4.1.1",
17 | "mongoose": "^6.0.5",
18 | "nodemon": "^2.0.12"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/views/products/all.handlebars:
--------------------------------------------------------------------------------
1 | Todos os produtos
2 |
3 | {{#each products}}
4 |
5 |

6 |
{{this.name}}
7 |
R${{this.price}}
8 |
12 |
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/13_MONGOOSE/8_remocao_de_dado/views/products/product.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
{{product.name}}
4 |
Preço: R${{product.price}}
5 |

6 |
Descrição: {{product.description}}
7 |
10 |
--------------------------------------------------------------------------------
/14_API/1_primeira_api/index.js:
--------------------------------------------------------------------------------
1 | // acesso via browser
2 | const express = require('express')
3 | const app = express()
4 |
5 | app.use(
6 | express.urlencoded({
7 | extended: true,
8 | }),
9 | )
10 |
11 | app.use(express.json())
12 |
13 | app.get('/', (req, res) => {
14 | res.json({ message: 'Primeira rota criada com sucesso!' })
15 | })
16 |
17 | app.listen(3000)
18 |
--------------------------------------------------------------------------------
/14_API/1_primeira_api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_primeira_api",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "nodemon": "^2.0.12"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/14_API/2_rota_com_post/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_primeira_api",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "nodemon": "^2.0.12"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/14_API/3_status_na_resposta/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_primeira_api",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "nodemon": "^2.0.12"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/15_GETAPET/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | backend/public/images/pets/*.png
3 | backend/public/images/pets/*.jpg
4 | backend/public/images/users/*.png
5 | backend/public/images/users/*.jpg
--------------------------------------------------------------------------------
/15_GETAPET/backend/db/conn.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | async function main() {
4 | await mongoose.connect('mongodb://localhost:27017/getapetref')
5 | console.log('Conectou com Mongoose!')
6 | }
7 |
8 | main().catch((err) => console.log(err))
9 |
10 | module.exports = mongoose
11 |
--------------------------------------------------------------------------------
/15_GETAPET/backend/helpers/create-user-token.js:
--------------------------------------------------------------------------------
1 | const jwt = require("jsonwebtoken");
2 |
3 | const createUserToken = async (user, req, res) => {
4 | const token = jwt.sign(
5 | // payload data
6 | {
7 | name: user.name,
8 | id: user._id,
9 | },
10 | "nossosecret"
11 | );
12 |
13 | // return token
14 | res.status(200).json({
15 | message: "Você está autenticado!",
16 | token: token,
17 | userId: user._id,
18 | });
19 | };
20 |
21 | module.exports = createUserToken;
22 |
--------------------------------------------------------------------------------
/15_GETAPET/backend/helpers/get-token.js:
--------------------------------------------------------------------------------
1 | // get token from headers
2 | const getToken = (req) => {
3 | const authHeader = req.headers["authorization"];
4 | const token = authHeader && authHeader.split(" ")[1];
5 |
6 | return token;
7 | };
8 |
9 | module.exports = getToken;
10 |
--------------------------------------------------------------------------------
/15_GETAPET/backend/helpers/get-user-by-token.js:
--------------------------------------------------------------------------------
1 | const jwt = require("jsonwebtoken");
2 |
3 | const User = require("../models/User");
4 |
5 | // get user by jwt token
6 | const getUserByToken = async (token) => {
7 | if (!token) return res.status(401).json({ error: "Acesso negado!" });
8 |
9 | // find user
10 | const decoded = jwt.verify(token, "nossosecret");
11 |
12 | const userId = decoded.id;
13 |
14 | const user = await User.findOne({ _id: userId });
15 |
16 | return user;
17 | };
18 |
19 | module.exports = getUserByToken;
20 |
--------------------------------------------------------------------------------
/15_GETAPET/backend/public/images/pets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/backend/public/images/pets/.gitkeep
--------------------------------------------------------------------------------
/15_GETAPET/backend/public/images/users/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/backend/public/images/users/.gitkeep
--------------------------------------------------------------------------------
/15_GETAPET/frontend/.env.local:
--------------------------------------------------------------------------------
1 | REACT_APP_API='http://localhost:5000/'
--------------------------------------------------------------------------------
/15_GETAPET/frontend/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/assets/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/frontend/src/assets/img/logo.png
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/form/Input.module.css:
--------------------------------------------------------------------------------
1 | .form_control {
2 | display: flex;
3 | flex-direction: column;
4 | margin-bottom: 1em;
5 | }
6 |
7 | .form_control label {
8 | margin-bottom: 0.3em;
9 | font-weight: bold;
10 | font-size: 0.8em;
11 | }
12 |
13 | .form_control input {
14 | padding: 0.7em;
15 | border: 1px solid #777;
16 | border-radius: 5px;
17 | }
18 |
19 | .form_control input::placeholder {
20 | color: #7b7b7b;
21 | }
22 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/form/Select.module.css:
--------------------------------------------------------------------------------
1 | .form_control {
2 | display: flex;
3 | flex-direction: column;
4 | margin-bottom: 1em;
5 | }
6 |
7 | .form_control label {
8 | margin-bottom: 0.6em;
9 | font-weight: bold;
10 | }
11 |
12 | .form_control select {
13 | padding: 0.7em;
14 | border: 1px solid #777;
15 | border-radius: 5px;
16 | }
17 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/Container.js:
--------------------------------------------------------------------------------
1 | import styles from "./Container.module.css";
2 |
3 | function Container({children}) {
4 | return
5 | {children}
6 |
7 | }
8 |
9 | export default Container
10 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/Container.module.css:
--------------------------------------------------------------------------------
1 | .container {
2 | min-height: 60vh;
3 | padding: 1em 2em 3em;
4 | max-width: 1200px;
5 | margin: 0 auto;
6 | }
7 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/Footer.js:
--------------------------------------------------------------------------------
1 | import styles from "./Footer.module.css";
2 |
3 | function Footer() {
4 | return
7 | }
8 |
9 | export default Footer
10 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/Footer.module.css:
--------------------------------------------------------------------------------
1 | .footer {
2 | height: 250px;
3 | display: flex;
4 | align-items: center;
5 | justify-content: center;
6 | background-color: #eee;
7 | color: #444;
8 | border-top: 1px solid #666;
9 | }
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/Message.module.css:
--------------------------------------------------------------------------------
1 | .message {
2 | width: 100%;
3 | padding: 1em;
4 | border: 1px solid #000;
5 | margin: 0 auto;
6 | text-align: center;
7 | max-width: 60%;
8 | margin: 1em auto;
9 | border-radius: 5px;
10 | }
11 |
12 | .success {
13 | color: #155724;
14 | background-color: #d4edda;
15 | border-color: #c3e6cb;
16 | }
17 |
18 | .error {
19 | color: #721c24;
20 | background-color: #f8d7da;
21 | border-color: #f5c6cb;
22 | }
23 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/RoundedImage.js:
--------------------------------------------------------------------------------
1 | import styles from './RoundedImage.module.css'
2 |
3 | function RoundedImage({ src, alt, width }) {
4 | return (
5 |
10 | )
11 | }
12 |
13 | export default RoundedImage
14 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/layout/RoundedImage.module.css:
--------------------------------------------------------------------------------
1 | .rounded_image {
2 | width: 200px;
3 | height: 200px;
4 | border-radius: 100%;
5 | }
6 |
7 | .rounded_image.px75 {
8 | width: 75px;
9 | height: 75px;
10 | }
11 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/pages/Pet/AddPet.module.css:
--------------------------------------------------------------------------------
1 | .addpet_header {
2 | text-align: center;
3 | margin-bottom: 1.2em;
4 | }
5 |
6 | .addpet_header h1 {
7 | margin-bottom: 0.2em;
8 | }
9 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/components/pages/User/Profile.module.css:
--------------------------------------------------------------------------------
1 | .profile_header {
2 | text-align: center;
3 | margin-bottom: 1em;
4 | }
5 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/context/UserContext.js:
--------------------------------------------------------------------------------
1 | import React, { createContext } from "react";
2 |
3 | import useAuth from "../hooks/useAuth";
4 |
5 | const Context = createContext();
6 |
7 | function UserProvider({ children }) {
8 | const { authenticated, loading, register, login, logout } = useAuth();
9 |
10 | return (
11 |
14 | {children}
15 |
16 | );
17 | }
18 |
19 | export { Context, UserProvider };
20 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/hooks/useFlashMessage.js:
--------------------------------------------------------------------------------
1 | import bus from '../utils/bus'
2 |
3 | export default function useFlashMessage() {
4 | function setFlashMessage(msg, type) {
5 | bus.emit('flash', {
6 | message: msg,
7 | type: type,
8 | })
9 | }
10 |
11 | return { setFlashMessage }
12 | }
13 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | padding: 0;
3 | margin: 0;
4 | font-family: Helvetica;
5 | box-sizing: border-box;
6 | }
7 |
8 | h1 {
9 | color: #16479d;
10 | margin-bottom: 1em;
11 | font-size: 2.1em;
12 | }
13 |
14 | .bold {
15 | font-weight: bold;
16 | color: #16479d;
17 | }
18 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root')
11 | );
12 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/utils/api.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 |
3 | export default axios.create({
4 | baseURL: "http://localhost:5000",
5 | });
6 |
--------------------------------------------------------------------------------
/15_GETAPET/frontend/src/utils/bus.js:
--------------------------------------------------------------------------------
1 | import EventEmitter from "events";
2 | export default new EventEmitter();
3 |
--------------------------------------------------------------------------------
/15_GETAPET/pets/labra1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/labra1.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/labra2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/labra2.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/labra3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/labra3.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet1.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet10.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet2.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet3.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet4.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet5.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet6.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet7.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet8.jpg
--------------------------------------------------------------------------------
/15_GETAPET/pets/pet9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/15_GETAPET/pets/pet9.jpg
--------------------------------------------------------------------------------
/16_WHATSAPP_WEB_CLONE/img/avatar1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/16_WHATSAPP_WEB_CLONE/img/avatar1.png
--------------------------------------------------------------------------------
/16_WHATSAPP_WEB_CLONE/img/avatar2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/16_WHATSAPP_WEB_CLONE/img/avatar2.png
--------------------------------------------------------------------------------
/16_WHATSAPP_WEB_CLONE/img/avatar3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/16_WHATSAPP_WEB_CLONE/img/avatar3.png
--------------------------------------------------------------------------------
/16_WHATSAPP_WEB_CLONE/img/avatar4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/16_WHATSAPP_WEB_CLONE/img/avatar4.png
--------------------------------------------------------------------------------
/16_WHATSAPP_WEB_CLONE/img/background_whats.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/16_WHATSAPP_WEB_CLONE/img/background_whats.png
--------------------------------------------------------------------------------
/17_API_REST_NODE_MONGOOSE_YT/models/Person.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | const Person = mongoose.model('Person', {
4 | name: String,
5 | salary: Number,
6 | approved: Boolean,
7 | })
8 |
9 | module.exports = Person
10 |
--------------------------------------------------------------------------------
/17_API_REST_NODE_MONGOOSE_YT/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "17_API_REST_NODE_MONGOOSE_YT",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "nodemon ./index.js localhost 3000"
8 | },
9 | "keywords": [],
10 | "author": "Matheus (http://www.horadecodar.com.br/)",
11 | "license": "MIT",
12 | "dependencies": {
13 | "express": "^4.17.1",
14 | "mongoose": "^6.0.7",
15 | "nodemon": "^2.0.13"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/18_AUTH_NODE_JWT/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .env
--------------------------------------------------------------------------------
/18_AUTH_NODE_JWT/models/User.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 |
3 | const User = mongoose.model('User', {
4 | name: String,
5 | email: String,
6 | password: String,
7 | })
8 |
9 | module.exports = User
10 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/19_REACT_ROUTER_6/app/public/favicon.ico
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/components/Navbar.js:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 |
3 | import styles from './Navbar.module.css'
4 |
5 | function Navbar() {
6 | return (
7 |
20 | )
21 | }
22 |
23 | export default Navbar
24 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/components/Navbar.module.css:
--------------------------------------------------------------------------------
1 | .navbar {
2 | background-color: #ddd;
3 | border-bottom: 1px solid #aaa;
4 | padding: 1em;
5 | margin-bottom: 1em;
6 | }
7 |
8 | .navbar ul {
9 | display: flex;
10 | list-style: none;
11 | }
12 |
13 | .navbar li {
14 | margin-right: 1em;
15 | }
16 |
17 | .navbar li a {
18 | color: #000;
19 | text-decoration: none;
20 | }
21 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/components/pages/Contact.js:
--------------------------------------------------------------------------------
1 | function Contact() {
2 | return Contact
3 | }
4 |
5 | export default Contact
6 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/components/pages/Home.js:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 |
3 | function Home() {
4 | return (
5 |
6 | Home
7 |
8 | Ver todos os usuários: Clique aqui
9 |
10 |
11 | )
12 | }
13 |
14 | export default Home
15 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/components/pages/Users.js:
--------------------------------------------------------------------------------
1 | import { useNavigate } from 'react-router-dom'
2 |
3 | function Users() {
4 | const navigate = useNavigate()
5 |
6 | function handleClick() {
7 | navigate('/')
8 | }
9 |
10 | return (
11 |
12 |
13 | Voltar para a
14 |
15 | Users
16 |
17 | )
18 | }
19 |
20 | export default Users
21 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: Helvetica;
3 | margin: 0;
4 | padding: 0;
5 | }
6 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import './index.css'
4 | import App from './App'
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root'),
11 | )
12 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/19_REACT_ROUTER_6/app_inicio/public/favicon.ico
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/components/Navbar.js:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 |
3 | import styles from './Navbar.module.css'
4 |
5 | function Navbar() {
6 | return (
7 |
20 | )
21 | }
22 |
23 | export default Navbar
24 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/components/Navbar.module.css:
--------------------------------------------------------------------------------
1 | .navbar {
2 | background-color: #ddd;
3 | border-bottom: 1px solid #aaa;
4 | padding: 1em;
5 | margin-bottom: 1em;
6 | }
7 |
8 | .navbar ul {
9 | display: flex;
10 | list-style: none;
11 | }
12 |
13 | .navbar li {
14 | margin-right: 1em;
15 | }
16 |
17 | .navbar li a {
18 | color: #000;
19 | text-decoration: none;
20 | }
21 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/components/pages/Contact.js:
--------------------------------------------------------------------------------
1 | function Contact() {
2 | return Contact
3 | }
4 |
5 | export default Contact
6 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/components/pages/Home.js:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 |
3 | function Home() {
4 | return (
5 |
6 | Home
7 |
8 | Ver todos os usuários: Clique aqui
9 |
10 |
11 | )
12 | }
13 |
14 | export default Home
15 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/components/pages/Users.js:
--------------------------------------------------------------------------------
1 | import { useHistory } from 'react-router-dom'
2 |
3 | function Users() {
4 | const history = useHistory()
5 |
6 | function handleClick() {
7 | history.push('/')
8 | }
9 |
10 | return (
11 |
12 |
13 | Voltar para a
14 |
15 | Users
16 |
17 | )
18 | }
19 |
20 | export default Users
21 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: Helvetica;
3 | margin: 0;
4 | padding: 0;
5 | }
6 |
--------------------------------------------------------------------------------
/19_REACT_ROUTER_6/app_inicio/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import './index.css'
4 | import App from './App'
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root'),
11 | )
12 |
--------------------------------------------------------------------------------
/1_INTRO/1_primeiro_programa/arquivo.js:
--------------------------------------------------------------------------------
1 | console.log('Hello World Node!')
2 |
--------------------------------------------------------------------------------
/1_INTRO/2_utilizando_modulo/arquivo.txt:
--------------------------------------------------------------------------------
1 | Estou aqui!
--------------------------------------------------------------------------------
/1_INTRO/2_utilizando_modulo/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | fs.readFile('arquivo.txt', 'utf8', (err, data) => {
4 | console.log(data)
5 | })
6 |
--------------------------------------------------------------------------------
/1_INTRO/3_tarefa_01/programa.js:
--------------------------------------------------------------------------------
1 | const a = 10;
2 | const b = 5;
3 |
4 | console.log(a + b);
5 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/10_abstracao_input/index.js:
--------------------------------------------------------------------------------
1 | const inquirer = require('inquirer')
2 |
3 | inquirer
4 | .prompt([
5 | { name: 'p1', message: 'Qual a primeira nota?' },
6 | { name: 'p2', message: 'Qual a segunda nota?' },
7 | ])
8 | .then((answers) => {
9 | console.log(answers)
10 | const media = (parseInt(answers.p1) + parseInt(answers.p2)) / 2
11 |
12 | console.log(`A média do aluno é ${media}`)
13 | })
14 | .catch((err) => {
15 | console.log(err)
16 | })
17 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/10_abstracao_input/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "10_abstracao_input",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus (http://www.horadecodar.com.br/)",
11 | "license": "MIT",
12 | "dependencies": {
13 | "inquirer": "^8.1.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/11_event_loop/index.js:
--------------------------------------------------------------------------------
1 | //Order c -> a -> b
2 | function a() {
3 | console.log('Executando a()')
4 | }
5 |
6 | function b() {
7 | console.log('Executando b()')
8 | }
9 |
10 | function c() {
11 | console.log('Executando c()')
12 | a()
13 | b()
14 | }
15 |
16 | c()
17 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/12_event_emitter/index.js:
--------------------------------------------------------------------------------
1 | const EventEmitter = require('events')
2 | const eventEmitter = new EventEmitter()
3 |
4 | eventEmitter.on('start', () => {
5 | console.log('Durante')
6 | })
7 |
8 | console.log('Antes')
9 |
10 | eventEmitter.emit('start')
11 |
12 | console.log('Depois')
13 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/13_sync_async/arquivo.txt:
--------------------------------------------------------------------------------
1 | Oi
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/13_sync_async/assincrono.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | console.log("Início");
4 |
5 | fs.writeFile("arquivo.txt", "Oi", function (err) {
6 | setTimeout(function () {
7 | console.log("Arquivo criado!");
8 | }, 1000);
9 | });
10 |
11 | console.log("Fim");
12 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/13_sync_async/sincrono.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | console.log("Início");
4 |
5 | fs.writeFileSync("arquivo.txt", "Oi");
6 |
7 | console.log("Fim");
8 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/14_erros/throw.js:
--------------------------------------------------------------------------------
1 | const x = "10";
2 |
3 | if (!Number.isInteger(x)) {
4 | throw new Error("O valor de x não é um número inteiro");
5 | }
6 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/14_erros/try_catch.js:
--------------------------------------------------------------------------------
1 | const x = 10;
2 |
3 | try {
4 | x = 2;
5 | } catch (err) {
6 | console.log(`Erro: ${err}`);
7 | }
8 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/15_tarefa_02/index.js:
--------------------------------------------------------------------------------
1 | const inquirer = require('inquirer')
2 | const chalk = require('chalk')
3 |
4 | inquirer
5 | .prompt([
6 | { name: 'nome', message: 'Qual o seu nome?' },
7 | { name: 'idade', message: 'Qual a sua idade?' },
8 | ])
9 | .then((answers) => {
10 | const response = `O nome do usuário é ${answers.nome} e ele tem ${answers.idade} anos`
11 | console.log(chalk.bgYellow.black(response))
12 | })
13 | .catch((err) => {
14 | console.log(err)
15 | })
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/15_tarefa_02/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "13_tarefa_02",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [],
9 | "author": "Matheus (http://www.horadecodar.com.br/)",
10 | "license": "MIT",
11 | "dependencies": {
12 | "chalk": "^4.1.2",
13 | "inquirer": "^8.1.2"
14 | },
15 | "devDependencies": {},
16 | "description": ""
17 | }
18 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/1_modulo_interno/index.js:
--------------------------------------------------------------------------------
1 | const meuModulo = require('./meu_modulo')
2 | const soma = meuModulo.soma
3 |
4 | soma(2, 3)
5 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/1_modulo_interno/meu_modulo.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | soma(a, b) {
3 | console.log(a + b)
4 | },
5 | }
6 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/2_export_import/index.mjs:
--------------------------------------------------------------------------------
1 | import soma from "./meu_modulo.mjs";
2 |
3 | soma(2, 3);
4 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/2_export_import/meu_modulo.mjs:
--------------------------------------------------------------------------------
1 | function soma(a, b) {
2 | console.log(a + b);
3 | }
4 |
5 | export default soma;
6 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/3_core_module/index.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 |
3 | const extension = path.extname("arquivo.php");
4 |
5 | console.log(extension);
6 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/4_ler_argumentos/index.js:
--------------------------------------------------------------------------------
1 | // nome=Matheus
2 |
3 | console.log(process.argv);
4 |
5 | const args = process.argv.slice(2);
6 |
7 | console.log(args);
8 |
9 | const nome = args[0].split("=")[1];
10 |
11 | console.log(nome);
12 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/5_modulos_externos/index.js:
--------------------------------------------------------------------------------
1 | // --nome=Matheus --idade=30
2 | const minimist = require("minimist");
3 |
4 | const args = minimist(process.argv.slice(2));
5 |
6 | console.log(args);
7 |
8 | const nome = args["nome"];
9 | const idade = args["idade"];
10 |
11 | console.log(nome);
12 | console.log(idade);
13 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/5_modulos_externos/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "5_modulos_externos",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "minimist": {
8 | "version": "1.2.5",
9 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
10 | "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/5_modulos_externos/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "5_modulos_externos",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus",
11 | "license": "ISC",
12 | "dependencies": {
13 | "minimist": "^1.2.5"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/6_pratica_com_args/index.js:
--------------------------------------------------------------------------------
1 | // --a=10 --b=20
2 |
3 | // externo
4 | const minimist = require("minimist");
5 |
6 | // interno
7 | const meuModulo = require("./meu_modulo");
8 | const soma = meuModulo.soma;
9 |
10 | const args = minimist(process.argv.slice(2));
11 |
12 | const a = args["a"];
13 | const b = args["b"];
14 |
15 | soma(a, b);
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/6_pratica_com_args/meu_modulo.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | soma(a, b) {
3 | console.log(a + b)
4 | },
5 | }
6 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/6_pratica_com_args/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "5_modulos_externos",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "minimist": {
8 | "version": "1.2.5",
9 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
10 | "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/6_pratica_com_args/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "5_modulos_externos",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus",
11 | "license": "ISC",
12 | "dependencies": {
13 | "minimist": "^1.2.5"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/7_explorando_console/index.js:
--------------------------------------------------------------------------------
1 | // mais de uma valor
2 | const x = 10;
3 | const y = "Matheus";
4 |
5 | console.log(x, y);
6 |
7 | // contagem de impressões
8 | console.count("O valor de x é: " + x + " -> contagem:");
9 | console.count("O valor de x é: " + x + " -> contagem:");
10 | console.count("O valor de x é: " + x + " -> contagem:");
11 | console.count("O valor de y é: " + y + " -> contagem:");
12 |
13 | // variável entre string
14 | console.log("O nome dele é %s", y);
15 |
16 | // limpando console
17 | setTimeout(() => {
18 | console.clear();
19 | }, 2000);
20 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/8_melhorando_visual/index.js:
--------------------------------------------------------------------------------
1 | const chalk = require("chalk");
2 |
3 | const nota = 8;
4 |
5 | if (nota >= 7) {
6 | console.log(chalk.green.bold("Parabéns, você passou!"));
7 | } else {
8 | console.log(chalk.bgRed.black("Você precisa fazer a prova final!"));
9 | }
10 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/8_melhorando_visual/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "2_FUNDAMENTOS",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus",
11 | "license": "ISC",
12 | "dependencies": {
13 | "chalk": "^4.1.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/2_FUNDAMENTOS/9_lendo_input/index.js:
--------------------------------------------------------------------------------
1 | const readline = require("readline").createInterface({
2 | input: process.stdin,
3 | output: process.stdout,
4 | });
5 |
6 | readline.question(`Qual a sua linguagem preferida? `, (language) => {
7 | console.log(`A minha linguagem preferida é: ${language}`);
8 | readline.close();
9 | });
10 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/10_roteamento/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 404
8 |
9 |
10 | 404
11 |
12 |
13 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/10_roteamento/contato.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Contato
8 |
9 |
10 | Contato
11 |
12 |
13 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/10_roteamento/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home
11 |
12 |
13 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/11_detalhes_arquivos/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | fs.stat('novoarquivo.txt', (err, stats) => {
4 | if (err) {
5 | console.error(err)
6 | return
7 | }
8 | console.log(stats.isFile())
9 | console.log(stats.isDirectory())
10 | console.log(stats.isSymbolicLink())
11 | console.log(stats.ctime)
12 | console.log(stats.size)
13 | })
14 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/11_detalhes_arquivos/novoarquivo.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/3_CORE_MODULES/11_detalhes_arquivos/novoarquivo.txt
--------------------------------------------------------------------------------
/3_CORE_MODULES/12_path/index.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 |
3 | const customPath = '/relatorios/matheus/relatorio1.pdf'
4 |
5 | console.log(path.dirname(customPath))
6 | console.log(path.basename(customPath))
7 | console.log(path.extname(customPath))
8 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/13_path_absoluto/index.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 |
3 | // path absoluto
4 | console.log(path.resolve('teste.txt'))
5 |
6 | // formar path
7 | const midFolder = 'relatorios'
8 | const fileName = 'matheus.txt'
9 |
10 | const finalPath = path.join('/', 'arquivos', midFolder, fileName)
11 |
12 | console.log(finalPath)
13 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/13_path_absoluto/teste.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/3_CORE_MODULES/13_path_absoluto/teste.txt
--------------------------------------------------------------------------------
/3_CORE_MODULES/14_trabalhando_com_dirs/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | if (!fs.existsSync('./minhapasta')) {
4 | console.log('Não existe')
5 | }
6 |
7 | fs.mkdirSync('minhapasta')
8 |
9 | if (fs.existsSync('minhapasta')) {
10 | console.log('Existe')
11 | }
12 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/15_modulo_os/index.js:
--------------------------------------------------------------------------------
1 | const os = require("os");
2 |
3 | console.log(os.cpus());
4 |
5 | console.log(os.freemem());
6 |
7 | console.log(os.homedir());
8 |
9 | console.log(os.type());
10 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/1_http/index.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 |
3 | const port = 3000
4 |
5 | const server = http.createServer((req, res) => {
6 | res.write('Oi HTTP')
7 | res.end()
8 | })
9 |
10 | server.listen(port, () => {
11 | console.log(`Servidor rodando na porta: ${port}`)
12 | })
13 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/2_retornando_html/index.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 |
3 | const port = 3000
4 |
5 | const server = http.createServer((req, res) => {
6 | res.statusCode = 200
7 | res.setHeader('Content-Type', 'text/html')
8 | res.end('Olá, este é o meu primeiro server!
')
9 | })
10 |
11 | server.listen(port, () => {
12 | console.log(`Servidor rodando na porta: ${port}`)
13 | })
14 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/3_url/index.js:
--------------------------------------------------------------------------------
1 | const url = require('url')
2 | const address = 'https://www.meusite.com.br/catalogo?produtos=cadeira'
3 | const parsedUrl = new url.URL(address)
4 |
5 | console.log(parsedUrl.host)
6 | console.log(parsedUrl.pathname)
7 | console.log(parsedUrl.search)
8 | console.log(parsedUrl.searchParams)
9 | console.log(parsedUrl.searchParams.get('produtos'))
10 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/5_fs/index.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 | const fs = require("fs");
3 |
4 | const port = 3000;
5 |
6 | const server = http.createServer((req, res) => {
7 | fs.readFile("mensagem.html", function (err, data) {
8 | res.writeHead(200, { "Content-Type": "text/html" });
9 | res.write(data);
10 | return res.end();
11 | });
12 | });
13 |
14 | server.listen(port, () => {
15 | console.log(`Servidor rodando na porta: ${port}`);
16 | });
17 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/5_fs/mensagem.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Mensagem
7 |
8 |
9 | Este arquivo foi lido pelo fs!
10 |
11 |
12 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/6_escrevendo_arquivos/arquivo.txt:
--------------------------------------------------------------------------------
1 | João
--------------------------------------------------------------------------------
/3_CORE_MODULES/6_escrevendo_arquivos/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Mensagem
7 |
8 |
9 | Como você se chama?
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/7_atualizando_arquivos/arquivo.txt:
--------------------------------------------------------------------------------
1 | TesteTesteeeasdasd
2 | asd
3 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/7_atualizando_arquivos/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Mensagem
7 |
8 |
9 | Como você se chama?
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/8_removendo_arquivos/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | fs.unlink('arquivo.txt', function (err) {
4 | if (err) {
5 | console.log(err)
6 | return
7 | }
8 | console.log('Arquivo removido!')
9 | })
10 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/9_renomeando_arquivo/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | fs.rename('arquivo.txt', 'novoarquivo.txt', function (err) {
4 | if (err) {
5 | console.log(err)
6 | return
7 | }
8 | console.log('Arquivo renomeado!')
9 | })
10 |
--------------------------------------------------------------------------------
/3_CORE_MODULES/9_renomeando_arquivo/novoarquivo.txt:
--------------------------------------------------------------------------------
1 | teste
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/1_criando_projeto/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "meu_projeto",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "Matheus",
10 | "license": "ISC"
11 | }
12 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/2_instalando_modulo/index.js:
--------------------------------------------------------------------------------
1 | const _ = require("lodash");
2 |
3 | const a = [1, 2, 3, 4, 5];
4 | const b = [2, 4, 5, 6, 7, 8];
5 |
6 | const diff = _.difference(a, b);
7 |
8 | console.log(diff);
9 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/2_instalando_modulo/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "2_instalando_modulo",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "lodash": {
8 | "version": "4.17.21",
9 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
10 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/2_instalando_modulo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "2_instalando_modulo",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "lodash": "^4.17.21"
8 | },
9 | "devDependencies": {},
10 | "scripts": {
11 | "test": "echo \"Error: no test specified\" && exit 1"
12 | },
13 | "keywords": [],
14 | "author": "Matheus",
15 | "license": "ISC"
16 | }
17 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/3_pacote_de_dev/index.js:
--------------------------------------------------------------------------------
1 | const _ = require("lodash");
2 | const chalk = require("chalk");
3 |
4 | const a = [1, 2, 3];
5 | const b = [4, 5, 6];
6 |
7 | const diff = _.merge(a, b);
8 |
9 | console.log(chalk.red.bold(diff));
10 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/3_pacote_de_dev/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "4_NPM_FUNDAMENTOS",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus",
11 | "license": "ISC",
12 | "dependencies": {
13 | "lodash": "^4.17.21"
14 | },
15 | "devDependencies": {
16 | "chalk": "^4.1.2"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/4_criando_scripts/index.js:
--------------------------------------------------------------------------------
1 | const _ = require("lodash");
2 | const chalk = require("chalk");
3 |
4 | const a = [1, 2, 3];
5 | const b = [4, 5, 6];
6 |
7 | const diff = _.merge(a, b);
8 |
9 | console.log(chalk.red.bold(diff));
10 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/4_criando_scripts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "4_NPM_FUNDAMENTOS",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "lodash": "^4.17.21"
15 | },
16 | "devDependencies": {
17 | "chalk": "^4.1.2"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/5_pacote_global/index.js:
--------------------------------------------------------------------------------
1 | // npm link lodash
2 | const _ = require('lodash')
3 |
4 | const arr = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 8]
5 |
6 | console.log(_.sortedUniq(arr))
7 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/6_executando_npx/arquivo.txt:
--------------------------------------------------------------------------------
1 | npx cowsay -d "Mensagem"
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/7_removendo_pacote/index.js:
--------------------------------------------------------------------------------
1 | const _ = require("lodash");
2 | const chalk = require("chalk");
3 |
4 | const a = [1, 2, 3];
5 | const b = [4, 5, 6];
6 |
7 | const diff = _.merge(a, b);
8 |
9 | console.log(chalk.red.bold(diff));
10 |
--------------------------------------------------------------------------------
/4_NPM_FUNDAMENTOS/7_removendo_pacote/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "4_NPM_FUNDAMENTOS",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {},
14 | "devDependencies": {
15 | "chalk": "^4.1.2"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/as.json:
--------------------------------------------------------------------------------
1 | {"balance":6}
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/teste.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/5_ACCOUNTS/accounts/teste.txt
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/testematheus.json:
--------------------------------------------------------------------------------
1 | {"balance":5000}
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/x.json:
--------------------------------------------------------------------------------
1 | {"balance":0}
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/y.json:
--------------------------------------------------------------------------------
1 | {"balance":0}
--------------------------------------------------------------------------------
/5_ACCOUNTS/accounts/z.json:
--------------------------------------------------------------------------------
1 | {"balance":1000}
--------------------------------------------------------------------------------
/5_ACCOUNTS/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "5_ACCOUNTS",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "chalk": "^4.1.2",
15 | "inquirer": "^8.1.2"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/6_EXPRESS/10_404/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/10_404/public/css/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #dfdfdf;
3 | text-align: center;
4 | padding: 2em;
5 | }
6 |
--------------------------------------------------------------------------------
/6_EXPRESS/10_404/templates/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 404
8 |
9 |
10 |
11 | Ops! Página não encontrada.
12 |
13 |
14 |
--------------------------------------------------------------------------------
/6_EXPRESS/10_404/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 |
11 | Home Express! Atualização
12 |
13 |
14 |
--------------------------------------------------------------------------------
/6_EXPRESS/10_404/templates/users.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Usuários
8 |
9 |
10 | Carregando usuário...
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/11_tarefa_3/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const port = 5000
4 |
5 | const projects = require('./projects')
6 |
7 | app.use(express.static('public'))
8 |
9 | app.use('/projects', projects)
10 |
11 | app.listen(port, () => {
12 | console.log(`App rodando na porta:${port}`)
13 | })
14 |
--------------------------------------------------------------------------------
/6_EXPRESS/11_tarefa_3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "11_tarefa_3",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "serve": "nodemon ./index.js localhost 5000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "nodemon": "^2.0.12"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/6_EXPRESS/11_tarefa_3/projects/index.js:
--------------------------------------------------------------------------------
1 | var express = require('express')
2 | var router = express.Router()
3 |
4 | const path = require('path')
5 |
6 | const basePath = path.join(__dirname, '../templates')
7 |
8 | router.get('/', (req, res) => {
9 | res.sendFile(`${basePath}/projects.html`)
10 | })
11 |
12 | router.get('/:id', (req, res) => {
13 | res.sendFile(`${basePath}/project.html`)
14 | })
15 |
16 | module.exports = router
17 |
--------------------------------------------------------------------------------
/6_EXPRESS/11_tarefa_3/public/css/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #000;
3 | color: #fff;
4 | padding: 50px;
5 | text-align: center;
6 | }
7 |
--------------------------------------------------------------------------------
/6_EXPRESS/11_tarefa_3/templates/project.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Projetos
8 |
9 |
10 | Projeto
11 | Descrição do projeto
12 |
13 |
14 |
--------------------------------------------------------------------------------
/6_EXPRESS/1_instalacao/index.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matheusbattisti/curso_node/42f65598deb89a05d03b592ae506765cc2cd3b2f/6_EXPRESS/1_instalacao/index.js
--------------------------------------------------------------------------------
/6_EXPRESS/1_instalacao/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus (http://www.horadecodar.com.br/)",
11 | "license": "MIT",
12 | "dependencies": {
13 | "express": "^4.17.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/6_EXPRESS/2_setup/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const port = 3000
4 |
5 | app.get('/', (req, res) => {
6 | res.send('Olá Mundo!!')
7 | })
8 |
9 | app.listen(port, () => {
10 | console.log(`App rodando na porta:${port}`)
11 | })
12 |
--------------------------------------------------------------------------------
/6_EXPRESS/2_setup/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus (http://www.horadecodar.com.br/)",
11 | "license": "MIT",
12 | "dependencies": {
13 | "express": "^4.17.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/6_EXPRESS/3_render_html/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const port = 3000
4 |
5 | const path = require('path')
6 |
7 | const basePath = path.join(__dirname, 'templates')
8 |
9 | app.get('/', (req, res) => {
10 | res.sendFile(`${basePath}/index.html`)
11 | })
12 |
13 | app.listen(port, () => {
14 | console.log(`App rodando na porta:${port}`)
15 | })
16 |
--------------------------------------------------------------------------------
/6_EXPRESS/3_render_html/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "Matheus (http://www.horadecodar.com.br/)",
11 | "license": "MIT",
12 | "dependencies": {
13 | "express": "^4.17.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/6_EXPRESS/3_render_html/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express!
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/4_nodemon/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const port = 3000
4 |
5 | const path = require('path')
6 |
7 | const basePath = path.join(__dirname, 'templates')
8 |
9 | app.get('/', (req, res) => {
10 | res.sendFile(`${basePath}/index.html`)
11 | })
12 |
13 | app.listen(port, () => {
14 | console.log(`App rodando na porta:${port}`)
15 | })
16 |
--------------------------------------------------------------------------------
/6_EXPRESS/4_nodemon/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/4_nodemon/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express! Atualização
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/5_middleware/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/5_middleware/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express! Atualização
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/6_parametro_na_rota/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/6_parametro_na_rota/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express! Atualização
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/6_parametro_na_rota/templates/users.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Usuários
8 |
9 |
10 | Carregando usuário...
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/7_post_de_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/7_post_de_dados/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express! Atualização
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/7_post_de_dados/templates/users.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Usuários
8 |
9 |
10 | Carregando usuário...
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/8_modulo_rotas/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/8_modulo_rotas/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 | Home Express! Atualização
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/8_modulo_rotas/templates/users.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Usuários
8 |
9 |
10 | Carregando usuário...
11 |
12 |
13 |
--------------------------------------------------------------------------------
/6_EXPRESS/9_colocando_css/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1"
15 | },
16 | "devDependencies": {
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/6_EXPRESS/9_colocando_css/public/css/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #dfdfdf;
3 | text-align: center;
4 | padding: 2em;
5 | }
6 |
--------------------------------------------------------------------------------
/6_EXPRESS/9_colocando_css/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Home
8 |
9 |
10 |
11 | Home Express! Atualização
12 |
13 |
14 |
--------------------------------------------------------------------------------
/6_EXPRESS/9_colocando_css/templates/users.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Usuários
8 |
9 |
10 | Carregando usuário...
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/10_tarefa_4/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/10_tarefa_4/public/css/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #333;
3 | color: #fff;
4 | padding: 30px;
5 | }
6 |
7 | a {
8 | color: #dfdfdf;
9 | }
10 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/10_tarefa_4/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Confira nossos produtos:
2 | {{#each products}}
3 |
4 |
{{this.title}}
5 |
R${{this.price}}
6 |
Ver mais
7 |
8 | {{/each}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/10_tarefa_4/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | E-commerce
8 |
9 |
10 |
11 | {{{ body }}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/10_tarefa_4/views/product.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{product.title}}
3 | R${{product.price}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/1_instalacao_handle/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 |
4 | const app = express()
5 |
6 | app.engine('handlebars', exphbs())
7 | app.set('view engine', 'handlebars')
8 |
9 | app.get('/', function (req, res) {
10 | res.render('home', { layout: false })
11 | })
12 |
13 | app.listen(3000)
14 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/1_instalacao_handle/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | Olá Handlebars!
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/2_criando_layouts/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 |
4 | const app = express()
5 |
6 | app.engine('handlebars', exphbs())
7 | app.set('view engine', 'handlebars')
8 |
9 | app.get('/', function (req, res) {
10 | res.render('home')
11 | })
12 |
13 | app.listen(3000)
14 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/2_criando_layouts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/2_criando_layouts/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá Handlebars com Layout!
3 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/2_criando_layouts/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/3_enviando_dados/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 |
4 | const app = express()
5 |
6 | app.engine('handlebars', exphbs())
7 | app.set('view engine', 'handlebars')
8 |
9 | app.get('/', function (req, res) {
10 | const user = {
11 | name: 'Matheus',
12 | surname: 'Battisti',
13 | }
14 |
15 | res.render('home', { user: user })
16 | })
17 |
18 | app.listen(3000)
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/3_enviando_dados/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/3_enviando_dados/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/4_condicionais/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const exphbs = require("express-handlebars");
3 |
4 | const app = express();
5 |
6 | app.engine("handlebars", exphbs());
7 | app.set("view engine", "handlebars");
8 |
9 | app.get("/", function (req, res) {
10 | const user = {
11 | name: "Matheus",
12 | surname: "Battisti",
13 | };
14 |
15 | res.render("home", { user: user, auth: true });
16 | });
17 |
18 | app.get("/dashboard", function (req, res) {
19 | res.render("dashboard");
20 | });
21 |
22 | app.listen(3000);
23 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/4_condicionais/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/4_condicionais/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if auth}}
5 |
6 | Você está autenticado no sistema, clique aqui para acessar a área de membros
7 |
8 | {{/if}}
9 |
10 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/4_condicionais/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/5_else/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/5_else/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/5_else/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if approved}}
5 | Parabéns, o seu cadastro está aprovado!
6 | {{else}}
7 | O seu cadastro ainda necessita de aprovação!
8 | {{/if}}
9 |
10 | {{#if auth}}
11 |
12 | Você está autenticado no sistema, clique aqui para acessar a área de membros
13 |
14 | {{/if}}
15 |
16 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/5_else/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/6_loops/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/6_loops/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
4 |
5 |
6 | {{#each items}}
7 | - {{this}}
8 | {{/each}}
9 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/6_loops/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if auth}}
5 |
6 | Você está autenticado no sistema, clique aqui para acessar a área de membros
7 |
8 | {{/if}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/6_loops/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/7_with/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/7_with/views/blogpost.handlebars:
--------------------------------------------------------------------------------
1 | {{#with post}}
2 | {{title}}
3 | {{category}}
4 | {{body}}
5 | Número de comentários: {{comments}}
6 | {{/with}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/7_with/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
4 |
5 |
6 | {{#each items}}
7 | - {{this}}
8 | {{/each}}
9 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/7_with/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if auth}}
5 |
6 | Você está autenticado no sistema, clique aqui para acessar a área de membros
7 |
8 | {{/if}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/7_with/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_handle",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus (http://www.horadecodar.com.br/)",
12 | "license": "MIT",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "nodemon": "^2.0.12"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/blog.handlebars:
--------------------------------------------------------------------------------
1 | Veja nossos posts
2 | {{#each posts}}
3 | {{> post}}
4 | {{/each}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/blogpost.handlebars:
--------------------------------------------------------------------------------
1 | {{#with post}}
2 | {{title}}
3 | {{category}}
4 | {{body}}
5 | Número de comentários: {{comments}}
6 | {{/with}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
4 |
5 |
6 | {{#each items}}
7 | - {{this}}
8 | {{/each}}
9 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if auth}}
5 |
6 | Você está autenticado no sistema, clique aqui para acessar a área de membros
7 |
8 | {{/if}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 | {{{ body }}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/8_partials/views/partials/post.handlebars:
--------------------------------------------------------------------------------
1 | {{this.title}}
2 | Categoria: {{this.category}}
3 | Ver post
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/public/css/styles.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: red;
3 | }
4 |
5 | h2 {
6 | color: blue;
7 | }
8 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/blog.handlebars:
--------------------------------------------------------------------------------
1 | Veja nossos posts
2 | {{#each posts}}
3 | {{> post}}
4 | {{/each}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/blogpost.handlebars:
--------------------------------------------------------------------------------
1 | {{#with post}}
2 | {{title}}
3 | {{category}}
4 | {{body}}
5 | Número de comentários: {{comments}}
6 | {{/with}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/dashboard.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Dashboard de usuários!
3 |
4 |
5 |
6 | {{#each items}}
7 | - {{this}}
8 | {{/each}}
9 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/home.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Olá {{ user.name }} {{ user.surname }}, seja bem-vindo!
3 |
4 | {{#if auth}}
5 |
6 | Você está autenticado no sistema, clique aqui para acessar a área de membros
7 |
8 | {{/if}}
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Handlebars
8 |
9 |
10 |
11 | {{{ body }}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/7_TEMPLATE_ENGINE/9_css_handlebars/views/partials/post.handlebars:
--------------------------------------------------------------------------------
1 | {{this.title}}
2 | Categoria: {{this.category}}
3 | Ver post
--------------------------------------------------------------------------------
/8_MYSQL/1_instalacao_mysql/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/1_instalacao_mysql/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Homepage
--------------------------------------------------------------------------------
/8_MYSQL/1_instalacao_mysql/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Node.js + MySQL
8 |
9 |
10 |
11 | {{{ body }}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/8_MYSQL/2_inserindo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/2_inserindo_dados/public/css/styles.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: Helvetica, sans-serif;
3 | }
4 |
5 | h1 {
6 | text-align: center;
7 | }
8 |
9 | .form {
10 | width: 450px;
11 | margin: 0 auto;
12 | }
13 |
14 | .form-control {
15 | display: flex;
16 | flex-direction: column;
17 | margin-bottom: 0.5em;
18 | }
19 |
20 | .form-control label {
21 | font-weight: bold;
22 | margin-bottom: 0.3em;
23 | }
24 |
25 | .form-control input {
26 | padding: 5px;
27 | }
28 |
--------------------------------------------------------------------------------
/8_MYSQL/2_inserindo_dados/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/2_inserindo_dados/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Node.js + MySQL
8 |
9 |
10 |
11 | {{{ body }}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/8_MYSQL/3_resgatando_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/3_resgatando_dados/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
#{{this.id}} - {{this.title}} - {{this.pageqty}} páginas
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/3_resgatando_dados/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/3_resgatando_dados/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Node.js + MySQL
8 |
9 |
10 |
11 | {{{ body }}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/8_MYSQL/4_dado_especifico/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/4_dado_especifico/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
7 |
--------------------------------------------------------------------------------
/8_MYSQL/4_dado_especifico/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/4_dado_especifico/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/5_editando_dado/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/5_editando_dado/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
9 |
10 |
--------------------------------------------------------------------------------
/8_MYSQL/5_editando_dado/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/5_editando_dado/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/6_realizando_update/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/6_realizando_update/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
9 |
10 |
--------------------------------------------------------------------------------
/8_MYSQL/6_realizando_update/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/6_realizando_update/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/7_removendo_dados/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/7_removendo_dados/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
12 |
13 |
--------------------------------------------------------------------------------
/8_MYSQL/7_removendo_dados/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/7_removendo_dados/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/8_connection_pool/db/conn.js:
--------------------------------------------------------------------------------
1 | const mysql = require('mysql')
2 |
3 | const pool = mysql.createPool({
4 | connectionLimit: 10,
5 | host: 'localhost',
6 | user: 'root',
7 | password: '',
8 | database: 'nodemysql',
9 | })
10 |
11 | module.exports = pool
12 |
--------------------------------------------------------------------------------
/8_MYSQL/8_connection_pool/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/8_connection_pool/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
12 |
13 |
--------------------------------------------------------------------------------
/8_MYSQL/8_connection_pool/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/8_connection_pool/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/8_MYSQL/9_preparando_query/db/conn.js:
--------------------------------------------------------------------------------
1 | const mysql = require('mysql')
2 |
3 | const pool = mysql.createPool({
4 | connectionLimit: 10,
5 | host: 'localhost',
6 | user: 'root',
7 | password: '',
8 | database: 'nodemysql',
9 | })
10 |
11 | module.exports = pool
12 |
--------------------------------------------------------------------------------
/8_MYSQL/9_preparando_query/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1_instalacao_mysql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon ./index.js localhost 3000"
9 | },
10 | "keywords": [],
11 | "author": "Matheus",
12 | "license": "ISC",
13 | "dependencies": {
14 | "express": "^4.17.1",
15 | "express-handlebars": "^5.3.3",
16 | "mysql": "^2.18.1",
17 | "nodemon": "^2.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/8_MYSQL/9_preparando_query/views/book.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Voltar
3 |
4 |
{{book.title}}
5 |
Este livro tem {{book.pageqty}} páginas.
6 |
12 |
13 |
--------------------------------------------------------------------------------
/8_MYSQL/9_preparando_query/views/books.handlebars:
--------------------------------------------------------------------------------
1 | Livros disponíveis:
2 |
3 | {{#each books}}
4 |
5 | {{/each}}
6 |
--------------------------------------------------------------------------------
/8_MYSQL/9_preparando_query/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Cadastre o seu livro:
2 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/10_add_relacionado/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/10_add_relacionado/models/Address.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = require('./User')
6 |
7 | const Address = db.define('Address', {
8 | street: {
9 | type: DataTypes.STRING,
10 | allowNull: false,
11 | },
12 | number: {
13 | type: DataTypes.STRING,
14 | },
15 | city: {
16 | type: DataTypes.STRING,
17 | },
18 | })
19 |
20 | Address.belongsTo(User)
21 |
22 | module.exports = Address
23 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/10_add_relacionado/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/10_add_relacionado/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/11_select_relacionados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/11_select_relacionados/models/Address.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = require('./User')
6 |
7 | const Address = db.define('Address', {
8 | street: {
9 | type: DataTypes.STRING,
10 | allowNull: false,
11 | },
12 | number: {
13 | type: DataTypes.STRING,
14 | },
15 | city: {
16 | type: DataTypes.STRING,
17 | },
18 | })
19 |
20 | User.hasMany(Address)
21 | Address.belongsTo(User)
22 |
23 | module.exports = Address
24 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/11_select_relacionados/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/11_select_relacionados/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/12_delete_relacionados/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/12_delete_relacionados/models/Address.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = require('./User')
6 |
7 | const Address = db.define('Address', {
8 | street: {
9 | type: DataTypes.STRING,
10 | allowNull: false,
11 | },
12 | number: {
13 | type: DataTypes.STRING,
14 | },
15 | city: {
16 | type: DataTypes.STRING,
17 | },
18 | })
19 |
20 | User.hasMany(Address)
21 | Address.belongsTo(User)
22 |
23 | module.exports = Address
24 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/12_delete_relacionados/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/12_delete_relacionados/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/1_instalacao/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | try {
9 | sequelize.authenticate()
10 | console.log('Conectamos com o Sequelize!')
11 | } catch (error) {
12 | console.error('Não foi possível conectar:', error)
13 | }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/1_instalacao/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const exphbs = require('express-handlebars')
3 |
4 | const app = express()
5 |
6 | const conn = require('./db/conn')
7 |
8 | app.engine('handlebars', exphbs())
9 | app.set('view engine', 'handlebars')
10 |
11 | app.use(
12 | express.urlencoded({
13 | extended: true,
14 | }),
15 | )
16 |
17 | app.use(express.json())
18 |
19 | app.use(express.static('public'))
20 |
21 | app.get('/', function (req, res) {
22 | res.render('home')
23 | })
24 |
25 | app.listen(3000)
26 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/1_instalacao/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Olá Sequelize
--------------------------------------------------------------------------------
/9_SEQUELIZE/1_instalacao/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Sequelize
8 |
9 |
10 |
11 |
16 | {{{ body }}}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/2_model/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/2_model/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/2_model/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Olá Sequelize
--------------------------------------------------------------------------------
/9_SEQUELIZE/2_model/views/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Sequelize
8 |
9 |
10 |
11 |
16 | {{{ body }}}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/3_insert/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/3_insert/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/3_insert/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Olá Sequelize
--------------------------------------------------------------------------------
/9_SEQUELIZE/4_select/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/4_select/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/4_select/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Usuários cadastrados
2 |
3 | {{#each users}}
4 |
7 | {{/each}}
8 |
9 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/5_where/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/5_where/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/5_where/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Usuários cadastrados
2 |
3 | {{#each users}}
4 |
5 |
{{this.name}}
6 |
{{this.occupation}}
7 |
10 |
11 | {{/each}}
12 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/5_where/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/6_delete/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/6_delete/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/6_delete/views/home.handlebars:
--------------------------------------------------------------------------------
1 | Usuários cadastrados
2 |
3 | {{#each users}}
4 |
5 |
{{this.name}}
6 |
{{this.occupation}}
7 |
13 |
14 | {{/each}}
15 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/6_delete/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/7_edit/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/7_edit/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/7_edit/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/8_update/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/8_update/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/8_update/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------
/9_SEQUELIZE/9_relacionamento/db/conn.js:
--------------------------------------------------------------------------------
1 | const { Sequelize } = require('sequelize')
2 |
3 | const sequelize = new Sequelize('nodesequelize', 'root', '', {
4 | host: 'localhost',
5 | dialect: 'mysql',
6 | })
7 |
8 | // try {
9 | // sequelize.authenticate()
10 | // console.log('Conectamos com o Sequelize!')
11 | // } catch (error) {
12 | // console.error('Não foi possível conectar:', error)
13 | // }
14 |
15 | module.exports = sequelize
16 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/9_relacionamento/models/Address.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = require('./User')
6 |
7 | const Address = db.define('Address', {
8 | street: {
9 | type: DataTypes.STRING,
10 | allowNull: false,
11 | },
12 | number: {
13 | type: DataTypes.STRING,
14 | },
15 | city: {
16 | type: DataTypes.STRING,
17 | },
18 | })
19 |
20 | Address.belongsTo(User)
21 |
22 | module.exports = Address
23 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/9_relacionamento/models/User.js:
--------------------------------------------------------------------------------
1 | const { DataTypes } = require('sequelize')
2 |
3 | const db = require('../db/conn')
4 |
5 | const User = db.define('User', {
6 | name: {
7 | type: DataTypes.STRING,
8 | allowNull: false,
9 | },
10 | occupation: {
11 | type: DataTypes.STRING,
12 | },
13 | newsletter: {
14 | type: DataTypes.BOOLEAN,
15 | },
16 | })
17 |
18 | module.exports = User
19 |
--------------------------------------------------------------------------------
/9_SEQUELIZE/9_relacionamento/views/userview.handlebars:
--------------------------------------------------------------------------------
1 | Voltar
2 | {{user.name}}
3 | {{user.occupation}}
--------------------------------------------------------------------------------