일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- js
- Express
- sqlite
- Linux
- figma
- PRISMA
- ML
- react
- Git
- CV
- vscode
- mongo
- UI
- C++
- CSS
- frontend
- PyTorch
- python
- SOLID
- threejs
- postgresql
- GAN
- review
- DM
- ts
- html
- DB
- API
- nodejs
- ps
- Today
- Total
목록Backend/Node.js (11)
아카이브
패키지 설치가 필요한 미들웨어 입니다. https://github.com/expressjs/multer/blob/master/doc/README-ko.md multer/doc/README-ko.md at master · expressjs/multerNode.js middleware for handling `multipart/form-data`. - expressjs/multergithub.com multer는 요청의 ContentType 헤더 값이 multipart/form-data 라면, 요청의 body에 담긴 데이터들을 객체로 불러옵니다. import express from 'express';import multer from 'multer';const app = express();const uploa..
패키지 설치가 필요한 미들웨어 입니다.https://github.com/expressjs/morgan?tab=readme-ov-file#predefined-formats GitHub - expressjs/morgan: HTTP request logger middleware for node.jsHTTP request logger middleware for node.js. Contribute to expressjs/morgan development by creating an account on GitHub.github.com morgan은 서버로 들어온 요청을 로그 보기 쉽게 남겨주는 미들웨어입니다.인자로는 '로그를 얼마나 자세하게 기록할 것인지'를 넘겨줄 수 있습니다.이는 tiny, short와 같은 예약..

route( )미들웨어의 기능을 추가하다보면 이렇게 중복되는 경로들이 많아지는 경우가 있습니다.아래 코드의 경우 /products의 경로가 중복해서 나타나는 것을 볼 수 있습니다.import express from 'express'const app = express()app.get('/products', (req, res) => { res.json({ message: 'get Product list' })})app.post('/products', (req, res) => { res.json({ message: 'add Product' })})app.patch('/products/:id', (req, res) => { res.json({ message: 'modify Product' })}..
패키지 설치가 필요한 미들웨어 입니다. cookie-parser는 요청으로 전달받은 쿠키를 파싱해주는 미들웨어입니다.쿠키는 요청의 헤더값으로 전달되며, 원래는 문자열의 형태로 읽어올 수 있습니다.import express from 'express'const app = express()app.get('/login', (req, res) => { console.log(req.headers.cookie) // cookie 헤더의 값을 출력합니다. return res.json({ message: 'get method called' })})app.listen(3000, () => { console.log('Server is listening on port 3000')})다음과 같이 쿠키로 id=2345값을..
Express에는 미리 만들어져 있는 내장 미들웨어들이 있습니다.내장 미들웨어는 모든 경로에 대한 요청과 응답을 대상으로 실행되는 경우가 대부분이기 때문에,경로를 생략하고 미들웨어를 인자로 넘겨줍니다.express.json( )요청의 ContentType 헤더 값이 application/json 이라면, 요청의 body에 담긴 json을 객체로 불러옵니다.express.json( ) 없이는 요청의 body 값을 다른 미들웨어의 req.body 속성을 통해 불러올 수 없습니다.때문에 다른 미들웨어들보다 먼저 실행되어야 합니다.const app = express()app.use(express.json()) // 다른 미들웨어보다 먼저 실행됩니다.app.post('/endpoint', (req, res) =>..
Express는 각 http 메소드를 통해 특정 엔드포인트에 접근할 때 미들웨어 함수를 호출할 수 있습니다.여기에 더해 express는 다른 메소드 함수도 제공하고 있습니다.all( )all 함수는 모든 종류의 http 메소드에 해당합니다.따라서 POST, GET 등의 메소드 종류에 관계 없이 미들웨어를 호출합니다.const app = express()// all은 모든 메소드에서 호출됩니다.app.all('/endpoint', (req, res, next) => { console.log('all method called') next()})// GET 메소드에서만 호출됩니다.app.get('/endpoint', (req, res, next) => { console.log('GET meth..
Express 객체를 이용해 미들웨어로 작용할 함수를 호출하는 방법에 대해 설명합니다. Express 객체를 생성하면, API 요청이 발생할 때 요청의 종류(GET, POST 등)에 따라 사용자가 원하는 함수를 실행하게 할 수 있습니다.import express from 'express';const app = express();이렇게 생성한 객체 app은 http 메소드들을 함수로 사용할 수 있으며, 엔드포인트와 콜백함수를 인자로 받습니다.// get() : GET 메소드를 사용합니다.// '/endpoint' : 요청이 도달할 서버의 엔드포인트입니다.// callback_function : 해당 엔드포인트에 이 요청이 전송되면, 이 함수를 호출합니다.app.get('/..

Express는 Node.js를 이용해 서버를 만들 수 있는 Node.js 웹 프레임워크입니다.Express는 미들웨어, 라우터, 에러 핸들러와 같이 서버 구성에 필요한 기능들을 API 형태로 제공하고 있습니다. ※ 미들웨어(middleware) : 클라이언트와 서버의 중간에서 요청과 응답을 먼저 받은 뒤 추가적인 작업을 처리하여 전달해주는 소프트웨어 또는 함수 https://expressjs.com/ko/ Express - Node.js 웹 애플리케이션 프레임워크Node.js를 위한 빠르고 개방적인 간결한 웹 프레임워크 $ npm install express --saveexpressjs.com