Introdução a NodeJS

Description

Uma transcrição do curso de NodeJS da Alura, recomendado acompanhar junto ao curso.
Rafael Mendes
Mind Map by Rafael Mendes, updated more than 1 year ago
Rafael Mendes
Created by Rafael Mendes about 7 years ago
30
1
1 2 3 4 5 (0)

Resource summary

Introdução a NodeJS
  1. Instalação
    1. Instalar node e #node -v - Visualizar versão do NodeJS
    2. Rodando NodeJS
      1. #node arquivo.js -> reproduz/inicia o arquivo no NodeJS
        1. Reproduzindo um servidor e respondendo um HTML

          Annotations:

          • var http = require("http"); http.createServer(function(req,res) { res.end("SEU HTML");}).listen(3000);
          1. Trabalhando com variações de endereço, ex: /produtos , /produtos/detalhe
            1. Express Framework
              1. Instalar através do Node Package Manager - NPM

                Annotations:

                • # npm -version # npm init - criar config inicial description: site da casa do codigo # npm install express -save
                1. Rodando Express Framework

                  Annotations:

                  • var express = require("express")(); express.get("/produtos",function (req,res) { res.send("<html>LISTAGEM DE PRODUTOS</html>"); }); express.listen(3000,function(){ console.log("rodando");});
                  1. Auxilio do projeto com EJS

                    Annotations:

                    • # npm install ejs --save
                    1. Criar pasta views > nodejs/views
                      1. Dentro de 'views', criar todo os diretórios ref as paginas > nodejs/views/produto/lista.ejs
                        1. Renderizar a página

                          Annotations:

                          • produtosWeb.js : express.get("/produtos",function (req,res) { res.render("produtos/lista"); });
              2. Dificuldade de trabalhar, muitos IFs para cada variação

                Annotations:

                • if(request.url == "/produtos"){ respond.end("<html>"); } if(request.url =="/produtos/detalhe"){ respond.end("<html>"); } if(request.url =="/produtos/detalhe/cor"){ respond.end("<html>"); }
          Show full summary Hide full summary

          0 comments

          There are no comments, be the first and leave one below:

          Similar

          Study Plan
          mlanders
          GCSE Maths Quiz
          Andrea Leyden
          English Language Terms
          ekimlauretta
          Cultural Studies
          Emily Fenton
          A View from the Bridge
          Mrs Peacock
          GCSE Chemistry C3 (OCR)
          Usman Rauf
          Prep Like a Pro with GoConqr's Revision Timetable
          Mike Nervo
          Periodic table - full deck of element symbols
          Derek Cumberbatch
          2PR101 1. test - 5. část
          Nikola Truong
          PSBD/PSCOD/ASSD-New
          Yuvraj Sunar