티스토리

Blue Breeze
검색하기

블로그 홈

Blue Breeze

bluebreeze.co.kr/m

C.H가 끄적이는 개발자 로그

구독자
0
방명록 방문하기
공지 티스토리 반응형 디자인 적용 모두보기

주요 글 목록

  • mogan body log npmjs.com/package/morgan morgan 으로 body 값을 로그에 남긴다. margan.token('body', (req) => req?.body ? req?.rawBody ?? JSON.stringify(req?.body) : null) // 로그 if (!/production/i.test(config.env)) app.use(margan('dev')).use(margan(':body')) else app.use(margan('default')).use(expressLogger(':body')) 공감수 0 댓글수 0 2023. 8. 9.
  • Build a Website Accessibility Tester With JavaScript & Pa11y Node.js 웹 접근성 테스트 도구 npm i express pa11y # index.js const pa11y = require('pa11y') async function run() { const response = await pa11y('https://bluebreeze.co.kr') console.log(response) } run() $ node index.js { documentTitle: 'Blue Breeze', pageUrl: 'https://bluebreeze.co.kr/', issues: [ { code: 'WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.InputText.Name', type: 'error', typeCode: 1, message: 'Thi.. 공감수 5 댓글수 0 2021. 11. 10.
  • Joi Validation Joi https://joi.dev/ https://joi.dev/tester/ https://github.com/sideway/joi v17.4.0 joi/API.md v16.1.4 joi/API.md const Joi = require('joi'); const schema = Joi.object({ username: Joi.string() // 문자 .alphanum() // 알파벳, 숫자 .min(3) // 최소 3이상 .max(30) // 최대 30이하 .required(), // 필수 password: Joi.string() // 문자 .pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')), // 정규식 repeat_password: Joi.r.. 공감수 4 댓글수 0 2021. 2. 10.
  • javascript: 교집합(Union), 합집합(Intersection), 여집합(difference, minus) ECMAScript 6 sets: union, intersection, difference [itertools — Functions creating iterators for efficient looping](https://docs.python.org/3/library/itertools.html] Union let a = new Set([1,2,3]); let b = new Set([4,3,2]); let union = new Set([...a, ...b]); // {1,2,3,4} Intersection let a = new Set([1,2,3]); let b = new Set([4,3,2]); let intersection = new Set( [...a].filter(x => b.has(x))); //.. 공감수 4 댓글수 0 2021. 1. 21.
  • linux watcher limit on pm2 Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static' #11406 Increasing the amount of inotify watchers watcher Error PM2 | at NodeFsHandler._addToNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:620:21) PM2 | Error: ENOSPC: System limit for number of file watchers reached, watch '/home/ubuntu/project/nexus2/no.. 공감수 3 댓글수 0 2019. 11. 21.
  • pm2 npm start Can pm2 run an 'npm start' script Pm2 log dateformat pm2 JSON(설정)으로 실행 Run pm2 npm pm2 start npm -- start ecosystem.config.js module.exports = { apps: [{ name: "utilservice", script: "./bin/www", instanses: "max", exec_mode: "cluster", env: { NODE_ENV: "production" }, log_date_format: "YYYY-MM-DD HH:mm:ss.SSS", error_file: "./logs/pm2-err.log", out_file: "./logs/pm2-out.log", combine_logs: true,.. 공감수 2 댓글수 0 2019. 11. 14.
  • NPM Permission Error npm throws error without sudo NPM permission 문제 해결하기 npm i 설치 permission 에러 npm ERR! Error: EACCES, open '/Users/username/.npm/-/all/.cache.json' npm ERR! { [Error: EACCES, open '/Users/username/.npm/-/all/.cache.json'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/username/.npm/-/all/.cache.json' } npm ERR! npm ERR! Please try running this command again as root/Administrato.. 공감수 1 댓글수 0 2019. 11. 13.
  • jwtwebtoken JWT for node.js # https://www.npmjs.com/package/jsonwebtoken npm i jsonwebtoken npm i magic-globals npm i lodash // JWTService.js const jwt = require('jsonwebtoken'); const SECRET='secretkey'; module.exports = { issuer(payload, expiresIn){ try{ return jwt.sign(payload, SECRET, { expiresIn }); }catch(TokenExpiredError){ throw { code: 'E_TOKEN', name: TokenExpiredError.name.. 공감수 1 댓글수 0 2019. 4. 12.
  • Origin Policy Error on Sailsjs Sails.js global CORS config not working, per-route is Access-Control-Allow-Headers On Cross-Origin Resource Sharing (CORS) MDN Access-Control-Request-Headers On Cross-Origin Resource Sharing (CORS) MDN sails.config.security # config/security.js module.exports.security = { cors: { allRoutes: true, allowOrigins: '*', allowCredentials: false, allowRequestMethods: 'GET, POST, PUT, DELETE, OPTIONS, H.. 공감수 1 댓글수 0 2019. 3. 20.
  • not support route and folder fot sails.js Routing to Action : Sails.jsFolder Lists Source controllers/AutoController.js module.exports = { }; AuthController.js module.exports = { async find(req, res){ const params = req.allParams(); return res.ok('OK', params); }, async findOne(req, res){ const params = req.allParams(); return res.ok('OK', params); }, }; find.js, module.exports = async (req, res)=>{ const params = req.allParams(); retur.. 공감수 1 댓글수 0 2019. 3. 4.
  • Sails Restful-api Tutorials Sails.js | Realtime MVC Framework for Node.js Sails Restful-api Tutorials sails v1.x Fast, Simple API Build Tutorials 공감수 1 댓글수 0 2019. 2. 22.
  • Full Stack Framework Sails.js For Node.js Get Start! Sails.js Build a Sails.js App 동영상은 0.12 버전2019.02.14일 현재 1.1.0 버전으로 일부 맞지 않는 부분이 있지만, 조금만 변경하면 무리없이 동작이 됩니다. 공감수 1 댓글수 0 2019. 2. 14.
  • node.js json-server typicode/json-server Installation & Run Server sudo npm install -g json-server vi db.json { "speakers": [{ "about": "Incididunt mollit cupidatat magna excepteur do tempor ex non eiusmod magna exercitation proident nisi non. Sunt ad consequat eu non esse excepteur. Veniam quis Lorem ea labore ullamco veniam nisi do sunt. Nisi irure sit qui irure mollit ad aliquip non culpa sint reprehenderit ulla.. 공감수 13 댓글수 0 2018. 6. 13.
  • Node.js helloWorld HTTP 트랜잭션 해부 - 서버생성Hello world 예제 - express Node.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('Hello World!'); res.end(); }).listen(1337); node app.js # other terminal ab -n 10000 -c 10 -k http://127.0.0.1:1337/ ..... Concurrency Level: 10 Time taken for tests: 0.766 seconds Complete requests: 10000 Failed re.. 공감수 11 댓글수 0 2018. 6. 10.
  • node.js Common System Errors Node.js v9.6.1 Documentation #Common System Errors Common System Errors This list is not exhaustive, but enumerates many of the common system errors encountered when writing a Node.js program. An exhaustive list may be found here. 이 목록은 전부는 아니지만 Node.js 프로그램을 작성할 때 발생하는 많은 공통 시스템 오류를 나열합니다. 전체 목록은 여기에서 찾을 수 있습니다. EACCES (Permission denied): An attempt was made to access a file in a way forbidden.. 공감수 10 댓글수 0 2018. 2. 23.
  • express-socket.io-session express-socket.io-session public Install npm install express-socket.io-session Example var app = require('express')(), server = require("http").createServer(app), io = require("socket.io")(server), session = require("express-session")({ secret: "my-secret", resave: true, saveUninitialized: true }), sharedsession = require("express-socket.io-session"); // Attach session app.use(session); // Share.. 공감수 9 댓글수 0 2018. 2. 13.
  • node.js 64bit int buffer Node.js Buffer Module nodejs write 64bit unsigned integer to buffer Converting a double to an int in Javascript without rounding Node.js 에서 64bit INT형을 다루는 버퍼는 없다. 이를 해결하기 위해서 32bit INT와 >>(비트계산)을 이용해서 64bit INT형으로 사용한다. var i = 99999; var buf = new Buffer(8); // 8byte 64bit buffer 생성 buf.fill(0); // 0으로 채우고 buf.writeUInt32BE(i >> 8, 0); // 상위 bit 자리 이동. buf.writeUInt32BE(i & 0x00ff, 4); // 하위비트.. 공감수 10 댓글수 0 2018. 1. 25.
  • 2진수 채우기 zerofill convert '1' to '0001' in JavaScript [duplicate] var str = '1234'; str = ('00000000'+str).substring(str.length); // 00001234 var str = '12345678'; str = ('00000000'+str).substring(str.length); // 12345678 공감수 11 댓글수 0 2018. 1. 12.
  • node.js Buffer Node.js :: Buffer :: 바이너리 데이터의 조작, 인코딩, 디코딩을 위한 버퍼 활용 :: Usi nodejs에서 버퍼데이터 처리하기 Using Buffers in Node.js - w3resource var buf = new Buffer('my buffer content'); // accessing the 10th position of buf console.log(buf.toString()); my buffer content var buf = new Buffer(100); console.log(buf.length); 100 buf.toString(); 100 var buf = new Buffer(10); buf.write("Node.js", "utf8"); buf.toJSON(); { typ.. 공감수 9 댓글수 0 2018. 1. 11.
  • node.js zlib compress uncompress Zlib | Node.js file gzip const zlib = require('zlib'); const gzip = zlib.createGzip(); const fs = require('fs'); const inp = fs.createReadStream('input.txt'); const out = fs.createWriteStream('input.txt.gz'); inp.pipe(gzip).pipe(out); string flate const input = '.................................'; zlib.deflate(input, (err, buffer) => { if (!err) { console.log(buffer.toString('base64')); } else {.. 공감수 10 댓글수 0 2018. 1. 10.
  • Pm2 log dateformat Log management pm2 install pm2-logrotate pm2 start app.js --log-date-format 'DD-MM HH:mm:ss.SSS' { "apps": [ { { "script" : "echo.js", "error_file" : "err.log", "out_file" : "out.log", "merge_logs" : true, "log_date_format" : "YYYY-MM-DD HH:mm Z" } ] } pm2 set pm2-logrotate:max_size 100M; pm2 set pm2-logrotate:dateFormat YYYY-MM-DD_HH-mm-ss; pm2 set pm2-logrotate:rotateInterval '0 * * * *'; pm2 .. 공감수 6 댓글수 0 2017. 6. 16.
  • pm2 JSON(설정)으로 실행 Cluster Mode pm2 start app.json { "apps": [{ "name": "app", "script": "app.js", "watch": false, "env": { "ssl" : true, "NODE_ENV": "production", "port" : 443, "redis" : { "host" : "127.0.0.1", "port" : 6379, "options" : {} }, "db" : { "host" : "127.0.0.1", "user" : "user", "password" : password", "port" : "3306", "database" : "databse_name", "dateStrings" : "date" } "apiHost" : "http://localhost.. 공감수 7 댓글수 0 2017. 3. 13.
  • pm2 1.1.3 to 2.1.5 upgrade Updating PM2 Error: connect EACCESS #837 Update pm2 save sudo npm install pm2 -g sudo pm2 update EACCESS Error Linux 에서는 발생하지 않고, mac에서 발생함(MacBook Pro) pm2 kill rm -rf ~/.pm2 vi /etc/profile # export PM2_HOME=/opt/.pm2 chmod -R 777 /opt/.pm2 내가 해결한 방법 # .pm2 디렉토리를 새로 만든다. cd ~/ mv .pm2 .pm2.back && mkdir .pm2 공감수 6 댓글수 0 2016. 11. 24.
  • socket.io namespace 사용 시 sids, io.to socket.io namespace 유무에 따른 rooms, sids 구분 // namespace 를 / 만 사용할 경우 var mio = { rooms : io.sockets.adapter.rooms, sids : io.sockets.adapter.sids }; //io.sockets.to( socketid ).emit('event', data ); //io.sockets.in( roomid ).emit('event', data ); io.sockets.to( socketid ).emit('event', data ); io.sockets.to( roomid ).emit('event', data ); // namespace 다른 namespace를 사용할 경우 var mio = { rooms : io.o.. 공감수 6 댓글수 0 2016. 9. 9.
  • Getting Startd : Messenger Platform - facebook for developers Getting Started This is a walkthrough to see the basics of the platform in action. Read the Complete Guide to learn about the platform in more detail. 실행되는 플랫폼을 볼 수있는 기초 연습입니다. 자세히 플랫폼에 대해 알아 보려면 완전한 가이드를 참조하십시오. Sample App Download the sample app from Github to follow along with this tutorial. You can run the sample app to see it in action. 이 튜토리얼을 따라할 수 있는 Github 샘플 응용 프로그램을 다운로드합니다. 샘플을 보고 응용.. 공감수 6 댓글수 0 2016. 7. 14.
  • Messenger Platform - facebook for developers Messenger Platform - facebook for developers Setup For this integration, you will need the following: 통합을 위해서 다음이 필요. Facebook App: The Facebook App contains the settings. This is where you will setup your webhook, retrieve your page access token and submit your app for approval. 페이스북 앱: 페이스북 앱 설정이 포합되어 있다. webhook 설정, 토큰 페이지 액세스를 검색, 승인을 위해 당신의 앱을 제출하라. Facebook Page: A Facebook Page will be us.. 공감수 5 댓글수 0 2016. 7. 13.
  • n 을 이용한 nodejs 설치 및 관리 CentOs yum install nodejs yum install npm npm install n -g n stable # v6.0.0 설치 n -v # yum 설치 버전 yum remove nodejs # yum 설치 버전 제거 # 로그아웃 후 재 로그인 n -v #v6.0.0 확인 npm update npm -g Ubuntu apt-get install nodejs, npm 이 후 n 설치 부터 동일 Mac brew install node npm -g install n # 최신 버전 설치 sudo n latest # LST 버전 설치 sudo n lts # 버전 설치 sudo n 12.19.0 # 설치되 node 목록 n ls # node 변경 n # 상/하 이동 후 선택 공감수 0 댓글수 0 2016. 5. 13.
  • node v6.0.0 Node v0.60 v5.0.0, v6.0.0 주요 변화 Buffer New Buffer constructors have been added 버퍼추가 #4682 and #5833. Existing Buffer() and SlowBuffer() constructors have been deprecated in docs #4682 and #5833. Previously deprecated Buffer APIs are removed #5048, #4594. Improved error handling #4514. The Buffer.prototype.lastIndexOf() method has been added #4846. Cluster Worker emitted as first argument in 'mes.. 공감수 1 댓글수 0 2016. 5. 11.
  • socket.io disconnect 전에 socket.leave 처리 socket.io 1.x 에서 disconnect 이벤트는 socket 에 저장된 id가 이미 삭제된 상태로 disconnect 이벤트가 처리된다. join된 room정보가 필요할 경우 socket.io 의 onclose 를 오버라이딩해서 처리하면 된다. io.of('/').on('connection', function(socket) { // overridding, ref:node_modules/socket.io/lib/socket.js:416 socket.onclose = function( reason ){ if (!this.connected) return this; //debug('closing socket - reason %s', reason); myfunc( this.id ); // myfunc(.. 공감수 5 댓글수 0 2016. 3. 9.
  • npm CLI Commands npmjs.com docs.npmjs.com CLI Commands access게시된 패키지에 설정된 액세스 수준 adduser저장소 사용자 계정 추가 binnpm bin 폴더 표시 bugs웹 브라우저에서 패키지 버그 Maybe(있다면?) build패키지 빌드 bundleREMOVED cache패키지 캐시 관리 completionnpm 탭 완료 configNPM 구성 파일 관리 dedupe중복 감소(제거) deprecate비추천 패키지 dist-tag패키지 배포 태그 수정 docs웹 브라우저에서 패키지 문서 Maybe(있다면?) edit설치 패키지 수정 explore설치 패키지 찾기 helpnpm 도움말 help-searchnpm 도움말 검색 initpackage.json 파일을 생성 install패키지.. 공감수 4 댓글수 0 2016. 2. 18.
    반응형
    문의안내
    • 티스토리
    • 로그인
    • 고객센터

    티스토리는 카카오에서 사랑을 담아 만듭니다.

    © Kakao Corp.