분류 전체보기
-
[TIL] 로컬에서 개발하기2) DB 원격 접속하기 postgreSQLTIL 2024. 1. 22. 21:58
EC2 인스턴스 서버 내에서 개발하던 것을 로컬에서 개발하기위해서 필요한 것은 프로젝트 폴더를 내려받았다고 끝이아니다. 기존에 같은 서버내에서 접속하던 DB들을 이제는 원격 접속을 해줘야하기 때문에 특정한 과정이 추가로 필요하다. 이는 DB들 Postgres, MongoDB, Redis 각각 하나하나 해줘야한다. 기본적으로 큰 과정은 모두 동일하다. 데이터베이스 원격 접속 국룰 1. DB 사용자 이름, 비밀번호로 계정을 만든다. 2. 사용자 이름에 대해서 권한을 부여한다, 데이터베이스를 생성한다 3. 설정 파일에서 원격 접속을 허용한다. (mongod.conf, postgres.conf .... 설정파일 조정.), 데이터베이스 재시작하기 4. AWS 인바운드 규칙을 편집한다. ( EC2 인스턴스 서버의 ..
-
로컬에서 개발하기1) 프로젝트 폴더 내려받기 (git clone)TIL 2024. 1. 22. 21:39
기존에는 EC2 인스턴스 서버내에서 ftp-simple을 이용하여 개발을 했었다. 하지만 redis의 zAdd() 함수와 같이 특정 모듈내 메서드들의 사용법들을 알기 어려웠다. 원래대로라면 VSC에서, 함수의 매개변수로 어떤것들이 필요하는지 알려주지만, ftp-simple 원격 접속으로는 몇몇 VSC기능들을 이용할 수 없었다. 로컬에서 개발하면 프로젝트 파일내 모든 파일들을 읽어서 사용법들을 제공해주지만, ftp-simple에서는 기본적으로 클릭해서 켜져있느 파일만 업로드해서 읽을 수 있기때문에, 사용설명서들까지 읽을 수 없기 때문이다. 일단 EC2 서버에서 원격접속하여 개발하던 것을 로컬로 옮기기 위해서는 프로젝트 파일(코드)들을 서버로부터 내려받아야한다. 이때는 깃허브의 clone을 이용하였다. 파일..
-
캐싱TIL 2024. 1. 14. 16:08
** 캐싱 Caching - 정의 ㄴ캐시를 사용하는 데이터 저장 기법 ㄴ 램이 될 수도있고, 각 하드웨어 부품에 달려있는 캐시 메모리가 대상이 될 수도 있음. ㄴ 데이터 처리 속도를 향상시킨다 -개발자에게 있어 캐싱 1. 사실 캐싱은 대부분 운영체제가 알아서 해줌 2. 개발자가 할 수 있는 캐싱으론, db에서 가져오는 내용을 램에 저장해두고, 활용하는 방법 (=세션에 유저정보 저장하는 행위) -쓰는이유) 1.속도향상 ㄴ백엔드 개발에서 가장 오래걸리는 작업은 DB통신 ㄴ 근데 이 데이터를 램에 저장해두고 쓰는 것 (db에서 자주 불러오게되는 데이터를 램에 저장해두고 활용) 2. DB 과부하방지 ㄴ DB의 입출력이 많아지면 DBMS가 과부하가 걸릴 수 있음 ㄴ 보잘 것 없은 데이터나, 수정이 매우 자주 일어..
-
db) Redis데이터베이스 2024. 1. 14. 01:29
-정의 ㄴ 일종의 데이터베이스 (Document Database) ㄴ 개발자에 따라서 DB라고 부르지않는 사람도 있음 ㄴ Redis는 램을 사용하는 데이터베이스 (말그대로 캐싱을 위한 데이터베이스) ㄴ그래서 램과같이 휘발성을 가지고, 속도가 매우빠르다 특징 1. 램을 사용해서 무진장 빠름 2. 램을 쓰기 때문에 갑자기 서버 전원이 꺼지면 모두 날아감(휘발성) ㄴ 데이터의 영속성을 보장하지 않음 3. 다른 db처럼 CRUD기능을 제공함 4. 이외에 Redis만의 독특한 자료구조 5. Document Database이므로 JSON 사용 -Collection ㄴ Redis에 존재하는 자료구조 (비유하자면 RDB의 테이블과 같은 위치) ㄴ 5개 종류가 존재하는데, 이 5개에 각각의 기능이 있음 1. String..
-
[MongoDB] express - mongoDB 연결하기TIL 2024. 1. 10. 22:46
mongodb.js) const mongoose = require("mongoose"); const uri = "mongodb://localhost:27017/project"; mongoose.connect(uri, { useUnifiedTopology: true } ) const mongoDB = mongoose.connection mongoDB.on("error", () => { console.log('mongoDB connect Failed'); }) mongoDB.on("open", () => { console.log('mongoDB connected!'); }) //스키마 작성 const logSchema = new mongoose.Schema({ method: { type: String, re..
-
express) morgan 으로 로그 관리하기TIL 2024. 1. 10. 21:38
morgan : request, response 로깅 미들웨어 morgan미들웨어만들기) morgan(format, options) 첫번째인자 format : Log를 어떻게 생성하여 출력할 것인지 설정 ㄴ'dev', 'combined'와 같은 방식으로 미리 정해진 형식으로 Log를 생성할 수 있다 ㄴ그외에도 'common', 'short', 'tiny'등의 형식이있음 ㄴ사용자 지정형식: 사용자가 원하는 대로 custom하여 Log를 생성할 수도 있다 ㄴㄴ'dev' : 나의 개발환경에서 사용, 간단한 log ㄴㄴ'dev' 형식) :method :url :status :response-time ms - :res[content-length] ㄴㄴ'combined' : 배포 환경에서 사용, 자세한 log ㄴㄴ..
-
WEB) JWT 토큰인증 - 세션 vs 쿠키 vs 토큰TIL 2024. 1. 9. 15:53
JWT 정의) ㄴJSON WEB TOKEN ㄴToken 기법의 한 종류(웹표준) ㄴJSON형태로 되어있어서. 값의 관리가 쉬움 ㄴ조작여부 판단이 간단해서 웹 표준으로 삼고있음 -구조 ㄴToken이라는 것 자체가 그냥 특정한 폼을 가진 String "header":{ token의 설정 정보(발행자, 만료시간, 종류 등) }, "payload":{ 개발자가 Token에 넣고 싶은 값 }, "signature" : 비밀키로 암호화된 header + payload ㄴ이렇게 3가지의 Key를 String으로 변환해서 저장한게 Token -jwt가 어떻게 FE 조작을 막는가?) 1. header와 payload를 각각 String으로 만듬 2. A.B 의 형태로 저장 3. A.B를 비밀키로 암호화해서 C라고 저장 ..
-
express) Winston로 Log 관리하기express 2024. 1. 5. 21:44
winston: 로그 파일 및 로그레벨 관리모듈 winston-daily-rotate-file : 매일 날짜별로 로그 파일 생성 및 관리 모듈 winston 모듈을 쓰는이유) ㄴwinston은 개발환경보다 배포환경에서 로그를 남기기위해 사용한다. ㄴ배포환경은 개발환경과 달리 콘솔창을 확인하기 어렵고, 서버가 재부팅되면 기록이 초기화돼서 보기어렵다 ㄴ그래서 로그나 에러가 발생했을때, 외부파일에 로그기록을 보관하기 위해 사용한다. mongoDB 연결) const mongoose = require("mongoose"); const uri = "mongodb://localhost:포트번호/db명"; mongoose.connect(uri, { useUnifiedTopology: true } ) const mong..