Node.js 기본과 •

  • View
    432

  • Download
    0

Embed Size (px)

Text of Node.js 기본과 •

  • Node.js

    - 2

    Socket.io

    syhong0714@gmail.com

  • 1. Node.js 2. Udemy - https://www.udemy.com/understand-nodejs

    3. T - https://tacademy.sktechx.com/live/player/listOnline.action

    4. 2 Node.js

  • 2 Node.js

    Node.js

    RUBY

    RubyonRails

    Node.js

    Express

  • async I/Oevent -driven

    +a?

    2 Node.js

  • 2 Node.js

    fs,http

    mysql,mongoose,aws-sdk,express,

    body-parser,jade,ejs,underscore,

    socket.io,supervisor,

    NPM

    gem

  • 2 Node.js

    Doc()

    var fs=require('fs');

    //Asyncfs.readFile('data.txt',{encoding:'utf8'}, function(err,data){

    console.log(data);})

    https://nodejs.org/en/docs

  • 2 Node.js

    -g

    --save

    package.json

    https://www.npmjs.com

  • 2 Node.js

    syncvs.asyncvar fs=require('fs');

    //Syncvar data=fs.readFileSync('data.txt',{encoding:'utf8'});console.log(data);

    //Asyncfs.readFile('data.txt',{encoding:'utf8'}, function(err,data){

    console.log(data);})

  • 2 Node.js

    syncvs.asyncvar fs=require('fs');

    //Syncconsole.log(1);var data=fs.readFileSync('data.txt',{encoding:'utf8'});console.log(data);

    //Asyncconsole.log(2);fs.readFile('data.txt',{encoding:'utf8'}, function(err,data){

    console.log(3);console.log(data);

    })console.log(4);

  • 2 Node.js

    -const /var

    - moduleexport

    - object()

    - method,property

    - argument

    - call-backfunction

    - request,response

  • 2 Node.js

    express

    RUBY

    RubyonRails

    Node.js

    Express

  • 2 Node.js

    expressmodule

    //Routing forthehometabapp.get('/', function(req,res){

    res.render('index');});

    //Exportingexpressmodulevar express=require('express');var app=express();

  • 2 Node.js

    mysql module//Exportingmysql modulevarmysql =require('mysql');

    //Mysql connectionvar client=mysql.createConnection({

    host:'localhost',user:'root',password:12345678,database:'dontmiss'

    });

  • 2 Node.js

    jade/ejs / angular

    body-parserBody

    POST method

  • 2 Node.js

    Get/Post//Routing forthe1sttabapp.get('/newsfeed', function(req,res){

    //SelectQueryclient.query('SELECT*FROMschedule', function(err,results){

    if(err){console.log(err);

    }res.render('newsfeed', {results:results});

    });});

    //Routing forthe2nd tab- postapp.post('/myfeed', function(req,res){

    vardata={'title':req.body.title,'description':req.body.description};

    //InsertQueryclient.query('INSERTINTOscheduleset?',data,function(err

    result){if(err){

    console.error(err);throwerr;

    }res.send(200, 'POSTSuccess!');

    });});

  • 1. AWS EC2Nodejs install Gabia DNS server setting - Ordernow.co.krRoute53 - url setting ?Ngnix

    2. ejs module 5 tabs - Newsfeed, pg&md list, upload, chatting, my list

    3. /AWS RDS - ec2Mysql module Db - User(username, password, email, img_user, description, pg_yes, md_yes) Photo(user_id, uploaded_datetime, url)

    4. /Passport module Sign up, log in()

    5. Upload AWS S3 Body-parser module (post) -, ,

    6. Newsfeed(, , , , , ) Mylist(, , , )

    7. /MylistpostDb-md, pg(user_id, description, price, img_pf1) md or pgPg&md listNewsfeed pf

    8.ChattingDb-chat mongooseSocket.io

  • 1. AWS EC2Nodejs install Gabia DNS server setting - Ordernow.co.krRoute53 - url setting ?Ngnix

    2. ejs module 5 tabs - Newsfeed, pg&md list, upload, chatting, my list

    3. /AWS RDS - ec2Mysql module Db - User(username, password, email, img_user, description, pg_yes, md_yes) Photo(user_id, uploaded_datetime, url)

    4. /Passport module Sign up, log in()

    5. Upload AWS S3 Body-parser module (post) -, ,

    6. Newsfeed(, , , , , ) Mylist(, , , )

    7. /MylistpostDb-md, pg(user_id, description, price, img_pf1) md or pgPg&md listNewsfeed pf

    8.ChattingDb-chat mongooseSocket.io

  • Node.js

    - 2

    syhong0714@gmail.com

  • 1. AWS EC2Nodejs install Gabia DNS server setting - Ordernow.co.krRoute53 - url setting ?Ngnix

    2. ejs module 5 tabs - Newsfeed, pg&md list, upload, chatting, my list

    3. /AWS RDS - ec2Mysql module Db - User(username, password, email, img_user, description, pg_yes, md_yes) Photo(user_id, uploaded_datetime, url)

    4. /Passport module Sign up, log in()

    5. Upload AWS S3 Body-parser module (post) -, ,

    6. Newsfeed(, , , , , ) Mylist(, , , )

    7. /MylistpostDb-md, pg(user_id, description, price, img_pf1) md or pgPg&md listNewsfeed pf

    8.ChattingDb-chat mongooseSocket.io

  • 1. AWS EC2Nodejs install Gabia DNS server setting - Ordernow.co.krRoute53 - url setting ?Ngnix

    2. ejs module 5 tabs - Newsfeed, model_list, chatting, my_page

    3. /AWS RDS - ec2Mysql module Db - User(username, password, email, img_user, description, pg_yes, md_yes) Photo(user_id, uploaded_datetime, url)

    4. /Passport module Sign up, log in()

    5. Upload AWS S3 Body-parser module (post) -, ,

    6. Newsfeed(, , , , , ) Mylist(, , , )

    7. /MylistpostDb-md, pg(user_id, description, price, img_pf1) md or pgPg&md listNewsfeed pf

    8.ChattingDb-chat mongooseSocket.io

  • 1. AWS EC2Nodejs install Gabia DNS server setting - Ordernow.co.krRoute53 - url setting ?Ngnix

    2. ejs module 4 tabs - Newsfeed, pg&md list, chatting, my list

    3. /AWS RDS - ec2Mysql module Db - User(username, password, email, img_user, description, pg_yes, md_yes) Photo(user_id, uploaded_datetime, url)

    4. /Passport module Sign up, log in()

    Nginx ?

    Ejs vs.Jade(Pug)

    Mysql vs.MariaDB

  • 2 Node.js

    Nginx

    LAMP Apache

    , ?

    .

  • 2 Node.js

  • 2 Node.js

    ordernow.co.kr

  • API

    - 2

    syhong0714@gmail.com

  • 2 Node.js

    RestAPI

    WWWSoftwareArchitectureStyle

    REpresentational StateTransfer

    :

  • 2 Node.js

    RestAPIResource,Method,Message(URI)

    terry .

    HTTP Post, http://myweb/users/{

    name:terry}

    : /users

    URI: /users/{user}

  • 2 Node.js

    2. =

    1.(plural)

    Usersvs. Models

    users,books

    /api/v1/users?type=model /api/v1/models

  • 2 Node.js

    Post,Put,Get,Delete

    Create,Read,Update,Delete

    Resource,Method,Message(URI)

    terry .

    HTTP get, http://myweb/users/terry

    http://myweb/users , id terry , suwon

    HTTP Post, http://myweb/users/{

    name:terry}

  • 2 Node.js

    URI1. /api/v1/users

    2. requestheader

    3. contenttype

    : https://www.troyhunt.com/your-api-versioning-is-wrong-which-is/

  • 2 Node.js

  • 2 Node.js

    ordernow.co.kr/api/v1/books

  • 2 Node.js

    postman

  • 2 Node.js

    var apiRoutes =express.Router();