Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Express 프레임워크

1,486 views

Published on

아키텍트를 꿈꾸는 사람들 오후반
nodejs 발표자료 chap.express framework

Published in: Software
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes.........ACCESS WEBSITE Over for All Ebooks ..... (Unlimited) ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • ACCESS that WEBSITE Over for All Ebooks (Unlimited) ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... DOWNLOAD FULL EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH }
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes.........ACCESS WEBSITE Over for All Ebooks ..... (Unlimited) ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Express 프레임워크

  1. 1. Node.js CHAPTER 7 Express 프레임워크 yarn
  2. 2. framework? • framework • 효율적으로 개발하기 위해 필요한 기능 및 아키텍 쳐를 미리 만들어 제공하는 라이러리 집합
  3. 3. Node framework • Express • Sinatra • RESTful • Geddy • Rails • MVC
  4. 4. Express 특징 • Robust routing • HTTP helpers (redirection, caching, etc) • Content negotiation • Focus on high performance • Executable for generating applications quickly • High test coverage
  5. 5. Express 처음 시작하기
  6. 6. express folder Main source code HTML view template URL 별로 수행되는 로직 HTML, 그림, js, css static 파일 필요한 모듈
  7. 7. app.js
  8. 8. app.get('/', routes.index); *지정된 뷰를 일련의 옵션으로 렌더링 한다 현재는 page의 title을 Express로 랜더링.
  9. 9. configure • Configure 함수로 옵션들을 구성 • 첫번째 매개변수는 서버 환경 (dev, stg, prd) • 두번째는 설정 옵션 • NODE_ENV 환경변수를 통해 제어 • 기본적으로 development
  10. 10. app.set() • View의 위치나 view engine 설정하는데 사용.
  11. 11. 에러처리
  12. 12. 에러처리-사용자 정의 함수 에러처리 함수는 4개의 변수를 매개 변수를 받고 error 첫번째 매개변수로 받는다. 어떤 path도 mapping 되지 않는 경우 404 처리 후 , next 함수로 다음 함수 호출
  13. 13. Express/connect • Connect의 세션 미들웨어 지원가능 • staticCache로 정적캐쉬를 활성화 시킴 –기본적으로 캐쉬는 최대 128개 –각각의 개체는 256kb
  14. 14. middelware request responseexpress. favicon() express. logger() express. static() app. get(/) app. use(404) next() 다음 middleware 호출 Mapping 되는 path가 없을 경우 404처리
  15. 15. 라우팅 • URL pattern으로 HTTP 요청 처리. • Express 라우팅은 HTTP method GET, PUT, DELETE, POST를 사용하여 관리. • method 이름은 GET인 경우 app.get(), POST인경 우 app.post(). • app(HTTP_METHOD).(URL, callback_function)
  16. 16. 라우팅 예제 ./app.js ./routes/index.js 지정된 View 호출 ./views/index.jade http://www.choong.com/ call!!!!
  17. 17. 라우팅의 경로 • 모든 라우팅 경로를 정규식 개체로 컴파일 • 경로 문자열에 특수문자를 가진 문자열을 사용하거나 직접 정규식을 사용해도 된다.
  18. 18. 라우팅 경로 예제 //write 및 end 대신에 send 함수 사용 *지정된 경로 패턴과 일치 하지 않는 요청이 있는 경우 404 응답
  19. 19. send()..1 생략 2번째 인자가 있는 경우 HTTP.status 값으로 처리. *인자 모두가 문자열인 경우 문제, 2번째 인자를 body로 1번째 인자를 상태값으로 처리.;;;
  20. 20. send()..2 BOdy 내용에 따라 적절한 헤더를 결정 해줌, 단 body가 숫자인 경우, http status 값 으로 간주함. 함수 호출 시 http.status 값도 던져주는 경우 응답코드는 던져진 값으로 셋팅
  21. 21. send()..3 생략 *Etag지원, (응답헤더로 리소스가 변경되었는지 확인하는 코드를 넣어줘서, 불필요한 리소스 절감
  22. 22. route 개체 *경로 path를 정규식 표현으로 자동변환.
  23. 23. 라우팅과 HTTP method • POST • app.post() • GET • app.get() • DELTE • app.delete() • PUT • app.put() * form에서 PUT,DELETE method를 지원하지 않으므로 _method사용하여서 method 지원 <input type=‘hidden’ value=‘put’ name=‘_method’ /> * express에서 HTTP method를 적절하게 처리 하기 위해서 methodOverride() configure에 추가. app.use(express.bodyParser()) 다음에 추가 app.use(express.methodOVerride())
  24. 24. methodOverride() *_method라는 숨겨진 파라미터를 이용하여 원하는 method 지정 *X-HTTP-Method-Override는 body 내용이 xml or application/x-www-form- urlencoded경우 사용(Header 값을 읽어서 처리)
  25. 25. MVC의 도입 • 모든기능을 하나의 js파일에 넣는것은 비효율적. • Express에서는 라우팅을 사용하고 있음
  26. 26. controllercontrollers/Widgets.js
  27. 27. Uri mapping /maproutecontroller/map.js
  28. 28. 관계 설정 /app.js
  29. 29. app.js(4.0)
  30. 30. 참고 • https://github.com/visionmedia/express • http://expressjs.com/ • http://bcho.tistory.com/887

×