# hinos-requestmatcher

> Module help parse type for request query, params, body before get data in controller for hinos

Latest version **1.0.7** (published 2017-08-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install hinos-requestmatcher
pnpm add hinos-requestmatcher
yarn add hinos-requestmatcher
bun add hinos-requestmatcher
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2017-08-07 |
| First published | 2017-05-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | doanthuanthanh88@gmail.com |
| Maintainers | doanthuanthanh88 |

## Links

- npm: https://www.npmjs.com/package/hinos-requestmatcher
- npm.io page: https://npm.io/package/hinos-requestmatcher

## Recent versions

- 1.0.7 (latest) — 2017-08-07
- 1.0.6 — 2017-08-07
- 1.0.5 — 2017-07-11
- 1.0.4 — 2017-06-28
- 1.0.3 — 2017-05-26
- 1.0.2 — 2017-05-24
- 1.0.1 — 2017-05-23
- 1.0.0 — 2017-05-22

## README

# hi-requestmatcher
A plugin cast type for request as query, params, body before get data in controller [hinos](https://github.com/doanthuanthanh88/hinos)

# Install
```nodejs
npm i hinos-requestmatcher -S
```

# Examples

### Typescript
File controller
```nodejs
import { GET, POST, PUT, DELETE, HEAD } from 'hinos-route';
import { BODYPARSER } from 'hinos-bodyparser';
import { MATCHER } from 'hinos-requestmatcher';

export default class ChartController {

    @POST('/chart/:id')
    @BODYPARSER() // Parse body first
    @MATCHER({ // Cast data type
        params: {
            id: Mongo.uuid    
        }, 
        body: {
            name: String,
            des: String,
            id: id => +id; // Customize parser, can use async, await
        }
    })
    static async add({
        params, // get after parse and match
		body // get after parse and match
	}) {
        const rs: Chart = await ChartService.insert(body);
        return rs;
    }
}
```

---
_Source: https://npm.io/package/hinos-requestmatcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
