Skip to content

Commit 576f25e

Browse files
committed
release(): release v11
1 parent 7de452a commit 576f25e

File tree

11 files changed

+48
-31
lines changed

11 files changed

+48
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Awesome NestJS Boilerplate v10
1+
# Awesome NestJS Boilerplate v11
22

33
[![Awesome NestJS](https://img.shields.io/badge/Awesome-NestJS-blue.svg?longCache=true&style=flat-square)](https://github.com/juliandavidmr/awesome-nestjs)
44

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "awesome-nestjs-boilerplate",
3-
"version": "10.0.0",
3+
"version": "11.0.0",
44
"description": "Awesome NestJS Boilerplate, Typescript, Postgres, TypeORM",
55
"author": "Narek Hakobyan <narek.hakobyan.07@gmail.com>",
66
"private": true,
77
"license": "MIT",
88
"type": "module",
99
"scripts": {
10-
"build:prod": "vite build",
10+
"build:prod": "nest build",
1111
"start:dev": "vite",
1212
"nest:start": "nest start ./src/main.ts",
1313
"nest:start:dev": "nest start --watch",

src/app.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './boilerplate.polyfill.ts';
2-
31
import path from 'node:path';
42

53
import { Module } from '@nestjs/common';

src/common/dto/page-options.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ export class PageOptionsDto {
99
@EnumFieldOptional(() => Order, {
1010
default: Order.ASC,
1111
})
12-
readonly order: Order = Order.ASC;
12+
readonly order!: Order;
1313

1414
@NumberFieldOptional({
1515
minimum: 1,
1616
default: 1,
1717
int: true,
1818
})
19-
readonly page: number = 1;
19+
readonly page!: number;
2020

2121
@NumberFieldOptional({
2222
minimum: 1,
2323
maximum: 50,
2424
default: 10,
2525
int: true,
2626
})
27-
readonly take: number = 10;
27+
readonly take!: number;
2828

2929
get skip(): number {
3030
return (this.page - 1) * this.take;

src/decorators/field.decorators.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function NumberField(
8181
}
8282

8383
if (options.swagger !== false) {
84-
decorators.push(ApiProperty({ type: Number, ...options }));
84+
decorators.push(ApiProperty({ type: Number, ...(options as ApiPropertyOptions) }));
8585
}
8686

8787
if (options.each) {
@@ -132,7 +132,7 @@ export function StringField(
132132

133133
if (options.swagger !== false) {
134134
decorators.push(
135-
ApiProperty({ type: String, ...options, isArray: options.each }),
135+
ApiProperty({ type: String, ...(options as ApiPropertyOptions), isArray: options.each }),
136136
);
137137
}
138138

@@ -202,7 +202,7 @@ export function BooleanField(
202202
}
203203

204204
if (options.swagger !== false) {
205-
decorators.push(ApiProperty({ type: Boolean, ...options }));
205+
decorators.push(ApiProperty({ type: Boolean, ...(options as ApiPropertyOptions) }));
206206
}
207207

208208
return applyDecorators(...decorators);
@@ -238,7 +238,7 @@ export function TranslationsField(
238238
}
239239

240240
if (options.swagger !== false) {
241-
decorators.push(ApiProperty({ isArray: true, ...options }));
241+
decorators.push(ApiProperty({ isArray: true, ...(options as ApiPropertyOptions) }));
242242
}
243243

244244
return applyDecorators(...decorators);
@@ -270,7 +270,7 @@ export function TmpKeyField(
270270

271271
if (options.swagger !== false) {
272272
decorators.push(
273-
ApiProperty({ type: String, ...options, isArray: options.each }),
273+
ApiProperty({ type: String, ...(options as ApiPropertyOptions), isArray: options.each }),
274274
);
275275
}
276276

@@ -341,7 +341,7 @@ export function ClassField<TClass extends Constructor>(
341341
decorators.push(
342342
ApiProperty({
343343
type: () => entity,
344-
...options,
344+
...(options as ApiPropertyOptions),
345345
}),
346346
);
347347
}
@@ -392,7 +392,7 @@ export function EmailField(
392392
}
393393

394394
if (options.swagger !== false) {
395-
decorators.push(ApiProperty({ type: String, ...options }));
395+
decorators.push(ApiProperty({ type: String, ...(options as ApiPropertyOptions) }));
396396
}
397397

398398
return applyDecorators(...decorators);
@@ -419,7 +419,7 @@ export function PhoneField(
419419
}
420420

421421
if (options.swagger !== false) {
422-
decorators.push(ApiProperty({ type: String, ...options }));
422+
decorators.push(ApiProperty({ type: String, ...(options as ApiPropertyOptions) }));
423423
}
424424

425425
return applyDecorators(...decorators);
@@ -502,7 +502,7 @@ export function DateField(
502502
}
503503

504504
if (options.swagger !== false) {
505-
decorators.push(ApiProperty({ type: Date, ...options }));
505+
decorators.push(ApiProperty({ type: Date, ...(options as ApiPropertyOptions) }));
506506
}
507507

508508
return applyDecorators(...decorators);

src/decorators/property.decorators.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getVariableName } from '../common/utils.ts';
66
export function ApiBooleanProperty(
77
options: Omit<ApiPropertyOptions, 'type'> = {},
88
): PropertyDecorator {
9-
return ApiProperty({ type: Boolean, ...options });
9+
return ApiProperty({ type: Boolean, ...(options as ApiPropertyOptions) });
1010
}
1111

1212
export function ApiBooleanPropertyOptional(
@@ -23,7 +23,7 @@ export function ApiUUIDProperty(
2323
type: options.each ? [String] : String,
2424
format: 'uuid',
2525
isArray: options.each,
26-
...options,
26+
...(options as ApiPropertyOptions),
2727
});
2828
}
2929

@@ -42,12 +42,11 @@ export function ApiEnumProperty<TEnum>(
4242
const enumValue = getEnum() as any;
4343

4444
return ApiProperty({
45-
type: 'enum',
4645
// throw error during the compilation of swagger
4746
// isArray: options.each,
4847
enum: enumValue,
4948
enumName: getVariableName(getEnum),
50-
...options,
49+
...(options as ApiPropertyOptions),
5150
});
5251
}
5352

src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './boilerplate.polyfill';
2+
13
import {
24
ClassSerializerInterceptor,
35
HttpStatus,
@@ -87,13 +89,13 @@ export async function bootstrap(): Promise<NestExpressApplication> {
8789

8890
const port = configService.appConfig.port;
8991

90-
if (import.meta.env.PROD) {
92+
if ((<any>import.meta).env.PROD) {
9193
await app.listen(port);
94+
console.info(`server running on ${await app.getUrl()}`);
9295
}
9396

94-
console.info(`server running on ${await app.getUrl()}`);
9597

9698
return app;
9799
}
98100

99-
void bootstrap();
101+
export const viteNodeApp = bootstrap();

src/metadata.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* eslint-disable */
2+
export default async () => {
3+
const t = {
4+
["./common/dto/abstract.dto"]: await import("./common/dto/abstract.dto"),
5+
["./constants/language-code"]: await import("./constants/language-code"),
6+
["./modules/post/post.entity"]: await import("./modules/post/post.entity"),
7+
["./modules/post/dtos/post-translation.dto"]: await import("./modules/post/dtos/post-translation.dto"),
8+
["./modules/user/user.entity"]: await import("./modules/user/user.entity"),
9+
["./modules/post/post-translation.entity"]: await import("./modules/post/post-translation.entity"),
10+
["./constants/role-type"]: await import("./constants/role-type"),
11+
["./modules/user/user-settings.entity"]: await import("./modules/user/user-settings.entity"),
12+
["./constants/order"]: await import("./constants/order"),
13+
["./common/dto/page-meta.dto"]: await import("./common/dto/page-meta.dto"),
14+
["./modules/user/dtos/user.dto"]: await import("./modules/user/dtos/user.dto"),
15+
["./modules/auth/dto/token-payload.dto"]: await import("./modules/auth/dto/token-payload.dto"),
16+
["./common/dto/create-translation.dto"]: await import("./common/dto/create-translation.dto"),
17+
["./modules/auth/dto/login-payload.dto"]: await import("./modules/auth/dto/login-payload.dto"),
18+
["./modules/post/dtos/post.dto"]: await import("./modules/post/dtos/post.dto")
19+
};
20+
return { "@nestjs/swagger/plugin": { "models": [[import("./common/dto/abstract.dto"), { "AbstractDto": { id: { required: true, type: () => Object }, createdAt: { required: true, type: () => Date }, updatedAt: { required: true, type: () => Date }, translations: { required: false, type: () => [t["./common/dto/abstract.dto"].AbstractTranslationDto] } }, "AbstractTranslationDto": {} }], [import("./common/abstract.entity"), { "AbstractEntity": { id: { required: true, type: () => Object }, createdAt: { required: true, type: () => Date }, updatedAt: { required: true, type: () => Date }, translations: { required: false } }, "AbstractTranslationEntity": { languageCode: { required: true, enum: t["./constants/language-code"].LanguageCode } } }], [import("./modules/post/post-translation.entity"), { "PostTranslationEntity": { title: { required: true, type: () => String }, description: { required: true, type: () => String }, postId: { required: true, type: () => Object }, post: { required: false, type: () => t["./modules/post/post.entity"].PostEntity } } }], [import("./modules/post/dtos/post-translation.dto"), { "PostTranslationDto": { title: { required: false, type: () => String }, description: { required: false, type: () => String }, languageCode: { required: false, enum: t["./constants/language-code"].LanguageCode } } }], [import("./modules/post/dtos/post.dto"), { "PostDto": { title: { required: false, type: () => String }, description: { required: false, type: () => String }, info: { required: true, type: () => String }, translations: { required: false, type: () => [t["./modules/post/dtos/post-translation.dto"].PostTranslationDto] } } }], [import("./modules/post/post.entity"), { "PostEntity": { userId: { required: true, type: () => Object }, user: { required: true, type: () => t["./modules/user/user.entity"].UserEntity }, translations: { required: false, type: () => [t["./modules/post/post-translation.entity"].PostTranslationEntity] } } }], [import("./modules/user/dtos/user.dto"), { "UserDto": { firstName: { required: false, type: () => String, nullable: true }, lastName: { required: false, type: () => String, nullable: true }, username: { required: true, type: () => String }, role: { required: false, enum: t["./constants/role-type"].RoleType }, email: { required: false, type: () => String, nullable: true }, avatar: { required: false, type: () => String, nullable: true }, phone: { required: false, type: () => String, nullable: true }, isActive: { required: false, type: () => Boolean } } }], [import("./modules/user/user-settings.entity"), { "UserSettingsEntity": { isEmailVerified: { required: false, type: () => Boolean }, isPhoneVerified: { required: false, type: () => Boolean }, userId: { required: false, type: () => String }, user: { required: false, type: () => t["./modules/user/user.entity"].UserEntity } } }], [import("./modules/user/user.entity"), { "UserEntity": { firstName: { required: true, type: () => String, nullable: true }, lastName: { required: true, type: () => String, nullable: true }, role: { required: true, enum: t["./constants/role-type"].RoleType }, email: { required: true, type: () => String, nullable: true }, password: { required: true, type: () => String, nullable: true }, phone: { required: true, type: () => String, nullable: true }, avatar: { required: true, type: () => String, nullable: true }, fullName: { required: true, type: () => String }, settings: { required: false, type: () => t["./modules/user/user-settings.entity"].UserSettingsEntity }, posts: { required: false, type: () => [t["./modules/post/post.entity"].PostEntity] } } }], [import("./modules/user/dtos/create-settings.dto"), { "CreateSettingsDto": { isEmailVerified: { required: false, type: () => Boolean }, isPhoneVerified: { required: false, type: () => Boolean } } }], [import("./common/dto/page-options.dto"), { "PageOptionsDto": { order: { required: true, enum: t["./constants/order"].Order }, page: { required: true, type: () => Number }, take: { required: true, type: () => Number }, q: { required: false, type: () => String } } }], [import("./common/dto/page-meta.dto"), { "PageMetaDto": { page: { required: true, type: () => Number }, take: { required: true, type: () => Number }, itemCount: { required: true, type: () => Number }, pageCount: { required: true, type: () => Number }, hasPreviousPage: { required: true, type: () => Boolean }, hasNextPage: { required: true, type: () => Boolean } } }], [import("./common/dto/page.dto"), { "PageDto": { data: { required: true }, meta: { required: true, type: () => t["./common/dto/page-meta.dto"].PageMetaDto } } }], [import("./modules/user/dtos/users-page-options.dto"), { "UsersPageOptionsDto": {} }], [import("./modules/auth/dto/user-register.dto"), { "UserRegisterDto": { firstName: { required: true, type: () => String }, lastName: { required: true, type: () => String }, email: { required: true, type: () => String }, password: { required: true, type: () => String }, phone: { required: false, type: () => String } } }], [import("./modules/auth/dto/token-payload.dto"), { "TokenPayloadDto": { expiresIn: { required: true, type: () => Number }, accessToken: { required: true, type: () => String } } }], [import("./modules/auth/dto/user-login.dto"), { "UserLoginDto": { email: { required: true, type: () => String }, password: { required: true, type: () => String } } }], [import("./modules/auth/dto/login-payload.dto"), { "LoginPayloadDto": { user: { required: true, type: () => t["./modules/user/dtos/user.dto"].UserDto }, token: { required: true, type: () => t["./modules/auth/dto/token-payload.dto"].TokenPayloadDto } } }], [import("./common/dto/create-translation.dto"), { "CreateTranslationDto": { languageCode: { required: true, enum: t["./constants/language-code"].LanguageCode }, text: { required: true, type: () => String } } }], [import("./modules/post/dtos/create-post.dto"), { "CreatePostDto": { title: { required: true, type: () => [t["./common/dto/create-translation.dto"].CreateTranslationDto] }, description: { required: true, type: () => [t["./common/dto/create-translation.dto"].CreateTranslationDto] } } }], [import("./modules/post/dtos/post-page-options.dto"), { "PostPageOptionsDto": {} }], [import("./modules/post/dtos/update-post.dto"), { "UpdatePostDto": {} }]], "controllers": [[import("./modules/user/user.controller"), { "UserController": { "admin": {}, "getUsers": {}, "getUser": { type: t["./modules/user/dtos/user.dto"].UserDto } } }], [import("./modules/auth/auth.controller"), { "AuthController": { "userLogin": { type: t["./modules/auth/dto/login-payload.dto"].LoginPayloadDto }, "userRegister": { type: t["./modules/user/dtos/user.dto"].UserDto }, "getCurrentUser": { type: t["./modules/user/dtos/user.dto"].UserDto } } }], [import("./modules/health-checker/health-checker.controller"), { "HealthCheckerController": { "check": { type: Object } } }], [import("./modules/post/post.controller"), { "PostController": { "createPost": { type: t["./modules/post/dtos/post.dto"].PostDto }, "getPosts": {}, "getSinglePost": { type: t["./modules/post/dtos/post.dto"].PostDto }, "updatePost": {}, "deletePost": {} } }]] } };
21+
};

src/modules/auth/public.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Strategy } from 'passport';
44

55
@Injectable()
66
export class PublicStrategy extends PassportStrategy(Strategy, 'public') {
7-
override authenticate(): void {
7+
override validate(): void {
88
this.success({ [Symbol.for('isPublic')]: true });
99
}
1010
}

src/shared/services/api-config.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common';
44
import { ConfigService } from '@nestjs/config';
55
import type { ThrottlerOptions } from '@nestjs/throttler';
66
import type { TypeOrmModuleOptions } from '@nestjs/typeorm';
7-
import { default as parse } from 'parse-duration';
7+
import parse from 'parse-duration';
88

99
import { UserSubscriber } from '../../entity-subscribers/user-subscriber.ts';
1010
import { SnakeNamingStrategy } from '../../snake-naming.strategy.ts';
@@ -93,10 +93,8 @@ export class ApiConfigService {
9393
return {
9494
entities,
9595
migrations,
96-
keepConnectionAlive: !this.isTest,
9796
dropSchema: this.isTest,
9897
type: 'postgres',
99-
name: 'default',
10098
host: this.getString('DB_HOST'),
10199
port: this.getNumber('DB_PORT'),
102100
username: this.getString('DB_USERNAME'),

0 commit comments

Comments
 (0)