# Show GN: express-cargo class 기반 request parsing

> Clean Markdown view of GeekNews topic #23977. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=23977](https://news.hada.io/topic?id=23977)
- GeekNews Markdown: [https://news.hada.io/topic/23977.md](https://news.hada.io/topic/23977.md)
- Type: show
- Author: [laggu91](https://news.hada.io/@laggu91)
- Published: 2025-10-29T01:03:28+09:00
- Updated: 2025-10-29T01:03:28+09:00
- Original source: [github.com/Beyond-Imagination](https://github.com/Beyond-Imagination/express-cargo)
- Points: 1
- Comments: 0

## Topic Body

express-cargo 는 TypeScript 기반의 데코레이터 방식으로 반복적인 요청 데이터 처리를 깔끔하게 정리해주는 미들웨어입니다. req.body, req.query, req.params를 직접 다루지 않고 클래스 선언과 미들웨어 호출로 필요한 작업을 할수 있습니다.  
  
---  
  
##### 설치 방법  
```  
npm install express-cargo reflect-metadata  
```  
  
---  
##### 주요 특징  
 - @body, @query, @param, @header, @session 데코레이터 지원  
 - 하나의 클래스에서 body, query, header 등 다양한 요청 정보를 한번에 처리 가능  
 - 클래스 필드 타입에 맞게 request 값 타입 자동 변환  
 - @equal, @range, @length 등의 validation 데코레이터로 검증  
 - @transform 을 이용해 값 변환  
 - @virtual 을 이용해 다른 필드 값 참조해 값 설정   
  
---  
##### 예시 코드  
```  
class RequestExample {  
    @body()  
    name!: string  
  
    @body()  
    @min(0)  
    age!: number  
  
    @params()  
    id!: number  
  
    @header()  
    authorization!: string  
}  
  
app.post('/:id', bindingCargo(RequestExample), (req, res) => {  
    const data = getCargo&lt;RequestExample&gt;(req)  
    // write your code with bound data  
})  
```  
  
---  
##### 관련 링크  
 - github : https://github.com/Beyond-Imagination/express-cargo  
 - npm : https://www.npmjs.com/package/express-cargo  
 - docs : https://beyond-imagination.github.io/express-cargo  
  
---  
피드백 언제든지 환영합니다. 많이 사용해보시고 의견 부탁드립니다

## Comments



_No public comments on this page._
