rl-core-api 0.1.0
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.
- package/README.md +99 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +19 -0
- package/dist/core/auth/authenticatedUser.interface.d.ts +16 -0
- package/dist/core/auth/authenticatedUser.interface.js +2 -0
- package/dist/core/auth/cookie.util.d.ts +9 -0
- package/dist/core/auth/cookie.util.js +28 -0
- package/dist/core/auth/decorators/currentUser.decorator.d.ts +2 -0
- package/dist/core/auth/decorators/currentUser.decorator.js +9 -0
- package/dist/core/auth/decorators/public.decorator.d.ts +3 -0
- package/dist/core/auth/decorators/public.decorator.js +7 -0
- package/dist/core/auth/decorators/requirePermission.decorator.d.ts +5 -0
- package/dist/core/auth/decorators/requirePermission.decorator.js +10 -0
- package/dist/core/auth/guards/appThrottler.guard.d.ts +5 -0
- package/dist/core/auth/guards/appThrottler.guard.js +23 -0
- package/dist/core/auth/guards/csrf.guard.d.ts +8 -0
- package/dist/core/auth/guards/csrf.guard.js +55 -0
- package/dist/core/auth/guards/jwtAuth.guard.d.ts +10 -0
- package/dist/core/auth/guards/jwtAuth.guard.js +37 -0
- package/dist/core/auth/guards/permissions.guard.d.ts +7 -0
- package/dist/core/auth/guards/permissions.guard.js +42 -0
- package/dist/core/bootstrap/bootstrapCore.util.d.ts +9 -0
- package/dist/core/bootstrap/bootstrapCore.util.js +67 -0
- package/dist/core/config/config.module.d.ts +8 -0
- package/dist/core/config/config.module.js +34 -0
- package/dist/core/config/env.schema.d.ts +65 -0
- package/dist/core/config/env.schema.js +94 -0
- package/dist/core/config/env.service.d.ts +7 -0
- package/dist/core/config/env.service.js +27 -0
- package/dist/core/context/auditContext.d.ts +7 -0
- package/dist/core/context/auditContext.js +5 -0
- package/dist/core/core.module.d.ts +11 -0
- package/dist/core/core.module.js +73 -0
- package/dist/core/database/base.schema.d.ts +7 -0
- package/dist/core/database/base.schema.js +49 -0
- package/dist/core/database/createDataSource.util.d.ts +8 -0
- package/dist/core/database/createDataSource.util.js +27 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.d.ts +6 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.js +272 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.d.ts +6 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.js +19 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.d.ts +6 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.js +15 -0
- package/dist/core/database/migrations/1786233600000-Notifications.d.ts +6 -0
- package/dist/core/database/migrations/1786233600000-Notifications.js +59 -0
- package/dist/core/database/migrations/index.d.ts +3 -0
- package/dist/core/database/migrations/index.js +13 -0
- package/dist/core/database/seeds/runSeeds.d.ts +1 -0
- package/dist/core/database/seeds/runSeeds.js +20 -0
- package/dist/core/database/seeds/seedAdmin.d.ts +2 -0
- package/dist/core/database/seeds/seedAdmin.js +44 -0
- package/dist/core/database/seeds/seedPermissions.d.ts +2 -0
- package/dist/core/database/seeds/seedPermissions.js +93 -0
- package/dist/core/events/appEvent.enum.d.ts +31 -0
- package/dist/core/events/appEvent.enum.js +12 -0
- package/dist/core/filters/allExceptions.filter.d.ts +5 -0
- package/dist/core/filters/allExceptions.filter.js +61 -0
- package/dist/core/filters/appErrorCode.enum.d.ts +9 -0
- package/dist/core/filters/appErrorCode.enum.js +13 -0
- package/dist/core/health/health.controller.d.ts +11 -0
- package/dist/core/health/health.controller.js +56 -0
- package/dist/core/logger/winston.config.d.ts +2 -0
- package/dist/core/logger/winston.config.js +74 -0
- package/dist/core/mailer/mailer.module.d.ts +2 -0
- package/dist/core/mailer/mailer.module.js +21 -0
- package/dist/core/mailer/mailer.service.d.ts +14 -0
- package/dist/core/mailer/mailer.service.js +148 -0
- package/dist/core/openapi/exportOpenapi.d.ts +1 -0
- package/dist/core/openapi/exportOpenapi.js +25 -0
- package/dist/core/query/applyFilter.util.d.ts +11 -0
- package/dist/core/query/applyFilter.util.js +122 -0
- package/dist/core/query/filter.constants.d.ts +7 -0
- package/dist/core/query/filter.constants.js +64 -0
- package/dist/core/query/filterField.interface.d.ts +35 -0
- package/dist/core/query/filterField.interface.js +2 -0
- package/dist/core/query/filterFieldType.enum.d.ts +10 -0
- package/dist/core/query/filterFieldType.enum.js +14 -0
- package/dist/core/query/filterOperator.enum.d.ts +23 -0
- package/dist/core/query/filterOperator.enum.js +28 -0
- package/dist/core/query/filterSchema.response.d.ts +17 -0
- package/dist/core/query/filterSchema.response.js +82 -0
- package/dist/core/query/filterSort.util.d.ts +7 -0
- package/dist/core/query/filterSort.util.js +11 -0
- package/dist/core/query/paginateWithFilter.util.d.ts +11 -0
- package/dist/core/query/paginateWithFilter.util.js +37 -0
- package/dist/core/query/parseFilter.util.d.ts +2 -0
- package/dist/core/query/parseFilter.util.js +220 -0
- package/dist/core/utils/codedError.util.d.ts +5 -0
- package/dist/core/utils/codedError.util.js +23 -0
- package/dist/core/utils/crypto.util.d.ts +2 -0
- package/dist/core/utils/crypto.util.js +39 -0
- package/dist/core/utils/hash.util.d.ts +6 -0
- package/dist/core/utils/hash.util.js +67 -0
- package/dist/core/utils/ip.util.d.ts +1 -0
- package/dist/core/utils/ip.util.js +15 -0
- package/dist/core/utils/pagination.util.d.ts +21 -0
- package/dist/core/utils/pagination.util.js +98 -0
- package/dist/core/utils/paginationMeta.response.d.ts +7 -0
- package/dist/core/utils/paginationMeta.response.js +32 -0
- package/dist/core/utils/password.constants.d.ts +2 -0
- package/dist/core/utils/password.constants.js +5 -0
- package/dist/core/websocket/baseGateway.d.ts +21 -0
- package/dist/core/websocket/baseGateway.js +63 -0
- package/dist/core/websocket/socket.constants.d.ts +4 -0
- package/dist/core/websocket/socket.constants.js +9 -0
- package/dist/core/websocket/socketEvent.envelope.d.ts +8 -0
- package/dist/core/websocket/socketEvent.envelope.js +11 -0
- package/dist/core/websocket/socketOrigin.util.d.ts +2 -0
- package/dist/core/websocket/socketOrigin.util.js +15 -0
- package/dist/core/websocket/wsAuth.service.d.ts +20 -0
- package/dist/core/websocket/wsAuth.service.js +97 -0
- package/dist/core/websocket/wsUserResolver.interface.d.ts +5 -0
- package/dist/core/websocket/wsUserResolver.interface.js +4 -0
- package/dist/coreEntities.d.ts +12 -0
- package/dist/coreEntities.js +35 -0
- package/dist/dataSource.d.ts +3 -0
- package/dist/dataSource.js +13 -0
- package/dist/features/audit/audit.module.d.ts +2 -0
- package/dist/features/audit/audit.module.js +44 -0
- package/dist/features/audit/domain/audit.service.d.ts +34 -0
- package/dist/features/audit/domain/audit.service.js +93 -0
- package/dist/features/audit/domain/classifyError.util.d.ts +2 -0
- package/dist/features/audit/domain/classifyError.util.js +24 -0
- package/dist/features/audit/domain/index.d.ts +2 -0
- package/dist/features/audit/domain/index.js +18 -0
- package/dist/features/audit/infra/auditData.subscriber.d.ts +17 -0
- package/dist/features/audit/infra/auditData.subscriber.js +139 -0
- package/dist/features/audit/infra/index.d.ts +7 -0
- package/dist/features/audit/infra/index.js +23 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.js +35 -0
- package/dist/features/audit/infra/schema/auditChange.schema.d.ts +14 -0
- package/dist/features/audit/infra/schema/auditChange.schema.js +68 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.d.ts +15 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.js +56 -0
- package/dist/features/audit/infra/schema/errorLog.schema.d.ts +21 -0
- package/dist/features/audit/infra/schema/errorLog.schema.js +69 -0
- package/dist/features/audit/presentation/audit.controller.d.ts +16 -0
- package/dist/features/audit/presentation/audit.controller.js +107 -0
- package/dist/features/audit/presentation/audit.interceptor.d.ts +8 -0
- package/dist/features/audit/presentation/audit.interceptor.js +78 -0
- package/dist/features/audit/presentation/filters/audit.filters.d.ts +4 -0
- package/dist/features/audit/presentation/filters/audit.filters.js +154 -0
- package/dist/features/audit/presentation/index.d.ts +2 -0
- package/dist/features/audit/presentation/index.js +18 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.d.ts +25 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.js +96 -0
- package/dist/features/audit/presentation/responses/log.response.d.ts +45 -0
- package/dist/features/audit/presentation/responses/log.response.js +164 -0
- package/dist/features/auth/auth.module.d.ts +2 -0
- package/dist/features/auth/auth.module.js +55 -0
- package/dist/features/auth/domain/auth.service.d.ts +66 -0
- package/dist/features/auth/domain/auth.service.js +289 -0
- package/dist/features/auth/domain/index.d.ts +5 -0
- package/dist/features/auth/domain/index.js +21 -0
- package/dist/features/auth/domain/jwtPayload.interface.d.ts +11 -0
- package/dist/features/auth/domain/jwtPayload.interface.js +2 -0
- package/dist/features/auth/domain/token.service.d.ts +56 -0
- package/dist/features/auth/domain/token.service.js +205 -0
- package/dist/features/auth/domain/twoFactor.service.d.ts +19 -0
- package/dist/features/auth/domain/twoFactor.service.js +103 -0
- package/dist/features/auth/domain/wsUserResolver.service.d.ts +10 -0
- package/dist/features/auth/domain/wsUserResolver.service.js +34 -0
- package/dist/features/auth/infra/index.d.ts +2 -0
- package/dist/features/auth/infra/index.js +18 -0
- package/dist/features/auth/infra/repositories/authToken.repository.d.ts +5 -0
- package/dist/features/auth/infra/repositories/authToken.repository.js +25 -0
- package/dist/features/auth/infra/schema/authToken.schema.d.ts +21 -0
- package/dist/features/auth/infra/schema/authToken.schema.js +73 -0
- package/dist/features/auth/presentation/auth.controller.d.ts +56 -0
- package/dist/features/auth/presentation/auth.controller.js +242 -0
- package/dist/features/auth/presentation/commands/clientType.enum.d.ts +4 -0
- package/dist/features/auth/presentation/commands/clientType.enum.js +8 -0
- package/dist/features/auth/presentation/commands/login.command.d.ts +4 -0
- package/dist/features/auth/presentation/commands/login.command.js +28 -0
- package/dist/features/auth/presentation/commands/password.command.d.ts +7 -0
- package/dist/features/auth/presentation/commands/password.command.js +37 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.d.ts +3 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.js +26 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.d.ts +12 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.js +68 -0
- package/dist/features/auth/presentation/index.d.ts +7 -0
- package/dist/features/auth/presentation/index.js +23 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.d.ts +19 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.js +90 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.d.ts +18 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.js +59 -0
- package/dist/features/auth/token.module.d.ts +2 -0
- package/dist/features/auth/token.module.js +23 -0
- package/dist/features/maintenance/domain/cleanup.service.d.ts +22 -0
- package/dist/features/maintenance/domain/cleanup.service.js +142 -0
- package/dist/features/maintenance/maintenance.module.d.ts +2 -0
- package/dist/features/maintenance/maintenance.module.js +24 -0
- package/dist/features/notifications/domain/enums/channelType.enum.d.ts +7 -0
- package/dist/features/notifications/domain/enums/channelType.enum.js +11 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.d.ts +8 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.js +12 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.d.ts +6 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.js +10 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.d.ts +5 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.js +9 -0
- package/dist/features/notifications/domain/notifications.service.d.ts +45 -0
- package/dist/features/notifications/domain/notifications.service.js +101 -0
- package/dist/features/notifications/infra/repositories/notification.repository.d.ts +14 -0
- package/dist/features/notifications/infra/repositories/notification.repository.js +74 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.d.ts +6 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.js +40 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.d.ts +5 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.js +25 -0
- package/dist/features/notifications/infra/schema/notification.schema.d.ts +13 -0
- package/dist/features/notifications/infra/schema/notification.schema.js +52 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.d.ts +7 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.js +38 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.d.ts +9 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.js +43 -0
- package/dist/features/notifications/notifications.module.d.ts +2 -0
- package/dist/features/notifications/notifications.module.js +45 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.d.ts +13 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.js +72 -0
- package/dist/features/notifications/presentation/domainEvents.listener.d.ts +13 -0
- package/dist/features/notifications/presentation/domainEvents.listener.js +121 -0
- package/dist/features/notifications/presentation/notifications.controller.d.ts +16 -0
- package/dist/features/notifications/presentation/notifications.controller.js +108 -0
- package/dist/features/notifications/presentation/notifications.gateway.d.ts +13 -0
- package/dist/features/notifications/presentation/notifications.gateway.js +58 -0
- package/dist/features/notifications/presentation/notifications.publisher.d.ts +9 -0
- package/dist/features/notifications/presentation/notifications.publisher.js +42 -0
- package/dist/features/notifications/presentation/responses/notification.response.d.ts +18 -0
- package/dist/features/notifications/presentation/responses/notification.response.js +72 -0
- package/dist/features/rbac/domain/index.d.ts +2 -0
- package/dist/features/rbac/domain/index.js +18 -0
- package/dist/features/rbac/domain/rbac.catalog.d.ts +21 -0
- package/dist/features/rbac/domain/rbac.catalog.js +153 -0
- package/dist/features/rbac/domain/rbac.service.d.ts +68 -0
- package/dist/features/rbac/domain/rbac.service.js +436 -0
- package/dist/features/rbac/infra/index.d.ts +12 -0
- package/dist/features/rbac/infra/index.js +28 -0
- package/dist/features/rbac/infra/repositories/action.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/action.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/group.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/group.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/permission.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/permission.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/resource.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/resource.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/role.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/role.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/scope.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/scope.repository.js +25 -0
- package/dist/features/rbac/infra/schema/action.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/action.schema.js +36 -0
- package/dist/features/rbac/infra/schema/group.schema.d.ts +12 -0
- package/dist/features/rbac/infra/schema/group.schema.js +60 -0
- package/dist/features/rbac/infra/schema/permission.schema.d.ts +15 -0
- package/dist/features/rbac/infra/schema/permission.schema.js +66 -0
- package/dist/features/rbac/infra/schema/resource.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/resource.schema.js +36 -0
- package/dist/features/rbac/infra/schema/role.schema.d.ts +8 -0
- package/dist/features/rbac/infra/schema/role.schema.js +46 -0
- package/dist/features/rbac/infra/schema/scope.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/scope.schema.js +36 -0
- package/dist/features/rbac/presentation/commands/createAction.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createAction.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.d.ts +7 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.js +54 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.js +35 -0
- package/dist/features/rbac/presentation/commands/createResource.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createResource.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createRole.command.d.ts +5 -0
- package/dist/features/rbac/presentation/commands/createRole.command.js +38 -0
- package/dist/features/rbac/presentation/commands/createScope.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createScope.command.js +32 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.js +24 -0
- package/dist/features/rbac/presentation/index.d.ts +13 -0
- package/dist/features/rbac/presentation/index.js +29 -0
- package/dist/features/rbac/presentation/rbac.controller.d.ts +54 -0
- package/dist/features/rbac/presentation/rbac.controller.js +413 -0
- package/dist/features/rbac/presentation/responses/rbac.response.d.ts +47 -0
- package/dist/features/rbac/presentation/responses/rbac.response.js +161 -0
- package/dist/features/rbac/rbac.module.d.ts +2 -0
- package/dist/features/rbac/rbac.module.js +55 -0
- package/dist/features/users/domain/avatar.service.d.ts +4 -0
- package/dist/features/users/domain/avatar.service.js +61 -0
- package/dist/features/users/domain/index.d.ts +2 -0
- package/dist/features/users/domain/index.js +18 -0
- package/dist/features/users/domain/users.service.d.ts +46 -0
- package/dist/features/users/domain/users.service.js +291 -0
- package/dist/features/users/infra/index.d.ts +4 -0
- package/dist/features/users/infra/index.js +20 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.d.ts +5 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.js +25 -0
- package/dist/features/users/infra/repositories/user.repository.d.ts +8 -0
- package/dist/features/users/infra/repositories/user.repository.js +56 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.d.ts +5 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.js +29 -0
- package/dist/features/users/infra/schema/user.schema.d.ts +28 -0
- package/dist/features/users/infra/schema/user.schema.js +153 -0
- package/dist/features/users/presentation/commands/changePassword.command.d.ts +4 -0
- package/dist/features/users/presentation/commands/changePassword.command.js +29 -0
- package/dist/features/users/presentation/commands/createUser.command.d.ts +8 -0
- package/dist/features/users/presentation/commands/createUser.command.js +56 -0
- package/dist/features/users/presentation/commands/updateProfile.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateProfile.command.js +38 -0
- package/dist/features/users/presentation/commands/updateUser.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateUser.command.js +8 -0
- package/dist/features/users/presentation/filters/users.filters.d.ts +3 -0
- package/dist/features/users/presentation/filters/users.filters.js +62 -0
- package/dist/features/users/presentation/index.d.ts +5 -0
- package/dist/features/users/presentation/index.js +21 -0
- package/dist/features/users/presentation/responses/user.response.d.ts +25 -0
- package/dist/features/users/presentation/responses/user.response.js +95 -0
- package/dist/features/users/presentation/users.controller.d.ts +30 -0
- package/dist/features/users/presentation/users.controller.js +247 -0
- package/dist/features/users/users.module.d.ts +2 -0
- package/dist/features/users/users.module.js +42 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +149 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +5 -0
- package/dist/rlCore.module.d.ts +10 -0
- package/dist/rlCore.module.js +42 -0
- package/package.json +139 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Notifications1786233600000 = void 0;
|
|
4
|
+
class Notifications1786233600000 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = "Notifications1786233600000";
|
|
7
|
+
}
|
|
8
|
+
async up(queryRunner) {
|
|
9
|
+
const ts = `
|
|
10
|
+
created_at datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
11
|
+
updated_at datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
|
12
|
+
deleted_at datetime(6) NULL
|
|
13
|
+
`;
|
|
14
|
+
await queryRunner.query(`
|
|
15
|
+
CREATE TABLE notifications (
|
|
16
|
+
id char(36) NOT NULL,
|
|
17
|
+
title varchar(255) NOT NULL,
|
|
18
|
+
body text NOT NULL,
|
|
19
|
+
payload json NULL,
|
|
20
|
+
type enum('INFO','SUCCESS','WARNING','ERROR') NOT NULL,
|
|
21
|
+
created_by char(36) NULL,
|
|
22
|
+
${ts},
|
|
23
|
+
PRIMARY KEY (id),
|
|
24
|
+
KEY IDX_notifications_created_at (created_at)
|
|
25
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
26
|
+
`);
|
|
27
|
+
await queryRunner.query(`
|
|
28
|
+
CREATE TABLE notification_scopes (
|
|
29
|
+
id char(36) NOT NULL,
|
|
30
|
+
notification_id char(36) NOT NULL,
|
|
31
|
+
scope_type enum('USER','ROLE','ALL') NOT NULL,
|
|
32
|
+
scope_key varchar(100) NULL,
|
|
33
|
+
${ts},
|
|
34
|
+
PRIMARY KEY (id),
|
|
35
|
+
KEY IDX_notification_scopes_notification (notification_id),
|
|
36
|
+
KEY IDX_notification_scopes_target (scope_type, scope_key),
|
|
37
|
+
CONSTRAINT FK_notification_scopes_notification
|
|
38
|
+
FOREIGN KEY (notification_id) REFERENCES notifications (id) ON DELETE CASCADE
|
|
39
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
40
|
+
`);
|
|
41
|
+
await queryRunner.query(`
|
|
42
|
+
CREATE TABLE notification_reads (
|
|
43
|
+
notification_id char(36) NOT NULL,
|
|
44
|
+
user_id char(36) NOT NULL,
|
|
45
|
+
read_at datetime NOT NULL,
|
|
46
|
+
PRIMARY KEY (notification_id, user_id),
|
|
47
|
+
KEY IDX_notification_reads_user (user_id),
|
|
48
|
+
CONSTRAINT FK_notification_reads_notification
|
|
49
|
+
FOREIGN KEY (notification_id) REFERENCES notifications (id) ON DELETE CASCADE
|
|
50
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
async down(queryRunner) {
|
|
54
|
+
await queryRunner.query(`DROP TABLE notification_reads`);
|
|
55
|
+
await queryRunner.query(`DROP TABLE notification_scopes`);
|
|
56
|
+
await queryRunner.query(`DROP TABLE notifications`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Notifications1786233600000 = Notifications1786233600000;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coreMigrations = void 0;
|
|
4
|
+
const _1710000000000_InitialSchema_1 = require("./1710000000000-InitialSchema");
|
|
5
|
+
const _1786060800000_FirstAccessTokenType_1 = require("./1786060800000-FirstAccessTokenType");
|
|
6
|
+
const _1786147200000_PermanentAccountLock_1 = require("./1786147200000-PermanentAccountLock");
|
|
7
|
+
const _1786233600000_Notifications_1 = require("./1786233600000-Notifications");
|
|
8
|
+
exports.coreMigrations = [
|
|
9
|
+
_1710000000000_InitialSchema_1.InitialSchema1710000000000,
|
|
10
|
+
_1786060800000_FirstAccessTokenType_1.FirstAccessTokenType1786060800000,
|
|
11
|
+
_1786147200000_PermanentAccountLock_1.PermanentAccountLock1786147200000,
|
|
12
|
+
_1786233600000_Notifications_1.Notifications1786233600000,
|
|
13
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const seedAdmin_1 = require("./seedAdmin");
|
|
4
|
+
const seedPermissions_1 = require("./seedPermissions");
|
|
5
|
+
const dataSource_1 = require("../../../dataSource");
|
|
6
|
+
async function run() {
|
|
7
|
+
await dataSource_1.AppDataSource.initialize();
|
|
8
|
+
try {
|
|
9
|
+
await (0, seedPermissions_1.seedPermissions)(dataSource_1.AppDataSource);
|
|
10
|
+
await (0, seedAdmin_1.seedAdmin)(dataSource_1.AppDataSource);
|
|
11
|
+
console.log("[seed] Concluído com sucesso.");
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
await dataSource_1.AppDataSource.destroy();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
run().catch((err) => {
|
|
18
|
+
console.error("[seed] Falhou:", err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.seedAdmin = seedAdmin;
|
|
4
|
+
const hash_util_1 = require("../../utils/hash.util");
|
|
5
|
+
const role_schema_1 = require("../../../features/rbac/infra/schema/role.schema");
|
|
6
|
+
const user_schema_1 = require("../../../features/users/infra/schema/user.schema");
|
|
7
|
+
async function seedAdmin(ds) {
|
|
8
|
+
const userRepo = ds.getRepository(user_schema_1.User);
|
|
9
|
+
const roleRepo = ds.getRepository(role_schema_1.Role);
|
|
10
|
+
const email = process.env.SEED_ADMIN_EMAIL;
|
|
11
|
+
const password = process.env.SEED_ADMIN_PASSWORD;
|
|
12
|
+
const name = process.env.SEED_ADMIN_NAME ?? "Administrador";
|
|
13
|
+
if (!email || !password) {
|
|
14
|
+
throw new Error("SEED_ADMIN_EMAIL e SEED_ADMIN_PASSWORD são obrigatórios para rodar o seed do admin (sem valor padrão, por segurança).");
|
|
15
|
+
}
|
|
16
|
+
const existing = await userRepo.findOne({
|
|
17
|
+
where: { email },
|
|
18
|
+
relations: { roles: true },
|
|
19
|
+
withDeleted: true,
|
|
20
|
+
});
|
|
21
|
+
const superAdmin = await roleRepo.findOne({ where: { name: "Super Admin" } });
|
|
22
|
+
if (!superAdmin) {
|
|
23
|
+
throw new Error('Role "Super Admin" não encontrada — rode seedPermissions antes.');
|
|
24
|
+
}
|
|
25
|
+
if (existing) {
|
|
26
|
+
if (!existing.roles?.some((r) => r.id === superAdmin.id)) {
|
|
27
|
+
existing.roles = [...(existing.roles ?? []), superAdmin];
|
|
28
|
+
await userRepo.save(existing);
|
|
29
|
+
}
|
|
30
|
+
console.log(`[seed] Admin já existe: ${email}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const admin = userRepo.create({
|
|
34
|
+
name,
|
|
35
|
+
email,
|
|
36
|
+
password: await (0, hash_util_1.hashPassword)(password),
|
|
37
|
+
passwordChangedAt: new Date(),
|
|
38
|
+
mustChangePassword: true,
|
|
39
|
+
isActive: true,
|
|
40
|
+
roles: [superAdmin],
|
|
41
|
+
});
|
|
42
|
+
await userRepo.save(admin);
|
|
43
|
+
console.log(`[seed] Admin criado: ${email} — defina a senha via SEED_ADMIN_PASSWORD e troque após o 1º acesso!`);
|
|
44
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.seedPermissions = seedPermissions;
|
|
4
|
+
const rbac_catalog_1 = require("../../../features/rbac/domain/rbac.catalog");
|
|
5
|
+
const action_schema_1 = require("../../../features/rbac/infra/schema/action.schema");
|
|
6
|
+
const permission_schema_1 = require("../../../features/rbac/infra/schema/permission.schema");
|
|
7
|
+
const resource_schema_1 = require("../../../features/rbac/infra/schema/resource.schema");
|
|
8
|
+
const role_schema_1 = require("../../../features/rbac/infra/schema/role.schema");
|
|
9
|
+
const scope_schema_1 = require("../../../features/rbac/infra/schema/scope.schema");
|
|
10
|
+
async function seedPermissions(ds) {
|
|
11
|
+
const resourceRepo = ds.getRepository(resource_schema_1.Resource);
|
|
12
|
+
const actionRepo = ds.getRepository(action_schema_1.Action);
|
|
13
|
+
const scopeRepo = ds.getRepository(scope_schema_1.Scope);
|
|
14
|
+
const permissionRepo = ds.getRepository(permission_schema_1.Permission);
|
|
15
|
+
const roleRepo = ds.getRepository(role_schema_1.Role);
|
|
16
|
+
const resources = new Map();
|
|
17
|
+
for (const r of rbac_catalog_1.RESOURCES) {
|
|
18
|
+
let entity = await resourceRepo.findOne({
|
|
19
|
+
where: { name: r.name },
|
|
20
|
+
withDeleted: true,
|
|
21
|
+
});
|
|
22
|
+
if (!entity) {
|
|
23
|
+
entity = await resourceRepo.save(resourceRepo.create(r));
|
|
24
|
+
}
|
|
25
|
+
resources.set(r.name, entity);
|
|
26
|
+
}
|
|
27
|
+
const actions = new Map();
|
|
28
|
+
for (const a of rbac_catalog_1.ACTIONS) {
|
|
29
|
+
let entity = await actionRepo.findOne({
|
|
30
|
+
where: { name: a.name },
|
|
31
|
+
withDeleted: true,
|
|
32
|
+
});
|
|
33
|
+
if (!entity) {
|
|
34
|
+
entity = await actionRepo.save(actionRepo.create(a));
|
|
35
|
+
}
|
|
36
|
+
actions.set(a.name, entity);
|
|
37
|
+
}
|
|
38
|
+
const scopes = new Map();
|
|
39
|
+
for (const s of rbac_catalog_1.SCOPES) {
|
|
40
|
+
let entity = await scopeRepo.findOne({
|
|
41
|
+
where: { name: s.name },
|
|
42
|
+
withDeleted: true,
|
|
43
|
+
});
|
|
44
|
+
if (!entity) {
|
|
45
|
+
entity = await scopeRepo.save(scopeRepo.create(s));
|
|
46
|
+
}
|
|
47
|
+
scopes.set(s.name, entity);
|
|
48
|
+
}
|
|
49
|
+
const permissions = new Map();
|
|
50
|
+
for (const p of rbac_catalog_1.PERMISSIONS) {
|
|
51
|
+
let entity = await permissionRepo.findOne({
|
|
52
|
+
where: { code: p.code },
|
|
53
|
+
withDeleted: true,
|
|
54
|
+
});
|
|
55
|
+
if (!entity) {
|
|
56
|
+
const [resourceName, actionName, scopeName] = p.code.split(":");
|
|
57
|
+
const resource = resources.get(resourceName);
|
|
58
|
+
const action = actions.get(actionName);
|
|
59
|
+
const scope = scopes.get(scopeName);
|
|
60
|
+
if (!resource || !action || !scope) {
|
|
61
|
+
throw new Error(`Permissão ${p.code} referencia resource/action/scope inexistente`);
|
|
62
|
+
}
|
|
63
|
+
entity = await permissionRepo.save(permissionRepo.create({
|
|
64
|
+
code: p.code,
|
|
65
|
+
description: p.description,
|
|
66
|
+
resourceId: resource.id,
|
|
67
|
+
actionId: action.id,
|
|
68
|
+
scopeId: scope.id,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
permissions.set(p.code, entity);
|
|
72
|
+
}
|
|
73
|
+
for (const r of rbac_catalog_1.ROLES) {
|
|
74
|
+
let role = await roleRepo.findOne({
|
|
75
|
+
where: { name: r.name },
|
|
76
|
+
relations: { permissions: true },
|
|
77
|
+
withDeleted: true,
|
|
78
|
+
});
|
|
79
|
+
if (!role) {
|
|
80
|
+
role = roleRepo.create({
|
|
81
|
+
name: r.name,
|
|
82
|
+
description: r.description,
|
|
83
|
+
permissions: [],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const codes = r.permissions === "*" ? rbac_catalog_1.PERMISSIONS.map((p) => p.code) : r.permissions;
|
|
87
|
+
role.permissions = codes
|
|
88
|
+
.map((code) => permissions.get(code))
|
|
89
|
+
.filter(Boolean);
|
|
90
|
+
await roleRepo.save(role);
|
|
91
|
+
}
|
|
92
|
+
console.log(`[seed] RBAC: ${resources.size} resources, ${actions.size} actions, ${scopes.size} scopes, ${permissions.size} permissions, ${rbac_catalog_1.ROLES.length} roles`);
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare enum AppEvent {
|
|
2
|
+
USER_LOCKED = "user.locked",
|
|
3
|
+
USER_TWO_FACTOR_RESET = "user.two-factor-reset",
|
|
4
|
+
USER_ROLES_CHANGED = "user.roles-changed",
|
|
5
|
+
USER_PASSWORD_RESET_REQUESTED = "user.password-reset-requested",
|
|
6
|
+
USER_PASSWORD_EXPIRING = "user.password-expiring",
|
|
7
|
+
SYSTEM_CLEANUP_FAILED = "system.cleanup-failed"
|
|
8
|
+
}
|
|
9
|
+
export interface UserLockedEvent {
|
|
10
|
+
userId: string;
|
|
11
|
+
userName: string;
|
|
12
|
+
userEmail: string;
|
|
13
|
+
}
|
|
14
|
+
export interface UserTwoFactorResetEvent {
|
|
15
|
+
userId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface UserRolesChangedEvent {
|
|
18
|
+
userId: string;
|
|
19
|
+
roleNames: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface UserPasswordResetRequestedEvent {
|
|
22
|
+
userId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface UserPasswordExpiringEvent {
|
|
25
|
+
userId: string;
|
|
26
|
+
daysLeft: number;
|
|
27
|
+
}
|
|
28
|
+
export interface SystemCleanupFailedEvent {
|
|
29
|
+
routine: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppEvent = void 0;
|
|
4
|
+
var AppEvent;
|
|
5
|
+
(function (AppEvent) {
|
|
6
|
+
AppEvent["USER_LOCKED"] = "user.locked";
|
|
7
|
+
AppEvent["USER_TWO_FACTOR_RESET"] = "user.two-factor-reset";
|
|
8
|
+
AppEvent["USER_ROLES_CHANGED"] = "user.roles-changed";
|
|
9
|
+
AppEvent["USER_PASSWORD_RESET_REQUESTED"] = "user.password-reset-requested";
|
|
10
|
+
AppEvent["USER_PASSWORD_EXPIRING"] = "user.password-expiring";
|
|
11
|
+
AppEvent["SYSTEM_CLEANUP_FAILED"] = "system.cleanup-failed";
|
|
12
|
+
})(AppEvent || (exports.AppEvent = AppEvent = {}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AllExceptionsFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let AllExceptionsFilter = class AllExceptionsFilter {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.logger = new common_1.Logger("Exception");
|
|
14
|
+
}
|
|
15
|
+
catch(exception, host) {
|
|
16
|
+
const ctx = host.switchToHttp();
|
|
17
|
+
const response = ctx.getResponse();
|
|
18
|
+
const request = ctx.getRequest();
|
|
19
|
+
const requestId = request.requestId ?? null;
|
|
20
|
+
const isHttp = exception instanceof common_1.HttpException;
|
|
21
|
+
const status = isHttp
|
|
22
|
+
? exception.getStatus()
|
|
23
|
+
: common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
24
|
+
let message = "Erro interno do servidor";
|
|
25
|
+
let error = "InternalServerError";
|
|
26
|
+
let errorCode = null;
|
|
27
|
+
if (isHttp) {
|
|
28
|
+
const res = exception.getResponse();
|
|
29
|
+
if (typeof res === "string") {
|
|
30
|
+
message = res;
|
|
31
|
+
}
|
|
32
|
+
else if (typeof res === "object" && res !== null) {
|
|
33
|
+
const body = res;
|
|
34
|
+
message = body.message ?? res;
|
|
35
|
+
error = body.error ?? exception.name;
|
|
36
|
+
errorCode = body.errorCode ?? null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (exception instanceof Error) {
|
|
40
|
+
if (process.env.NODE_ENV === "production") {
|
|
41
|
+
this.logger.error(`[${requestId}] ${request.method} ${request.url} - ${exception.message}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.logger.error(`[${requestId}] ${exception.message}`, exception.stack);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
response.status(status).json({
|
|
48
|
+
statusCode: status,
|
|
49
|
+
message,
|
|
50
|
+
error,
|
|
51
|
+
errorCode,
|
|
52
|
+
path: request.url,
|
|
53
|
+
timestamp: new Date().toISOString(),
|
|
54
|
+
requestId,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.AllExceptionsFilter = AllExceptionsFilter;
|
|
59
|
+
exports.AllExceptionsFilter = AllExceptionsFilter = __decorate([
|
|
60
|
+
(0, common_1.Catch)()
|
|
61
|
+
], AllExceptionsFilter);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum AppErrorCode {
|
|
2
|
+
ACCOUNT_LOCKED = "ACCOUNT_LOCKED",
|
|
3
|
+
ACCOUNT_INACTIVE = "ACCOUNT_INACTIVE",
|
|
4
|
+
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
5
|
+
INVALID_TWO_FACTOR_CODE = "INVALID_TWO_FACTOR_CODE",
|
|
6
|
+
PASSWORD_REUSED = "PASSWORD_REUSED",
|
|
7
|
+
TOO_MANY_REQUESTS = "TOO_MANY_REQUESTS",
|
|
8
|
+
INVALID_FILTER = "INVALID_FILTER"
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppErrorCode = void 0;
|
|
4
|
+
var AppErrorCode;
|
|
5
|
+
(function (AppErrorCode) {
|
|
6
|
+
AppErrorCode["ACCOUNT_LOCKED"] = "ACCOUNT_LOCKED";
|
|
7
|
+
AppErrorCode["ACCOUNT_INACTIVE"] = "ACCOUNT_INACTIVE";
|
|
8
|
+
AppErrorCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
|
|
9
|
+
AppErrorCode["INVALID_TWO_FACTOR_CODE"] = "INVALID_TWO_FACTOR_CODE";
|
|
10
|
+
AppErrorCode["PASSWORD_REUSED"] = "PASSWORD_REUSED";
|
|
11
|
+
AppErrorCode["TOO_MANY_REQUESTS"] = "TOO_MANY_REQUESTS";
|
|
12
|
+
AppErrorCode["INVALID_FILTER"] = "INVALID_FILTER";
|
|
13
|
+
})(AppErrorCode || (exports.AppErrorCode = AppErrorCode = {}));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var HealthController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.HealthController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
|
+
const typeorm_2 = require("typeorm");
|
|
21
|
+
const public_decorator_1 = require("../auth/decorators/public.decorator");
|
|
22
|
+
let HealthController = HealthController_1 = class HealthController {
|
|
23
|
+
constructor(ds) {
|
|
24
|
+
this.ds = ds;
|
|
25
|
+
this.logger = new common_1.Logger(HealthController_1.name);
|
|
26
|
+
}
|
|
27
|
+
async check() {
|
|
28
|
+
let database = "up";
|
|
29
|
+
try {
|
|
30
|
+
await this.ds.query("SELECT 1");
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
this.logger.error(`Healthcheck do banco falhou: ${err.message}`);
|
|
34
|
+
database = "down";
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
status: database === "up" ? "ok" : "degraded",
|
|
38
|
+
database,
|
|
39
|
+
timestamp: new Date().toISOString(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.HealthController = HealthController;
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, public_decorator_1.Public)(),
|
|
46
|
+
(0, common_1.Get)(),
|
|
47
|
+
__metadata("design:type", Function),
|
|
48
|
+
__metadata("design:paramtypes", []),
|
|
49
|
+
__metadata("design:returntype", Promise)
|
|
50
|
+
], HealthController.prototype, "check", null);
|
|
51
|
+
exports.HealthController = HealthController = HealthController_1 = __decorate([
|
|
52
|
+
(0, swagger_1.ApiTags)("Health"),
|
|
53
|
+
(0, common_1.Controller)({ path: "health", version: "1" }),
|
|
54
|
+
__param(0, (0, typeorm_1.InjectDataSource)()),
|
|
55
|
+
__metadata("design:paramtypes", [typeorm_2.DataSource])
|
|
56
|
+
], HealthController);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createAppLogger = createAppLogger;
|
|
37
|
+
const nest_winston_1 = require("nest-winston");
|
|
38
|
+
const winston = __importStar(require("winston"));
|
|
39
|
+
function text(value) {
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
44
|
+
return String(value);
|
|
45
|
+
}
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
function createAppLogger() {
|
|
49
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
50
|
+
return nest_winston_1.WinstonModule.createLogger({
|
|
51
|
+
level: process.env.LOG_LEVEL ?? "info",
|
|
52
|
+
transports: [
|
|
53
|
+
new winston.transports.Console({
|
|
54
|
+
format: isProd
|
|
55
|
+
? winston.format.combine(winston.format.timestamp(), winston.format.json())
|
|
56
|
+
: winston.format.combine(winston.format.timestamp(), winston.format.ms(), winston.format.colorize(), winston.format.printf((info) => {
|
|
57
|
+
const timestamp = text(info.timestamp);
|
|
58
|
+
const context = info.context ? `[${text(info.context)}] ` : "";
|
|
59
|
+
const ms = text(info.ms);
|
|
60
|
+
return `${timestamp} ${info.level} ${context}${text(info.message)} ${ms}`;
|
|
61
|
+
})),
|
|
62
|
+
}),
|
|
63
|
+
new winston.transports.File({
|
|
64
|
+
filename: "logs/error.log",
|
|
65
|
+
level: "error",
|
|
66
|
+
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
|
|
67
|
+
}),
|
|
68
|
+
new winston.transports.File({
|
|
69
|
+
filename: "logs/combined.log",
|
|
70
|
+
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MailerModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mailer_service_1 = require("./mailer.service");
|
|
12
|
+
let MailerModule = class MailerModule {
|
|
13
|
+
};
|
|
14
|
+
exports.MailerModule = MailerModule;
|
|
15
|
+
exports.MailerModule = MailerModule = __decorate([
|
|
16
|
+
(0, common_1.Global)(),
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [mailer_service_1.MailerService],
|
|
19
|
+
exports: [mailer_service_1.MailerService],
|
|
20
|
+
})
|
|
21
|
+
], MailerModule);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EnvService } from "../config/env.service";
|
|
2
|
+
export declare class MailerService {
|
|
3
|
+
private readonly env;
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly transporter;
|
|
6
|
+
constructor(env: EnvService);
|
|
7
|
+
private send;
|
|
8
|
+
private escapeHtml;
|
|
9
|
+
private layout;
|
|
10
|
+
sendTwoFactorCode(to: string, code: string, userName: string): Promise<void>;
|
|
11
|
+
sendPasswordReset(to: string, token: string, userName: string): Promise<void>;
|
|
12
|
+
private formatExpiry;
|
|
13
|
+
sendFirstAccess(to: string, token: string, userName: string): Promise<void>;
|
|
14
|
+
}
|