@urbansolv/create-nestjs-app 1.2.8 → 1.2.10

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.
@@ -0,0 +1,35 @@
1
+ import { Prisma } from '@prisma/client';
2
+
3
+ export function getErrorMessage(error: unknown): string {
4
+ if (error instanceof Error) {
5
+ return error.message;
6
+ }
7
+
8
+ // Prisma known error
9
+ if (error instanceof Prisma.PrismaClientKnownRequestError) {
10
+ return error.message;
11
+ }
12
+
13
+ // Prisma validation error
14
+ if (error instanceof Prisma.PrismaClientValidationError) {
15
+ return error.message;
16
+ }
17
+
18
+ // String thrown
19
+ if (typeof error === 'string') {
20
+ return error;
21
+ }
22
+
23
+ // Object with message
24
+ if (
25
+ typeof error === 'object' &&
26
+ error !== null &&
27
+ 'message' in error &&
28
+ typeof (error as any).message === 'string'
29
+ ) {
30
+ return (error as any).message;
31
+ }
32
+
33
+ // Fallback
34
+ return 'Unexpected error occurred';
35
+ }
@@ -1,5 +1,5 @@
1
- import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
2
- import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
1
+ import { Controller, Post, Body, HttpCode, HttpStatus, UseGuards } from '@nestjs/common';
2
+ import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
3
3
  import { AuthService } from '../../auth.service';
4
4
  import { LoginDto } from '../../core/dto/login.dto';
5
5
  import { RegisterDto } from '../../core/dto/register.dto';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urbansolv/create-nestjs-app",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "CLI generator for Urbansolv NestJS boilerplate with RBAC and Prisma",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1,35 @@
1
+ import { Prisma } from '@prisma/client';
2
+
3
+ export function getErrorMessage(error: unknown): string {
4
+ if (error instanceof Error) {
5
+ return error.message;
6
+ }
7
+
8
+ // Prisma known error
9
+ if (error instanceof Prisma.PrismaClientKnownRequestError) {
10
+ return error.message;
11
+ }
12
+
13
+ // Prisma validation error
14
+ if (error instanceof Prisma.PrismaClientValidationError) {
15
+ return error.message;
16
+ }
17
+
18
+ // String thrown
19
+ if (typeof error === 'string') {
20
+ return error;
21
+ }
22
+
23
+ // Object with message
24
+ if (
25
+ typeof error === 'object' &&
26
+ error !== null &&
27
+ 'message' in error &&
28
+ typeof (error as any).message === 'string'
29
+ ) {
30
+ return (error as any).message;
31
+ }
32
+
33
+ // Fallback
34
+ return 'Unexpected error occurred';
35
+ }
@@ -1,5 +1,5 @@
1
- import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
2
- import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
1
+ import { Controller, Post, Body, HttpCode, HttpStatus, UseGuards } from '@nestjs/common';
2
+ import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
3
3
  import { AuthService } from '../../auth.service';
4
4
  import { LoginDto } from '../../core/dto/login.dto';
5
5
  import { RegisterDto } from '../../core/dto/register.dto';