게임 웹 프로그래밍
-
07/12 게임 웹 프로그래밍게임 웹 프로그래밍/node.js 2021. 7. 12. 14:36
VS Code 실행후 exam-10 폴더 만들기 터미널 열어서 cd exam-10 npm init -y npm i express nodemon app.js파일 만들기 기본 express server 만들어서 실행 supervisor app or nodemon app 포트 3030 nodemon이 작동하지 않을 때는 npx nodemon app postman으로 파라미터 잘 들어오는 지 확인 app.cs const express = require('express'); const app = express(); app.use(express.json()); app.get('/', (req, res) => { res.send("hello express!!"); }); app.post('/purchases', (r..
-
06/16 node.js 카카오톡 로그인게임 웹 프로그래밍/node.js 2021. 6. 16. 12:22
플랫폼의 Redirect URI과 카카오 로그인 Redirect URI를 등록 https://developers.kakao.com/ Kakao Developers 카카오 API를 활용하여 다양한 어플리케이션을 개발해보세요. 카카오 로그인, 메시지 보내기, 친구 API, 인공지능 API 등을 제공합니다. developers.kakao.com 코드작성 const passport = require('passport') const express = require('express') const KakaoStrategy = require('passport-kakao').Strategy; const { deserializeUser } = require('passport'); const port = 8002; // p..
-
06/11 node.js 리퀘스트의 params, query확인게임 웹 프로그래밍/node.js 2021. 6. 11. 14:10
next함수 next('route') 리퀘스트의 params, query확인 :id req.params.id로 조회 가능 :type이면 req.params.type으로 조회 가능 const express = require("express"); const router = express.Router(); router.get("/:id", (req, res, next) => { console.log(req.params); console.log(req.query); res.send('검색'); }); module.exports = router; send 문자열, html코드, json데이터를 전송가능 sendFile 파일을 응답으로 보냄 우리가 http상태코드를 보낼 수 있음 res.status(404).sen..
-
06/10 node.js express를 사용한 rest api 연습게임 웹 프로그래밍/node.js 2021. 6. 10. 14:18
npm init -y npm i express uuid nodemon visual studio code 코드 정리 툴 prettier 파일 > 기본설정 > 설정 save검색 Formate On Save 체크설정 라우터 const userRouter = require("./routes/users"); app.use('/users', userRouter); 서버 할일 id를 생성 객체로 만들어서 배열에 추가 password 암호화 할수 있음 하기 npm crypto검색 jwttoken 응답시 status 200 오류시 500 app.js const express = require("express"); const userRouter = require("./routes/users"); const app = ex..
-
06/09 node.js게임 웹 프로그래밍/node.js 2021. 6. 9. 14:23
https://expressjs.com/ Express - Node.js web application framework Fast, unopinionated, minimalist web framework for Node.js $ npm install express --save expressjs.com 글로벌로 설치된 모듈 확인 npm list -g postman다운로드 https://www.postman.com/ Postman | The Collaboration Platform for API Development Postman makes API development easy. Our platform offers the tools to simplify each step of the API building p..
-
06/08 node.js게임 웹 프로그래밍/node.js 2021. 6. 8. 18:18
restfront.js function getUser() { console.log("getUser"); let xhr = new XMLHttpRequest(); xhr.onload = function() { if(xhr.status === 200) { let users = JSON.parse(xhr.responseText); let list = document.getElementById('list'); list.innerHTML = ''; Object.keys(users).map(function(key) { let userDiv = document.createElement('div'); let span = document.createElement('span'); span.textContent = user..
-
06/04 node.js게임 웹 프로그래밍/node.js 2021. 6. 4. 14:31
1. rest api와 라우팅 rest api 네트워크 구조의 한 형식 서버의 자원을 정의하고 자원에 대한 주소를 지정하는 방법 주소는 명사로 구성 주소 외에도 http요청 메서드를 사용 http 메서드 GET 서버 자원을 가져오고자 할 때 사용 요청의 본문에 데이터를 넣지 않음 데이터를 서버로 보내야 한다면 쿼리스트링을 사용 POST 요청의 본문에 새로 등록할 데이터를 넣음 PUT 서버에 자원을 요청에 들어 있는 자원으로 치환할 때 사용 PATCH 서버에 자원의 일부를 요청에 들어 있는 자원으로 치환할 때 사용 DELETE 서버의 자원을 삭제할 때 사용 주소 하나가 요청메서드를 여러개 가질 수 있음 서버확장 Scaling 주소설계 프로토콜 문서 작성 주소, 메서드, 어떤 역할, 어떻게 보내고 받나 re..
-
06/03 node.js 서버게임 웹 프로그래밍/node.js 2021. 6. 3. 13:17
1. http 모듈로 웹서버 만들기 쿠키, 세션 처리, 라우팅 createServer메서드 요청이 들어올 때마다 매번 콜백함수가 실행 req객체는 요청에 관한 정보 res객체는 응답에 관한 정보 포트 외부에서 PC에 연결할 수 있는 통로 서버 내에서 프로세스를 구분하는 번호 유명한 포트번호는 21(ftp) 80(http) 443(https) 3306(mysql) 포트만 다르게 해서 여러 서버를 실행할 수 있음 server.listen 서버에 포트를 열어줌 클라이언트에게 공개할 포트 번호와 포트 연결 완료 후 실행될 콜백 함수를 넣어줌 server1.js const http = require('http'); const port = 3000; const server = http.createServer((re..