JavaScript (94) 썸네일형 리스트형 Node.js 숙련 1주차_3 Node.js 숙련 1주차_3 Middle Ware 웹 서버의 요청/응답에 대해 공통적으로 관리 📄 app.js app.use(express.json()); // post, put 전달된 body데이터를 req.body로 사용할 수 있도록 만든 bodyparser app.use((req, res, next) => { console.log('Request URL:', req.originalUrl, ' - ', new Date()); next(); }); app.use('/api', [postsRouter, commentsRouter]); //API가 사용되기 위한 라우터 등록 next() : 다음 스택으로 정의된 미들웨어 호출 사용자 인증이나 logging에 쓰임. 여러 개의 미들 웨어 📄 app.js a.. Node.js 숙련 1주차_2 Node.js 숙련 1주차_2 📌 쿠키(Cookie) 브라우저가 서버로부터 응답으로 Set-Cookie 헤더를 받은 경우, 해당 데이터를 저장한 뒤 모든 요청에 포함하여 보냄 보안에 취약 📌 세션(Session) 데이터를 서버에서만 저장(Stateful)하기 때문에 보안이 좋음 사용자가 많은 경우 서버에 저장해야 할 데이터가 많아서 서버가 터질 수 있음 📌 JWT header.payload.signature header(머리) : signature에서 어떤 암호화를 사용하여 생성된 데이터인지 표현 payload(가슴) : 개발자가 원하는 데이터를 저장 signature(배) : 토큰이 변조되지 않은 정상적인 토큰인지 확인할 수 있게 도와줌(특정 키) JWT는 누구나 복호화(Decode) 가능하므로 pay.. Node.js 숙련 1주차_1 Node.js 숙련 1주차_1 todo-memo 프로젝트 📌 package.json 생성 npm init -y 📌 express 설치 npm install express 📌 mongoose 설치 npm install mongoose 📄 app.js const express = require("express"); const app = express(); const router = express.Router(); router.get("/", (req, res) => { res.send("Hi!"); }); // post, put 메소드 사용시 body로 들어오는 데이터 // 사용할 수 있도록 하는 미들웨어 app.use("/api", express.json(), router); app.listen(8080,.. Node.js 입문 1주차, 개인과제 Node.js 입문 1주차, 개인과제 어제 공부한 내용. https://pangeei-h.tistory.com/entry/%EB%82%B4%EC%9D%BC%EB%B0%B0%EC%9B%80%EC%BA%A0%ED%94%84-4%EA%B8%B0Node%EC%9E%85%EB%AC%B8-%EA%B0%9C%EC%9D%B8%EA%B3%BC%EC%A0%9C-24%EC%9D%BC%EC%B0%A8-TIL 내일배움캠프 4기_Node입문 개인과제 24일차 TIL 내일배움캠프 4기_Node입문 개인과제 24일차 TIL 개인과제 전체 게시글 목록 조회 API 제목, 작성자명, 작성 날짜를 조회하기 작성 날짜 기준으로 내림차순 정렬하기 게시글 작성 API 제목, 작성자명, pangeei-h.tistory.com 사실 다른 분 코드.. Node.js 입문 주차 1주차_5 Node.js 입문 주차 1주차_5 git 형상관리 도구 📌 SSH Key 발급 ssh-keygen -t rsa -b 4096 -C "archepro84@gmail.com" 📌 키 파일 open cat ~/.ssh/id_rsa.pub 📌 git init git init 📌 .gitignore 파일 생성 git add . git commit -m "first Commit All Files" git push -u origin master 📌 원격 repo 업로드 확인 수정된 사항 업로드 📌 변경사항 있는지 확인 git status git add . git commit -m "Second Commit Files" git push aws 인스턴스 cd Download ssh -i ./sparta_keypair... Node.js 입문 주차 1주차_4 Node.js 입문 주차 1주차_4 MongoDB, Studio 3T 설치 📌 mongoose DB Clinet 역할 npm install mongoose MongoDB 연결 📄 app.js const express = require('express'); const app = express(); const port = 3000; const goodsRouter = require('./routes/goods.js'); const connect = require('./schemas/index.js'); connect(); app.use(express.json()); app.use("/api", goodsRouter); app.listen(port, () => { console.log(port, '포트로 서버.. Node.js 입문 주차 1주차_3 Node.js 입문 주차 1주차_3 Express.js란? Node.js로 서버를 빠르고 간편하게 만들 수 있게 도와주는 웹 프레임워크 npm install -y npm install express 📄 app.js const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(port, () => { console.log(port, '포트로 서버가 열렸어요!'); }); GET test router 클라이언트 요청을 쉽게 처리할 수 있는 기능 중 하나. 📄routes/goods.js const expres.. Node.js 입문 주차 1주차_2 Node.js 입문 주차 1주차_2 객체 리터럴이란? 객체를 생성하기 위한 표기 방법 📌 사칙연산하는 객체 const calculater = { add : function (a, b) {return a+b}, sub : function (a, b) {return a-b}, mul : function (a, b) {return a*b}, div : function (a, b) {return a/b} } console.log(calculater.add(3,2)); console.log(calculater.sub(3,2)); console.log(calculater.mul(3,2)); console.log(calculater.div(3,2)); Error handling 에러를 관리하는 방법, 예상치 못한 상.. Node.js 입문 주차 1주차 Node.js 입문 주차 1주차 Node.js 특징 Async + Non-blocking Model Non-blocking : 함수가 실행되는 중에도 다른 작업을 동시에 진행할 수 있음. Single Thread : 동시에 하나의 작업만 수행할 수 있음 Event Loop : 싱글 스레드 약점을 극복하기 위해 효율적으로 작업을 처리할 수 있는 특성 ※ java랑 c언어는 blocking, 비동기 처리가 가능한 환경이어도 비동기 처리가 불가능하다. promise test async function main() { function first(){ console.log("Set Time Out이 실행되었습니다."); } console.log("코드가 실행되었습니다."); setTimeout(first, 100.. Node.js 실무 기초 1주차 Node.js 실무 기초 1주차 편집기 : VS Code, cmd Node.js란? 자바스크립트가 실행될 수 있게 도와주는 런타임 플랫폼 V8 엔진으로 빌드된 자바스크립트 런타임 플랫폼(마법 상자) 한국어 : 자바스크립트 한국말 : node.js(소리라는 수단으로 나의 의견 & 생각을 전달할 수 있다. 실행시키는 수단) 📌 npm이란? 자바스크립트를 사용할 수 있는 패키지(모듈) 관리자 ex) pip와 동일한 역할을 함. npm install express https://www.npmjs.com/ npm Bring the best of open source to you, your team, and your company Relied upon by more than 11 million developers .. 이전 1 ··· 4 5 6 7 8 9 10 다음 목록 더보기