1.7.2 • Published 9 months ago
@buka/nestjs-type-helper v1.7.2
@nestjs/nestjs-type-helper
A set of helpers for project of NestJS + MikroORM + class-validator + class-transformer.
The purpose is to reduce duplicate decorators
For example, if we want create an Book entity. The code:
import { BigIntType, Entity, PrimaryKey, Property } from "@mikro-orm/core";
import { ApiProperty } from "@nestjs/swagger";
import { IsNumber, IsNumberString, Min } from "class-validator";
@Entity()
export class Book {
@ApiProperty({
type: "string",
description: "PK",
example: "1",
required: true,
})
@PrimaryKey({
type: new BigIntType("string"),
comment: "PK",
})
@IsNumberString()
id!: string;
@IsNumber()
@Min(0)
@ApiProperty({
type: "number",
description: "Book Price",
minimum: 0,
example: 10,
required: true,
})
@Property({
type: "int",
comment: "Book Price",
})
price!: number;
@ApiProperty({
type: "string",
description: "Book Created Time",
required: true,
})
@Property({
type: "datetime",
onCreate: () => new Date(),
defaultRaw: "CURRENT_TIMESTAMP",
comment: "Book Created Time",
})
createdAt: Date = new Date();
@ApiProperty({
type: "string",
description: "Book Last Updated Time",
required: true,
})
@Property({
type: "datetime",
onUpdate: () => new Date(),
defaultRaw: "CURRENT_TIMESTAMP",
comment: "Book Last Updated Time",
})
updatedAt: Date = new Date();
}Rewrite by @buka/nestjs-type-helpers:
import { BaseEntity, Entity } from "@mikro-orm/core";
import { EntityProperty } from "@buka/nestjs-type-helper";
@Entity()
export class Book extends BaseEntity {
@EntityProperty({
type: "int",
comment: "Book Price",
example: 10,
})
price!: number;
}Helpers
1.7.2
9 months ago
1.7.1
9 months ago
1.7.0
9 months ago
1.6.2
10 months ago
1.6.1
10 months ago
1.6.0
10 months ago
1.5.0
11 months ago
1.4.8
11 months ago
1.4.7
12 months ago
1.4.6
12 months ago
1.4.5
12 months ago
1.4.4
12 months ago
1.4.3
12 months ago
1.4.2
12 months ago
1.4.1
12 months ago
1.4.0
12 months ago
1.3.4
12 months ago
1.3.3
12 months ago
1.3.2
12 months ago
1.3.1
12 months ago
1.3.0
1 year ago
1.2.0
1 year ago
1.1.0
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago