Skip to content

Commit

Permalink
feat: refresh the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbash committed Feb 6, 2024
1 parent bb6c86f commit 98b8fa4
Show file tree
Hide file tree
Showing 34 changed files with 8,931 additions and 6,183 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
indent_size = 2

[*.md]
trim_trailing_whitespace = false
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
node: [18, 20]
steps:
- uses: actions/checkout@v1

Expand All @@ -21,7 +21,7 @@ jobs:
- run: npm run test:ci

- name: Collect coverage
if: matrix.node == 16
if: matrix.node == 20
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -38,10 +38,10 @@ jobs:
with:
fetch-depth: 0

- name: Use Node.js 16
- name: Use Node.js 20
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 20

- run: npm ci

Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
node_modules
.coverage
.nyc_output
.DS_Store
*.log
.vscode
.idea
lib
compiled
.awcache
.rpt2_cache
docs
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2022 glebbash <[email protected]>
Copyright 2024 glebbash <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
62 changes: 36 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,38 @@

This library combines common `@nestjs/swagger`, `class-transformer` and `class-validator` decorators that are used together into one decorator for full Nest.js DTO lifecycle including OpenAPI schema descriptions.

DTO without `nestjs-swagger-dto`:
<table>
<tr>
<th>DTO with nestjs-swagger-dto</th>
<th>DTO without nestjs-swagger-dto</th>
</tr>
<tr>
<td>

```ts
import { IsEnum, IsNested, IsString } from 'nestjs-swagger-dto';

class RoleDto {
@IsString({
optional: true,
minLength: 3,
maxLength: 256,
})
name?: string;

@IsString({ optional: true, maxLength: 255 })
description?: string;

@IsEnum({ enum: { RoleStatus } })
status!: RoleStatus;

@IsNested({ type: PermissionDto, isArray: true })
permissions!: PermissionDto[];
}
```

</td>
<td>

```ts
import { ApiProperty } from '@nestjs/swagger';
Expand All @@ -34,32 +65,11 @@ export class RoleDto {
@ApiProperty({ type: [PermissionDto] })
permissions!: PermissionDto[];
}

```

DTO with `nestjs-swagger-dto`:

```ts
import { IsEnum, IsNested, IsString } from 'nestjs-swagger-dto';

class RoleDto {
@IsString({
optional: true,
minLength: 3,
maxLength: 256,
})
name?: string;

@IsString({ optional: true, maxLength: 255 })
description?: string;

@IsEnum({ enum: { RoleStatus } })
status!: RoleStatus;

@IsNested({ type: PermissionDto, isArray: true })
permissions!: PermissionDto[];
}
```
</td>
</tr>
</table>

## Installation

Expand Down Expand Up @@ -113,8 +123,8 @@ export class TestHeaders {
countryCode!: string;

@IsString({
isDate: { format: 'date-time' },
name: 'timestamp',
isDate: { format: 'date-time' },
})
timestamp!: string;
}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type Jest from '@jest/types';

const config: Jest.Config.InitialOptions = {
preset: "ts-jest",
preset: 'ts-jest',
moduleFileExtensions: ['js', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
Expand Down
Loading

0 comments on commit 98b8fa4

Please sign in to comment.