xiongzhu %!s(int64=2) %!d(string=hai) anos
pai
achega
bbb53ee37d

+ 9 - 3
src/filters/all-exceptions-filter.filter.ts

@@ -13,13 +13,19 @@ export class AllExceptionsFilter implements ExceptionFilter {
         const ctx = host.switchToHttp()
         const ctx = host.switchToHttp()
 
 
         const httpStatus = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR
         const httpStatus = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR
-
-        const res = {
+        const path = httpAdapter.getRequestUrl(ctx.getRequest())
+        let res: any = {
             status: httpStatus,
             status: httpStatus,
             path: httpAdapter.getRequestUrl(ctx.getRequest()),
             path: httpAdapter.getRequestUrl(ctx.getRequest()),
             message: (exception as any).message
             message: (exception as any).message
         }
         }
-        Logger.error(`status=${res.status}, path=${res.path}, msg=${res.message}`, 'GlobalExceptionFilter')
+        if (exception instanceof HttpException) {
+            res = exception.getResponse()
+            if (res.message instanceof Array) {
+                res.message = res.message.join()
+            }
+        }
+        Logger.error(`status=${httpStatus}, path=${path}, msg=${res.message}`, 'GlobalExceptionFilter')
 
 
         httpAdapter.reply(ctx.getResponse(), res, httpStatus)
         httpAdapter.reply(ctx.getResponse(), res, httpStatus)
     }
     }

+ 6 - 2
src/users/dto/user-register.dto.ts

@@ -1,4 +1,4 @@
-import { IsOptional, IsString } from 'class-validator'
+import { IsNumber, IsOptional, IsString } from 'class-validator'
 
 
 export class UserRegisterDto {
 export class UserRegisterDto {
     @IsString()
     @IsString()
@@ -8,6 +8,10 @@ export class UserRegisterDto {
     readonly password: string
     readonly password: string
 
 
     @IsOptional()
     @IsOptional()
-    @IsString()
+    @IsNumber()
     readonly invitor?: number
     readonly invitor?: number
+
+    @IsOptional()
+    @IsString()
+    readonly deviceId?: string
 }
 }

+ 3 - 0
src/users/entities/users.entity.ts

@@ -37,4 +37,7 @@ export class Users {
 
 
     @Column({ nullable: true })
     @Column({ nullable: true })
     iat: number
     iat: number
+
+    @Column({ nullable: true })
+    deviceId: string
 }
 }

+ 1 - 0
src/users/users.service.ts

@@ -73,6 +73,7 @@ export class UsersService {
         newUser.name = userRegister.username
         newUser.name = userRegister.username
         newUser.password = await this.hashingService.hash(userRegister.password)
         newUser.password = await this.hashingService.hash(userRegister.password)
         newUser.invitor = userRegister.invitor
         newUser.invitor = userRegister.invitor
+        newUser.deviceId = userRegister.deviceId
 
 
         return await this.userRepository.save(newUser)
         return await this.userRepository.save(newUser)
     }
     }