코딩/Javascript

설치 방법 : npm i express-rate-limit 사용 방법 : import rateLimit from 'express-rate-limit'; // OR // const rateLimit = require("express-rate-limit"); const option = { windowMs: 15 * 60 * 1000, // 15분 max: 100, // IP당 최대 100개의 요청을 허용합니다 (15 분 동안) standardHeaders: true, // 헤더에 `RateLimit-*` 를 포함합니다 legacyHeaders: false, // `X-RateLimit-*` 헤더를 비활성화합니다. } const limiter = rateLimit(option); // 모든 요청에 대해 rat..
자바스크립트로 간단하게 구현하는 방법입니다. function timeFormat (start, end) { const start = new Date(start); const end = new Date(end); const duration = Math.floor((end.getTime() - start.getTime()) / 6000); if (duration < 1) return '몇 초 전'; if (duration < 60) return `${duration}분 전`; if (duration < 60 * 24) return `${Math.floor(duration / 60)}시간 전`; if (duration < 60 * 24 * 30) return `${Math.floor(duration / 60 ..
function msToTime(ms) { var milliseconds = parseInt((ms%1000)/100) , seconds = parseInt((ms/1000)%60) , minutes = parseInt((ms/(1000*60))%60) , hours = parseInt((duration/(1000*60*60))%24); hours = (hours < 10) ? "0" + hours : hours; minutes = (minutes < 10) ? "0" + minutes : minutes; seconds = (seconds < 10) ? "0" + seconds : seconds; return hours + ":" + minutes + ":" + seconds + "." + millise..
Node.js로 뭔가를 만들고 실행시킬 때, 코드를 수정하고 다시 실행해줘야 하는 번거로움이 있습니다. 하지만 supervisor을 사용하면 코드의 수정사항을 감지하여 자동으로 재시작해줍니다. 설치 방법 npm install supervisor -g 꼭 -g 옵션으로 설치하셔야됩니다. 사용 방법 supervisor (file).js 오류가 나서 종료되거나 코드가 수정되었을 때 자동으로 재시작해줍니다.
소스코드 유튜브 영상 넣기 제출 제출
See the Pen eng-kor by Sol-Studio (@sol-studio) on CodePen.
See the Pen d-day by Sol-Studio (@sol-studio) on CodePen.
See the Pen hash by Sol-Studio (@sol-studio) on CodePen.
function init(){ testWebSocket(); } function testWebSocket(){ websocket = new WebSocket("ws://echo.websocket.org"); // 웹소켓 서버 주소로 변경 websocket.onopen = function(evt){ onOpen(evt) }; websocket.onclose = function(evt){ onClose(evt) }; websocket.onmessage = function(evt){ onMessage(evt) }; websocket.onerror = function(evt){ onError(evt) }; } function onOpen(evt){ // 소켓이 열렸을 때 실행될 함수 } function onCl..
--지금 시간--
Sol Studio 공식 블로그
'코딩/Javascript' 카테고리의 글 목록