일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- #cloudfront #s3 #html 확장자 없애기
- 기후변화
- git pair
- lightsail nodejs apache
- this
- ESLint
- 클로저
- NPM
- OOP
- url #querystring
- jest
- TypeScript
- 객체참조 #객체
- Today
- Total
목록node.js (8)
Hello World...
app.js const express = require('express'); const jwt = require('jsonwebtoken'); const cookieParser = require('cookie-parser'); const app = express(); const secretObj = require('./config'); app.use(cookieParser()); app.get('/', (req, res) => { res.send('hello~'); }); app.get('/jwt', (req, res) => { try { const token = jwt.sign( { email: 'user@example.com' }, secretObj.secret, { expiresIn: '2h' } ..
https://dal-ya.github.io/BookNote-cojak BookNote 번호 책이름 독서상태 메모 날짜 dal-ya.github.io 나만의 독서 메모 웹 애플리케이션을 만드려다보니 어느새 부트캠프까지 다녀왔다. 해당 프로젝트의 시작은 2019년 9월이다. 9월 12일. 달랩 멘토링 서비스를 받으면서, 작지만 자신에게 필요한 유용한 것을 만들어보라는 존경하는 개발자 아샬님의 조언에서부터 시작된 프로젝트이다. 실력은 여전히 초보이지만, 도전~ 위에 페이지를 Node-Express 서버와 리액트를 이용해서 AWS에 배포까지 진행하는 것이 목적이다.
nodejs 콜백(callback) 비동기 처리 공부! pdf로 보기 목표 자바스크립트 "비동기"에 대해 레퍼런스를 참고하여 개념을 알아 봅시다. 콜백으로 비동기를 처리하는 방법에 대해 간단한 예제를 만들어 보면서 공부합니다. 자바스크립트 비동기 아래 코드를 보고 콘솔에 어떻게 출력될 지 생각해 봅시다. //* 사용자로부터 str 을 받아 wait 이후에 콘솔로 출력해주는 함수 const outpuStr = (str, wait) => { setTimeout(() => { console.log('output:', str); }, wait); }; outpuStr('1', 1000); outpuStr('2', 500); outpuStr('3', 100); 1 → 2→ 3 순서대로 출력 되었을까요? 🤔 그러면..
nodejs express(4.16) & mysql(5) 연동하는 아주 간단한 코드를 작성해보았다. node 와 mysql 이 설치되어 있어야 한다. npm init 을 하고, npm i express dotenv mysql2 를 설치한다. 기본 데이터베이스 세팅 twit001.sql /* * prepare database(mysql) * mysql -u root -p < twit001.sql * $ mysql -u root -p */ DROP database twit001; CREATE database twit001; USE twit001; CREATE table twit ( id INT(11) NOT NULL AUTO_INCREMENT, user VARCHAR(20) NOT NULL, memo VAR..
nodejs-express 에서 lowdb 를 설치하고 nodemon 을 실행하는데, 이상하게 nodemon 이 계속 리스타트 되는 문제가 있었다. 검색을 해보니 공식 깃허브에 해결 방법이 있었다 ^^ 노드몬이 db.json 를 계속 watching하고 있어서 생기는 문제 같다. https://github.com/typicode/lowdb/issues/174 package.json 을 가서 start 에서 --ignore db.json 를 추가 해주면 된다. "scripts": { "start": "nodemon server/express-app.js --ignore db.json" }
nodejs -express 에 lowdb를 연동해보려고 이것저것 해보고 있는데, res.end or res.json 앞에 return 을 작성 안 하면 에러가 발생한다는 점을 발견했다. res.end() 또는 res.josn() 서버 응답 메서드를 실행해도 함수가 종료되지 않는다. 어떻게 보면 너무 당연한 것이지만, 서버 쪽 코드를 짜면서 은근 헷갈리는 부분인 것 같다. return 을 통해 확실히 끝맺음(?) 해주어야 한다. const express = require('express'); const app = express(); const port = 3003; // lowdb setting const low = require('lowdb'); const FileSync = require('lowdb..
예제1) const url = require('url'); const qs = require('querystring'); // WAHTWG parse 방법 const myurl = new url.URL('https://www.naver.com:9000/user?name=mina#hash'); console.log(myurl); // 기존 url parse 방법 const parsedUrl = url.parse( 'https://www.naver.com:9000/user?name=mina&name=sherlock#hash' ); console.log(parsedUrl); const query = qs.parse(parsedUrl.query); console.log(query); const { name } ..