반응형
ChatGPT 도움을 받아보았습니다.
Koa - next generation web framework for node.js
Introduction Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. By leveraging async functions, Koa allows you to ditch callbacks and greatly
koajs.com
// Koa 프레임워크를 가져옵니다.
const Koa = require('koa');
// 들어오는 요청 바디를 구문 분석하는 데 사용되는 koa-bodyparser 미들웨어를 가져옵니다.
const bodyParser = require('koa-bodyparser');
// 웹 어플리케이션의 라우트를 정의하는 데 사용되는 router 모듈을 가져옵니다.
const router = require('./router');
// 새로운 Koa 어플리케이션 인스턴스를 생성합니다.
const app = new Koa();
// Koa 어플리케이션 인스턴스에 koa-bodyparser 미들웨어를 추가합니다.
// 들어오는 요청 바디를 구문 분석하고, ctx.request.body 속성으로 Koa 컨텍스트 객체에서 사용할 수 있게 합니다.
app.use(bodyParser());
// Koa 어플리케이션 인스턴스에 router 미들웨어를 추가합니다.
// router 미들웨어는 router 모듈에서 정의된 적절한 라우트 핸들러에 들어오는 요청을 매칭시킵니다.
app.use(router.routes());
// Koa 어플리케이션을 시작하고 포트 3000에서 들어오는 요청을 수신 대기합니다.
app.listen(3000);
반응형
'자바스크립트 > node.js' 카테고리의 다른 글
* socket.io 샘플 예제 (0) | 2023.04.22 |
---|---|
* SuperAgent 샘플 예제 (0) | 2023.04.22 |