node
-
[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 fix the ERROR that 'net::ERR_CONNECTION_REFUSED' on Node.js?Frontend/react 2020. 2. 5. 18:28
환경 Platform: React URL: http://localhost:3000 API PATH : http://localhost:3000/api/... used HTTP Request Module : Axios 문제 리엑트 프로젝트에서 프론트 단에서 백엔드 단으로 REST API를 요청 하는 부분이 있다. 이때 서버 포트가 3000이라, 요청 주소를 'http://localhost:3000'으로 하고 로컬에서 작업을 하면 무리없이 잘 동작하지만 실제 서버에서 동작을 시키게되면 http 요청을 실패하게 된다. (서버에 접속해 직접 curl로 요청을 하면 또 잘된다.) 문제 발생 과정 Part of request source, // front-end const baseUrl = 'http://localh..
-
[winston] How to customize timestamp format. (to local timezone) 날짜 시간 포맷을 로컬 타임존으로 변경하기Backend/NodeJS 2019. 12. 20. 16:17
Winston에서 날짜 시간 포맷을 로컬 타임존으로 변경 하기! 나의 node.js 프로젝트에 winston을 적용하는 과정에서 로그 메시지의 시간을 기록하는데 timezone이 utc 기준 시간으로 기록이 되었다. 그래서 timestamp를 커스터마이징을 했다. winston 깃허브에서 사용 예를 보면 아래와 같다. timestamp 타임존이 로컬 기준이 아니라 시간이 맞지 않는다. // 원본 소스 const { format } = require('winston'); const { combine, timestamp, label, prettyPrint } = format; const logger = createLogger({ format: combine( label({ label: 'right meow!..
-
[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..
-
[typescript] Start express with typescriptPrograming/javascript 2019. 12. 6. 16:43
1.Make a PROJECT_DIRECTORY $ mkdir plantonline-cron-service && cd $_ 2. Make package.json $ npm init -y // package.json { "name": "plantonline-cron-service", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" } 3. Install modules $ npm install -S express $ npm install -D t..
-
[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":"", "..