'2019/03'에 해당되는 글 3건

pm2

시스템 2019. 3. 28. 16:36

npm install pm2 -g

 

pm2 start app.js --name 'app'

 

require('http').createServer((request, response) => {
    response.writeHead(200, { 'Content-Type': 'text/html' });
    response.end('Hello World');
}).listen(50000, () => {

    console.log('Serer  is start');
   
    });

'시스템' 카테고리의 다른 글

버추얼박스 VT-x is not available 오류  (1) 2019.07.18
시놀리지 나스 synology nas(redmine plugin)설치  (2) 2019.04.29
nodejs - form submit  (0) 2019.01.22
nodejs + mariadb 연동  (0) 2019.01.14
nodejs json파일 MongDB에 입력  (0) 2018.12.04
블로그 이미지

iesay

,

promise

2019. 3. 28. 16:13

 

 

여러개의 비동기 처리가 끝난 후

특정 로직을 실행하고 싶은 경우 발행

const promiseFirst = new Promise(resolve => resolve(1))
.then(result => `${result + 10}`);

const promiseSecend = new Promise(resolve => resolve(2))
.then(result => `${result + 20}`);

Promise.all([promiseFirst, promiseSecend]).then((result) => {
console.log('result :', result);
console.log('sum :', Number(result[0]) + Number(result[1]));
}
)

 

 

 

'' 카테고리의 다른 글

GS인증(보안성)  (7) 2020.04.13
express + morgan  (0) 2019.04.01
정규식 표현 정리  (0) 2019.03.28
DB에 웹쉘코드 삽입 POC  (0) 2018.12.06
워드프레스 서버 이관  (0) 2018.09.03
블로그 이미지

iesay

,

정규식 표현 정리

2019. 3. 28. 10:53

역슬레쉬

'use strict';

const string = '<h1>::: buy - 99,000 won :::</h1>';
const result1 = string.replace(/<h1>/g, '');
console.log('result1 :', result1);


const result2 = string.replace(/<h1>/g, '').replace(/<\/h1>/g, '');

// 역슬러쉬 정규식 표현시 앞에 사용
console.log('result2 :', result2);


 

.점

const string = '<h1>::: buy - </h1> <h2> 99,000 won :::</h2>';


const result1 = string.replace(/<..>/g, '');       // <..> 괄호속 어떤 문자2개면 삭제
const result2 = string.replace(/<.../g, '');        // <...  왼괄호 후  문자열3개 삭제


console.log('<..> : ', result1);
console.log('<...> : ', result2);

 

중괄호

'use strict';


const string = '<h1>::: buy - </h1> <h2> 99,000 won :::</h2>';
const stringDiv = '<div>::: buy - </div> <h2> 99,000 won :::</h2>';

const replaceH1 = string.replace(/<.{0,1}h1> /g, '');  // h1앞에 0,1글짜
const replaceTags = string.replace(/<.{0,4}> /g, '');  // > 앞에 0,4글짜

console.log(replaceH1);
console.log(replaceTags);

 

[]

const string = '<h1>::: buy - </h1> <h2> 99,000 won :::</h2>';

const Bracket = string.replace(/[()]/g, '');
const BracketComma = string.replace(/[()/\-,]/g, '');

 


console.log('before 전: ', string);
console.log('()after : ', Bracket);
console.log('/after : ', BracketComma);

 

 

 

 

'' 카테고리의 다른 글

express + morgan  (0) 2019.04.01
promise  (0) 2019.03.28
DB에 웹쉘코드 삽입 POC  (0) 2018.12.06
워드프레스 서버 이관  (0) 2018.09.03
PHPMailer 구글 SMTP 메일 보내기  (0) 2018.08.23
블로그 이미지

iesay

,