1- <p align =" center " >
1+ <div align =" center " >
22 <a aria-label =" Story of AMS logo " href =" https://storyofams.com/ " target =" _blank " align =" center " >
33 <img src="https://storyofams.com/public/[email protected] " alt="Story of AMS" width="120"> 44 </a >
55 <h1 align =" center " >@storyofams/next-api-decorators</h1 >
6- </ p >
7-
8- < p align = " center " >Collection of decorators to create typed Next.js API routes, with easy request validation and transformation.</ p >
9-
10- < p align = " center " >
11- < a aria-label = " releases " href = " https://GitHub.com/ storyofams/next-api-decorators/releases/ " >
12- <img src="https://github.com/storyofams/next-api-decorators/workflows/Release/badge.svg" >
13- </ a >
14- < a aria-label = " npm " href = " https://www.npmjs.com/package/@ storyofams/next -api-decorators " >
15- <img src="https://img.shields.io/npm/v/@storyofams/next-api-decorators" >
16- </ a >
17- < a aria-label = " stars " href = " https://github.com/ storyofams/next-api-decorators/stargazers/ " >
18- <img src="https://img.shields.io/github/stars/storyofams/next-api-decorators.svg?style=social&label=Star&maxAge=86400" / >
19- </a >
20- </p >
6+ < p align = " center " >
7+ <a aria-label="releases" href="https://GitHub.com/storyofams/next-api-decorators/releases/" target="_blank">
8+ <img src="https://github.com/storyofams/next-api-decorators/workflows/Release/badge.svg" >
9+ </a>
10+ <a aria-label="npm" href="https://www.npmjs.com/package/@storyofams/next-api-decorators" target="_blank ">
11+ <img src=" https://img.shields.io/npm/v/@ storyofams/next-api-decorators">
12+ </a >
13+ <a aria-label="codecov" href="https://codecov.io/gh/storyofams/nextjs-api-decorators" target="_blank" >
14+ <img src=" https://codecov.io/gh/ storyofams/nextjs -api-decorators/branch/master/graph/badge.svg?token=AXW3QH19YI ">
15+ </a >
16+ <a aria-label="stars" href="https://github.com/storyofams/next-api-decorators/stargazers/" target="_blank" >
17+ <img src=" https://img.shields.io/github/stars/ storyofams/next-api-decorators.svg?style=social&label=Star&maxAge=86400" / >
18+ </a >
19+ </p >
20+ </div >
2121
2222---
2323
24+ Collection of decorators to create typed Next.js API routes, with easy request validation and transformation.
25+
2426## Installation
2527
2628Add the package to your project:
@@ -121,14 +123,14 @@ export default createHandler(User);
121123
122124### Method decorators
123125
124- | | Description |
125- | ----------------------------------------- | -------------------------------------------------- |
126- | ` @Get() ` | Marks the method as ` GET ` handler. |
127- | ` @Post() ` | Marks the method as ` POST ` handler. |
128- | ` @Put() ` | Marks the method as ` PUT ` handler. |
129- | ` @Delete() ` | Marks the method as ` DELETE ` handler. |
130- | ` @SetHeader(name: string, value: string) ` | Sets a header name/value into the route response. |
131- | ` @HttpCode(code: number) ` | Sets the http code in the route response. |
126+ | | Description |
127+ | ----------------------------------------- | ------------------------------------------------- |
128+ | ` @Get() ` | Marks the method as ` GET ` handler. |
129+ | ` @Post() ` | Marks the method as ` POST ` handler. |
130+ | ` @Put() ` | Marks the method as ` PUT ` handler. |
131+ | ` @Delete() ` | Marks the method as ` DELETE ` handler. |
132+ | ` @SetHeader(name: string, value: string) ` | Sets a header name/value into the route response. |
133+ | ` @HttpCode(code: number) ` | Sets the http code in the route response. |
132134
133135### Parameter decorators
134136
@@ -151,8 +153,8 @@ Pipes are being used to validate and transform incoming values. The pipes can be
151153
152154⚠️ Beware that they throw when the value is invalid.
153155
154- | | Description | Remarks |
155- | ------------------ | -------------------------------------------- | --------------------------------------------- |
156+ | | Description | Remarks |
157+ | ------------------ | ------------------------------------------- | --------------------------------------------- |
156158| ` ParseNumberPipe ` | Validates and transforms ` Number ` strings. | Uses ` parseFloat ` under the hood |
157159| ` ParseBooleanPipe ` | Validates and transforms ` Boolean ` strings. | Allows ` 'true' ` and ` 'false' ` as valid values |
158160
0 commit comments