node.js
-
[node] How to limit the HTTP request size and upload file size?Backend 2022. 6. 30. 15:29
디얼핏홈 관리자페이지에서 생활습관 개선 프로그램을 일자별로 설정한다. 거의 2년을 하다보니 일수가 797일차까지 되었는데, 자꾸 7월6일부터 추가가 안되고 서버에서 API 동작시 실행되는 로그도 안찍히고 500에러가 났다. 이유를 분석하니, 서버에서 배열 인풋값을 받을때 용량이 초과되어서였다. 그래서 아래와 같이 용량을 늘려줬다. solution: index.ts import bodyParser from "body-parser"; app.use(bodyParser.json({limit: "50mb"})); app.use(bodyParser.urlencoded({limit: "50mb", extended: true}));
-
The configuration file __MACOSX/eb-node-express-sample-v1.1/.ebextensions/._create-sns-topic.config in application version 1.2 contains invalid YAML or JSON. YAML exception: Invalid Yaml: unacceptable character '�' (0x0) special characters are not all..Infra/AWS 2020. 8. 7. 16:53
Elasticbeanstalk에 node.js 어플리케이션을 배포하기위해 .zip 파일을 업로드하면 아래와 같은 에러 이벤트가 발생하는 경우가 있다. The configuration file __MACOSX/eb-node-express-sample-v1.1/.ebextensions/._create-sns-topic.config in application version 1.2 contains invalid YAML or JSON. YAML exception: Invalid Yaml: unacceptable character '�' (0x0) special characters are not allowed in "", position 0, JSON exception: Invalid JSON: Unexpecte..
-
[node] nodemailer를 이용해 메일 전송 하기Backend/NodeJS 2020. 4. 13. 09:39
node.js에서 메일 전송 시스템을 구축해보자. 사실 시스템까진 아니고,, 회원 비밀번호 초기화 기능을 목적으로 사용할 예정이다. node.js에선 nodemailer 모듈을 이용하면 단 코드 몇줄로 쉽게 기능을 구현 할 수 있다. 먼저 모듈을 설치하자. npm install --save nodemailer 본인이 원하는 위치에 아래와 같은 코드를 작성하고 실행 하면 끝.. const nodemailer = require(`nodemailer`); // nodemailer transport 생성 const transporter = nodemailer.createTransport({ service: `gmail`, port: 465, secure: true, // true for 465, false fo..
-
How to configure nginx as reverse proxy for node.js(express) with aws ec2.Backend 2019. 12. 18. 16:31
node.js express memory optimization 관련해서 정보를 찾던 중 reverse proxy 레벨에서 압축(gzip)을 사용하면 도움이 된다는 사실을 알게 되었다. 그래서 내 프로젝트에 nginx로 reverse proxy를 구현하고자 한다. express 서버는 3000포트를 사용한다. nginx에서 8000포트로 들어오는 요청을 127.0.0.1:3000로 포워드한다. 대략 아래와 같은 구조로 만들려고 한다. 이렇게하면 요청이 Nginx를 거쳐서 접근이 되기 때문에 내부 서버의 포트를 외부로부터 숨길 수 있다. (이 글에선 node express 서버 구축과 aws 인프라 설정은 생략하겠다.) 먼저 nginx conf 파일을 아래와 같이 생성하자. $ nano /etc/nginx..
-
[node] express compression 메모리 최적화 (memory optimization)Backend/NodeJS 2019. 12. 18. 11:57
현재 내 express 서버의 메모리 용량이다. 메모리를 한번 줄여보고자 한다. node.js express에서 가장 흔히 쓰는 방법이 expression 이다. 간단하게 gzip을 적용한다 생각하면 된다. expression 설치는 아래 링크에서 확인! compression github 소스에 적용시키고 // index.js import compression from "compression"; import express from "express"; ...... app.use(compression()); ..... 빌드 후 실행을 시켰더니 조금 떨어지는듯 했다. 몇시간 지나니 다시 비슷해졌다.. 이 글을 쓰는 와중에 더 올라갔다.. ※참고로 서버 요청은 하나도 없었다. 그리고 하루를 더 보냈다. serv..
-
[node] How to send remind-push to customersBackend/NodeJS 2019. 11. 27. 17:21
What is the remind-push? It is push notifications that leads users to access PLANT app service. So, We expect more connection & active users. When should I send it? 하루 중, 자주 접속 했던 시간이 지났는 데도 접속을 하지 않았을때 During a day, When they didn't connect until the time they frequently connect. How? I use data selectivity, histogram. 작업 프로세스 Step 1. 사용자들의 활동에 대한 날짜를 수집한다. Get timestamp that user activity. 2. ..
-
[node] How to double co-routine in promise & loopBackend/NodeJS 2019. 11. 26. 17:06
비동기 작업의 동기화, 코루틴 각 회원들의 프로필과 친구리스트를 회원별로 새로운 객체에 담고 싶을때 co-routine과 promise를 활용하여 DB 작업은 비동기로 처리하고 베이스 루틴은 동기적으로 처리하여 만들어진 객체를 반환한다. 이 작업은 코루틴 안에서 작업을 비동기적으로 하면서, 모든 작업이 완료되었을 때 반환한다. When all jobs are done, this funtion is return and the main tasks are processed asyncronously. const cofunc = bPromise.coroutine(function* () { try { ... const members = yield getMembers();// get DB // [{"id":"", "..