@urbansolv/create-nestjs-app 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
2
 
3
3
  export class ApiResponseDto<T = any> {
4
- @ApiProperty({ example: true })
5
- success: boolean;
4
+ @ApiProperty({ example: 200 })
5
+ statusCode: number;
6
6
 
7
7
  @ApiProperty({ example: 'Operation successful' })
8
8
  message: string;
@@ -43,7 +43,7 @@ export class HttpExceptionFilter implements ExceptionFilter {
43
43
  );
44
44
 
45
45
  const errorResponse: ApiResponseDto<null> = {
46
- success: false,
46
+ statusCode: status,
47
47
  message,
48
48
  data: null,
49
49
  errors,
@@ -18,7 +18,7 @@ export class TransformInterceptor<T> implements NestInterceptor<T, ApiResponseDt
18
18
  return next.handle().pipe(
19
19
  map((data) => {
20
20
  // If data is already in ApiResponseDto format, return as is
21
- if (data && typeof data === 'object' && 'success' in data && 'message' in data) {
21
+ if (data && typeof data === 'object' && 'statusCode' in data && 'message' in data) {
22
22
  return data;
23
23
  }
24
24
 
@@ -43,7 +43,7 @@ export class TransformInterceptor<T> implements NestInterceptor<T, ApiResponseDt
43
43
  }
44
44
 
45
45
  return {
46
- success: true,
46
+ statusCode: response.statusCode || HttpStatus.OK,
47
47
  message,
48
48
  data,
49
49
  timestamp: new Date().toISOString(),
@@ -48,13 +48,6 @@ export class AuthService {
48
48
  throw new UnauthorizedException('Account is inactive');
49
49
  }
50
50
 
51
- console.log({
52
- passwordInput: loginDto.password,
53
- passwordHash: user.password,
54
- isActive: user.is_active,
55
- deletedAt: user.deleted_at,
56
- });
57
-
58
51
  // Verify password
59
52
  const isPasswordValid = await PasswordUtil.compare(password, user.password);
60
53
  if (!isPasswordValid) {
@@ -114,6 +114,10 @@ export class UsersService {
114
114
  this.prisma.user.count({ where }),
115
115
  ]);
116
116
 
117
+ if (total === 0) {
118
+ throw new NotFoundException('No users found');
119
+ }
120
+
117
121
  return {
118
122
  data: UserTransformHelper.toEntities(users),
119
123
  meta: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urbansolv/create-nestjs-app",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "CLI generator for Urbansolv NestJS boilerplate with RBAC and Prisma",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,8 +1,8 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
2
 
3
3
  export class ApiResponseDto<T = any> {
4
- @ApiProperty({ example: true })
5
- success: boolean;
4
+ @ApiProperty({ example: 200 })
5
+ statusCode: number;
6
6
 
7
7
  @ApiProperty({ example: 'Operation successful' })
8
8
  message: string;
@@ -43,7 +43,7 @@ export class HttpExceptionFilter implements ExceptionFilter {
43
43
  );
44
44
 
45
45
  const errorResponse: ApiResponseDto<null> = {
46
- success: false,
46
+ statusCode: status,
47
47
  message,
48
48
  data: null,
49
49
  errors,
@@ -18,7 +18,7 @@ export class TransformInterceptor<T> implements NestInterceptor<T, ApiResponseDt
18
18
  return next.handle().pipe(
19
19
  map((data) => {
20
20
  // If data is already in ApiResponseDto format, return as is
21
- if (data && typeof data === 'object' && 'success' in data && 'message' in data) {
21
+ if (data && typeof data === 'object' && 'statusCode' in data && 'message' in data) {
22
22
  return data;
23
23
  }
24
24
 
@@ -43,7 +43,7 @@ export class TransformInterceptor<T> implements NestInterceptor<T, ApiResponseDt
43
43
  }
44
44
 
45
45
  return {
46
- success: true,
46
+ statusCode: response.statusCode || HttpStatus.OK,
47
47
  message,
48
48
  data,
49
49
  timestamp: new Date().toISOString(),
@@ -48,13 +48,6 @@ export class AuthService {
48
48
  throw new UnauthorizedException('Account is inactive');
49
49
  }
50
50
 
51
- console.log({
52
- passwordInput: loginDto.password,
53
- passwordHash: user.password,
54
- isActive: user.is_active,
55
- deletedAt: user.deleted_at,
56
- });
57
-
58
51
  // Verify password
59
52
  const isPasswordValid = await PasswordUtil.compare(password, user.password);
60
53
  if (!isPasswordValid) {
@@ -114,6 +114,10 @@ export class UsersService {
114
114
  this.prisma.user.count({ where }),
115
115
  ]);
116
116
 
117
+ if (total === 0) {
118
+ throw new NotFoundException('No users found');
119
+ }
120
+
117
121
  return {
118
122
  data: UserTransformHelper.toEntities(users),
119
123
  meta: {