Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/val-istar-guo/nestjs-take-type
A type helper extend from @nestjs/swagger
https://github.com/val-istar-guo/nestjs-take-type
Last synced: about 1 month ago
JSON representation
A type helper extend from @nestjs/swagger
- Host: GitHub
- URL: https://github.com/val-istar-guo/nestjs-take-type
- Owner: Val-istar-Guo
- License: mit
- Created: 2022-02-24T03:17:14.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T08:49:36.000Z (about 1 year ago)
- Last Synced: 2024-11-09T09:40:57.507Z (about 2 months ago)
- Language: TypeScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# @miaooo/nestjs-take-type
[![version](https://img.shields.io/npm/v/@miaooo/nestjs-take-type.svg?style=flat-square)](https://www.npmjs.com/package/@miaooo/nestjs-take-type)
[![downloads](https://img.shields.io/npm/dm/@miaooo/nestjs-take-type.svg?style=flat-square)](https://www.npmjs.com/package/@miaooo/nestjs-take-type)
[![license](https://img.shields.io/npm/l/@miaooo/nestjs-take-type.svg?style=flat-square)](https://www.npmjs.com/package/@miaooo/nestjs-take-type)
[![dependencies](https://img.shields.io/librariesio/github/Val-istar-Guo/nestjs-take-type.svg?style=flat-square)](https://www.npmjs.com/package/@miaooo/nestjs-take-type)
[![coveralls](https://img.shields.io/coveralls/github/Val-istar-Guo/nestjs-take-type.svg?style=flat-square)](https://coveralls.io/github/Val-istar-Guo/nestjs-take-type)NestJS helper function that combined PartialType and PickType,
reduce duplicate definitions of parameters in dto.## Usage
```typescript
// my-entity.entity.ts
import { Entity, Column, PriamryGeneratedColumn } from 'typeorm'
import { IsString, IsNumber } from 'class-transformer'@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id: number;@IsString()
@Column()
type: string;@IsNumber()
@Column()
age: number;
}
``````typescript
// my-entity.filter.dto.ts
import { TakeType } from '@miaooo/nestjs-take-type'
import { IsString, IsNumber } from 'class-transformer'export class MyEntityFilerDTO extends TakeType(
MyEntity,
// required params
['type'],
// optional params
['age'],
) {}// this is equal to
export class MyEntityFilerDTO {
@IsString()
type!: string;@IsOptional()
@IsNumber()
age?: number;
}
```## Contributing & Development
If there is any doubt, it is very welcome to discuss the issue together.
Please read [Contributor Covenant Code of Conduct](.github/CODE_OF_CONDUCT.md) and [CONTRIBUTING](.github/CONTRIBUTING.md).