@lenne.tech/nest-server 10.2.6 → 10.2.8
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/dist/config.env.js +75 -75
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/args/filter.args.js +1 -1
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/current-user.decorator.js.map +1 -1
- package/dist/core/common/decorators/graphql-populate.decorator.js.map +1 -1
- package/dist/core/common/decorators/graphql-service-options.decorator.js.map +1 -1
- package/dist/core/common/decorators/restricted.decorator.d.ts +4 -4
- package/dist/core/common/decorators/restricted.decorator.js +2 -2
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/enums/comparison-operator.enum.js +1 -1
- package/dist/core/common/enums/comparison-operator.enum.js.map +1 -1
- package/dist/core/common/enums/logical-operator.enum.js +1 -1
- package/dist/core/common/enums/logical-operator.enum.js.map +1 -1
- package/dist/core/common/enums/role.enum.d.ts +3 -3
- package/dist/core/common/enums/role.enum.js +2 -2
- package/dist/core/common/enums/role.enum.js.map +1 -1
- package/dist/core/common/enums/sort-order.emum.js +1 -1
- package/dist/core/common/enums/sort-order.emum.js.map +1 -1
- package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/helpers/context.helper.js +1 -1
- package/dist/core/common/helpers/context.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.d.ts +28 -4
- package/dist/core/common/helpers/db.helper.js +4 -4
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/decorator.helper.d.ts +24 -0
- package/dist/core/common/helpers/decorator.helper.js.map +1 -1
- package/dist/core/common/helpers/file.helper.js +1 -1
- package/dist/core/common/helpers/file.helper.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.d.ts +26 -2
- package/dist/core/common/helpers/filter.helper.js +3 -3
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.d.ts +2 -2
- package/dist/core/common/helpers/graphql.helper.js +1 -1
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.d.ts +3 -3
- package/dist/core/common/helpers/input.helper.js +5 -5
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/model.helper.d.ts +2 -2
- package/dist/core/common/helpers/model.helper.js +3 -3
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.d.ts +6 -6
- package/dist/core/common/helpers/service.helper.js +5 -5
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/helpers/table.helper.d.ts +9 -0
- package/dist/core/common/helpers/table.helper.js +28 -0
- package/dist/core/common/helpers/table.helper.js.map +1 -0
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/interceptors/check-response.interceptor.js.map +1 -1
- package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
- package/dist/core/common/interfaces/core-persistence-model.interface.d.ts +3 -3
- package/dist/core/common/interfaces/mailjet-options.interface.d.ts +1 -1
- package/dist/core/common/interfaces/prepare-input-options.interface.d.ts +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +15 -7
- package/dist/core/common/interfaces/service-options.interface.d.ts +31 -5
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.d.ts +24 -0
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/core/common/plugins/complexity.plugin.js +4 -4
- package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
- package/dist/core/common/plugins/mongoose-id.plugin.js.map +1 -1
- package/dist/core/common/scalars/any.scalar.js.map +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
- package/dist/core/common/scalars/date.scalar.js.map +1 -1
- package/dist/core/common/scalars/json.scalar.js.map +1 -1
- package/dist/core/common/services/brevo.service.d.ts +10 -0
- package/dist/core/common/services/brevo.service.js +75 -0
- package/dist/core/common/services/brevo.service.js.map +1 -0
- package/dist/core/common/services/config.service.js +1 -1
- package/dist/core/common/services/config.service.js.map +1 -1
- package/dist/core/common/services/core-cron-jobs.service.d.ts +2 -2
- package/dist/core/common/services/core-cron-jobs.service.js.map +1 -1
- package/dist/core/common/services/crud.service.d.ts +63 -32
- package/dist/core/common/services/crud.service.js +59 -21
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/email.service.js +5 -5
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/mailjet.service.d.ts +4 -4
- package/dist/core/common/services/mailjet.service.js +8 -8
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/core/common/services/model-doc.service.d.ts +24 -0
- package/dist/core/common/services/model-doc.service.js +1 -1
- package/dist/core/common/services/model-doc.service.js.map +1 -1
- package/dist/core/common/services/module.service.d.ts +28 -4
- package/dist/core/common/services/module.service.js +23 -7
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/services/template.service.js +3 -3
- package/dist/core/common/services/template.service.js.map +1 -1
- package/dist/core/common/types/core-model-constructor.type.d.ts +1 -1
- package/dist/core/common/types/falsy.type.d.ts +1 -1
- package/dist/core/common/types/field-selection.type.d.ts +25 -1
- package/dist/core/common/types/ids.type.d.ts +31 -7
- package/dist/core/common/types/maybe-promise.type.d.ts +1 -1
- package/dist/core/common/types/plain-input.type.d.ts +1 -1
- package/dist/core/common/types/populate-config.type.d.ts +25 -1
- package/dist/core/common/types/string-or-object-id.type.d.ts +25 -1
- package/dist/core/modules/auth/core-auth.controller.js +1 -1
- package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.module.d.ts +5 -5
- package/dist/core/modules/auth/core-auth.module.js +5 -5
- package/dist/core/modules/auth/core-auth.module.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.d.ts +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/refresh-token.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
- package/dist/core/modules/auth/interfaces/core-auth-user.interface.d.ts +1 -1
- package/dist/core/modules/auth/interfaces/core-token-data.interface.d.ts +1 -1
- package/dist/core/modules/auth/interfaces/jwt-payload.interface.d.ts +1 -1
- package/dist/core/modules/auth/services/core-auth.service.d.ts +1 -1
- package/dist/core/modules/auth/services/core-auth.service.js +10 -10
- package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
- package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js +1 -1
- package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js.map +1 -1
- package/dist/core/modules/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/core/modules/auth/tokens.decorator.js +1 -1
- package/dist/core/modules/auth/tokens.decorator.js.map +1 -1
- package/dist/core/modules/file/core-file-info.model.d.ts +24 -0
- package/dist/core/modules/file/core-file-info.model.js +5 -5
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.resolver.js +1 -1
- package/dist/core/modules/file/core-file.resolver.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +30 -6
- package/dist/core/modules/file/core-file.service.js +3 -3
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +1 -1
- package/dist/core/modules/file/interfaces/file-upload.interface.d.ts +2 -2
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.module.js +1 -1
- package/dist/core/modules/health-check/core-health-check.module.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.resolver.js +2 -2
- package/dist/core/modules/health-check/core-health-check.resolver.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.service.js +1 -1
- package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
- package/dist/core/modules/user/core-user.model.d.ts +24 -0
- package/dist/core/modules/user/core-user.model.js +1 -1
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.d.ts +25 -1
- package/dist/core/modules/user/core-user.service.js +3 -3
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user-create.input.js +1 -1
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/core.module.js +20 -20
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/server/common/models/persistence.model.d.ts +24 -0
- package/dist/server/common/models/persistence.model.js +4 -4
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/common/services/cron-jobs.service.js.map +1 -1
- package/dist/server/modules/auth/auth.controller.js.map +1 -1
- package/dist/server/modules/auth/auth.model.js.map +1 -1
- package/dist/server/modules/auth/auth.module.js +2 -2
- package/dist/server/modules/auth/auth.module.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/auth/auth.service.js +1 -1
- package/dist/server/modules/auth/auth.service.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
- package/dist/server/modules/file/file-info.model.js.map +1 -1
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/file/file.module.js +2 -2
- package/dist/server/modules/file/file.module.js.map +1 -1
- package/dist/server/modules/file/file.resolver.js +5 -5
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/file/file.service.d.ts +24 -0
- package/dist/server/modules/file/file.service.js.map +1 -1
- package/dist/server/modules/file/multer-config.service.js +2 -2
- package/dist/server/modules/file/multer-config.service.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
- package/dist/server/modules/user/inputs/user.input.js.map +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/server/modules/user/user.model.js +2 -2
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/modules/user/user.module.js +2 -2
- package/dist/server/modules/user/user.module.js.map +1 -1
- package/dist/server/modules/user/user.resolver.d.ts +1 -1
- package/dist/server/modules/user/user.resolver.js +1 -1
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.d.ts +25 -1
- package/dist/server/modules/user/user.service.js +2 -2
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/server/server.controller.js.map +1 -1
- package/dist/server/server.module.js +2 -2
- package/dist/server/server.module.js.map +1 -1
- package/dist/test/test.helper.d.ts +13 -13
- package/dist/test/test.helper.js +15 -15
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +35 -34
- package/src/config.env.ts +79 -78
- package/src/core/common/args/filter.args.ts +2 -1
- package/src/core/common/args/pagination.args.ts +1 -0
- package/src/core/common/decorators/current-user.decorator.ts +1 -0
- package/src/core/common/decorators/graphql-populate.decorator.ts +1 -0
- package/src/core/common/decorators/graphql-service-options.decorator.ts +1 -0
- package/src/core/common/decorators/restricted.decorator.ts +7 -5
- package/src/core/common/enums/comparison-operator.enum.ts +1 -1
- package/src/core/common/enums/logical-operator.enum.ts +1 -1
- package/src/core/common/enums/role.enum.ts +6 -6
- package/src/core/common/enums/sort-order.emum.ts +1 -1
- package/src/core/common/helpers/context.helper.ts +1 -1
- package/src/core/common/helpers/db.helper.ts +14 -12
- package/src/core/common/helpers/decorator.helper.ts +1 -0
- package/src/core/common/helpers/file.helper.ts +1 -1
- package/src/core/common/helpers/filter.helper.ts +6 -5
- package/src/core/common/helpers/graphql.helper.ts +7 -6
- package/src/core/common/helpers/input.helper.ts +10 -8
- package/src/core/common/helpers/model.helper.ts +6 -5
- package/src/core/common/helpers/service.helper.ts +13 -11
- package/src/core/common/helpers/table.helper.ts +37 -0
- package/src/core/common/inputs/combined-filter.input.ts +1 -0
- package/src/core/common/inputs/filter.input.ts +1 -0
- package/src/core/common/inputs/single-filter.input.ts +1 -0
- package/src/core/common/inputs/sort.input.ts +1 -0
- package/src/core/common/interceptors/check-response.interceptor.ts +1 -0
- package/src/core/common/interceptors/check-security.interceptor.ts +1 -0
- package/src/core/common/interfaces/core-persistence-model.interface.ts +3 -3
- package/src/core/common/interfaces/cron-job-config-with-time-zone.interface.ts +1 -0
- package/src/core/common/interfaces/cron-job-config-with-utc-offset.interface.ts +1 -0
- package/src/core/common/interfaces/mailjet-options.interface.ts +1 -1
- package/src/core/common/interfaces/prepare-input-options.interface.ts +1 -1
- package/src/core/common/interfaces/server-options.interface.ts +49 -23
- package/src/core/common/interfaces/service-options.interface.ts +31 -16
- package/src/core/common/models/core-persistence.model.ts +1 -0
- package/src/core/common/pipes/check-input.pipe.ts +1 -0
- package/src/core/common/pipes/map-and-validate.pipe.ts +1 -0
- package/src/core/common/plugins/complexity.plugin.ts +5 -4
- package/src/core/common/scalars/date-timestamp.scalar.ts +1 -0
- package/src/core/common/scalars/date.scalar.ts +1 -0
- package/src/core/common/services/brevo.service.ts +93 -0
- package/src/core/common/services/config.service.ts +3 -1
- package/src/core/common/services/core-cron-jobs.service.ts +3 -2
- package/src/core/common/services/crud.service.ts +113 -41
- package/src/core/common/services/email.service.ts +7 -5
- package/src/core/common/services/mailjet.service.ts +14 -13
- package/src/core/common/services/model-doc.service.ts +2 -1
- package/src/core/common/services/module.service.ts +33 -13
- package/src/core/common/services/template.service.ts +5 -3
- package/src/core/common/types/core-model-constructor.type.ts +1 -1
- package/src/core/common/types/falsy.type.ts +1 -1
- package/src/core/common/types/field-selection.type.ts +4 -3
- package/src/core/common/types/ids.type.ts +3 -3
- package/src/core/common/types/maybe-promise.type.ts +1 -1
- package/src/core/common/types/plain-input.type.ts +1 -1
- package/src/core/common/types/populate-config.type.ts +1 -1
- package/src/core/common/types/string-or-object-id.type.ts +1 -1
- package/src/core/modules/auth/core-auth.controller.ts +2 -1
- package/src/core/modules/auth/core-auth.model.ts +1 -0
- package/src/core/modules/auth/core-auth.module.ts +8 -7
- package/src/core/modules/auth/core-auth.resolver.ts +2 -1
- package/src/core/modules/auth/guards/auth.guard.ts +4 -2
- package/src/core/modules/auth/guards/refresh-token.guard.ts +1 -0
- package/src/core/modules/auth/guards/roles.guard.ts +1 -0
- package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +1 -0
- package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +1 -0
- package/src/core/modules/auth/interfaces/core-auth-user.interface.ts +4 -4
- package/src/core/modules/auth/interfaces/core-token-data.interface.ts +4 -4
- package/src/core/modules/auth/interfaces/jwt-payload.interface.ts +1 -1
- package/src/core/modules/auth/services/core-auth.service.ts +13 -11
- package/src/core/modules/auth/strategies/jwt-refresh.strategy.ts +3 -2
- package/src/core/modules/auth/strategies/jwt.strategy.ts +3 -2
- package/src/core/modules/auth/tokens.decorator.ts +4 -3
- package/src/core/modules/file/core-file-info.model.ts +6 -5
- package/src/core/modules/file/core-file.controller.ts +1 -0
- package/src/core/modules/file/core-file.resolver.ts +2 -1
- package/src/core/modules/file/core-file.service.ts +9 -8
- package/src/core/modules/file/interfaces/file-service-options.interface.ts +1 -1
- package/src/core/modules/file/interfaces/file-upload.interface.ts +2 -2
- package/src/core/modules/health-check/core-health-check-result.model.ts +1 -0
- package/src/core/modules/health-check/core-health-check.controller.ts +1 -0
- package/src/core/modules/health-check/core-health-check.module.ts +2 -1
- package/src/core/modules/health-check/core-health-check.resolver.ts +3 -2
- package/src/core/modules/health-check/core-health-check.service.ts +2 -1
- package/src/core/modules/user/core-user.model.ts +2 -1
- package/src/core/modules/user/core-user.service.ts +6 -4
- package/src/core/modules/user/inputs/core-user-create.input.ts +2 -1
- package/src/core/modules/user/inputs/core-user.input.ts +2 -1
- package/src/core.module.ts +24 -22
- package/src/index.ts +2 -0
- package/src/main.ts +5 -3
- package/src/server/common/models/persistence.model.ts +7 -5
- package/src/server/common/services/cron-jobs.service.ts +1 -0
- package/src/server/modules/auth/auth.controller.ts +1 -0
- package/src/server/modules/auth/auth.model.ts +1 -0
- package/src/server/modules/auth/auth.module.ts +3 -2
- package/src/server/modules/auth/auth.resolver.ts +1 -0
- package/src/server/modules/auth/auth.service.ts +2 -1
- package/src/server/modules/auth/inputs/auth-sign-in.input.ts +1 -0
- package/src/server/modules/auth/inputs/auth-sign-up.input.ts +1 -0
- package/src/server/modules/file/file-info.model.ts +1 -0
- package/src/server/modules/file/file.controller.ts +1 -0
- package/src/server/modules/file/file.module.ts +3 -2
- package/src/server/modules/file/file.resolver.ts +7 -5
- package/src/server/modules/file/file.service.ts +1 -0
- package/src/server/modules/file/multer-config.service.ts +3 -2
- package/src/server/modules/user/avatar.controller.ts +1 -0
- package/src/server/modules/user/inputs/user-create.input.ts +1 -0
- package/src/server/modules/user/inputs/user.input.ts +1 -0
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +1 -0
- package/src/server/modules/user/user.model.ts +3 -2
- package/src/server/modules/user/user.module.ts +3 -2
- package/src/server/modules/user/user.resolver.ts +2 -1
- package/src/server/modules/user/user.service.ts +5 -3
- package/src/server/server.controller.ts +1 -0
- package/src/server/server.module.ts +7 -6
- package/src/test/test.helper.ts +28 -26
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Types } from 'mongoose';
|
|
2
2
|
|
|
3
3
|
export type IdsType =
|
|
4
|
-
| string
|
|
4
|
+
| ({ _id?: Types.ObjectId | string; id?: Types.ObjectId | string } | Types.ObjectId | string)[]
|
|
5
|
+
| { _id?: Types.ObjectId | string; id?: Types.ObjectId | string }
|
|
5
6
|
| Types.ObjectId
|
|
6
|
-
|
|
|
7
|
-
| (string | Types.ObjectId | { id?: string | Types.ObjectId; _id?: string | Types.ObjectId })[];
|
|
7
|
+
| string;
|
|
@@ -3,4 +3,4 @@ import { PopulateOptions } from 'mongoose';
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuration (path or options) for Mongoose populate methode
|
|
5
5
|
*/
|
|
6
|
-
export type PopulateConfig =
|
|
6
|
+
export type PopulateConfig = (PopulateOptions | string)[] | PopulateOptions | string | string[];
|
|
@@ -3,4 +3,4 @@ import { Types } from 'mongoose';
|
|
|
3
3
|
/**
|
|
4
4
|
* Everything which will be used by getStringIds or getObjectIds (see helpers/db.helper.ts)
|
|
5
5
|
*/
|
|
6
|
-
export type StringOrObjectId<T = any> =
|
|
6
|
+
export type StringOrObjectId<T = any> = T | Types.ObjectId | string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Body, Controller, Get, Param, ParseBoolPipe, Post, Res, UseGuards } from '@nestjs/common';
|
|
2
2
|
import { Args } from '@nestjs/graphql';
|
|
3
3
|
import { Response as ResponseType } from 'express';
|
|
4
|
+
|
|
4
5
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
5
6
|
import { ConfigService } from '../../common/services/config.service';
|
|
6
7
|
import { AuthGuardStrategy } from './auth-guard-strategy.enum';
|
|
@@ -30,7 +31,7 @@ export class CoreAuthController {
|
|
|
30
31
|
@Res() res: ResponseType,
|
|
31
32
|
@Param('allDevices', ParseBoolPipe) allDevices?: boolean,
|
|
32
33
|
): Promise<boolean> {
|
|
33
|
-
const result = await this.authService.logout(token, {
|
|
34
|
+
const result = await this.authService.logout(token, { allDevices, currentUser });
|
|
34
35
|
return this.processCookies(res, result);
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -3,12 +3,13 @@ import { APP_GUARD } from '@nestjs/core';
|
|
|
3
3
|
import { JwtModule, JwtModuleOptions } from '@nestjs/jwt';
|
|
4
4
|
import { PassportModule } from '@nestjs/passport';
|
|
5
5
|
import { PubSub } from 'graphql-subscriptions';
|
|
6
|
+
|
|
6
7
|
import { AuthGuardStrategy } from './auth-guard-strategy.enum';
|
|
7
8
|
import { RolesGuard } from './guards/roles.guard';
|
|
8
|
-
import { JwtRefreshStrategy } from './strategies/jwt-refresh.strategy';
|
|
9
|
-
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
10
|
-
import { CoreAuthUserService } from './services/core-auth-user.service';
|
|
11
9
|
import { CoreAuthService } from './services/core-auth.service';
|
|
10
|
+
import { CoreAuthUserService } from './services/core-auth-user.service';
|
|
11
|
+
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
12
|
+
import { JwtRefreshStrategy } from './strategies/jwt-refresh.strategy';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* CoreAuthModule to handle user authentication and enables Roles
|
|
@@ -24,9 +25,9 @@ export class CoreAuthModule {
|
|
|
24
25
|
UserService: Type<CoreAuthUserService>,
|
|
25
26
|
options: JwtModuleOptions & {
|
|
26
27
|
authService?: Type<CoreAuthService>;
|
|
27
|
-
|
|
28
|
+
imports?: Array<DynamicModule | ForwardReference | Promise<DynamicModule> | Type<any>>;
|
|
28
29
|
jwtRefreshStrategy?: Type<JwtRefreshStrategy>;
|
|
29
|
-
|
|
30
|
+
jwtStrategy?: Type<JwtStrategy>;
|
|
30
31
|
providers?: Provider[];
|
|
31
32
|
},
|
|
32
33
|
): DynamicModule {
|
|
@@ -74,10 +75,10 @@ export class CoreAuthModule {
|
|
|
74
75
|
|
|
75
76
|
// Return CoreAuthModule
|
|
76
77
|
return {
|
|
77
|
-
|
|
78
|
+
exports: [CoreAuthService, JwtModule, JwtStrategy, JwtRefreshStrategy, PassportModule, UserModule],
|
|
78
79
|
imports,
|
|
80
|
+
module: CoreAuthModule,
|
|
79
81
|
providers,
|
|
80
|
-
exports: [CoreAuthService, JwtModule, JwtStrategy, JwtRefreshStrategy, PassportModule, UserModule],
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UseGuards } from '@nestjs/common';
|
|
2
2
|
import { Args, Context, Mutation, Resolver } from '@nestjs/graphql';
|
|
3
3
|
import { Response as ResponseType } from 'express';
|
|
4
|
+
|
|
4
5
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
5
6
|
import { GraphQLServiceOptions } from '../../common/decorators/graphql-service-options.decorator';
|
|
6
7
|
import { ServiceOptions } from '../../common/interfaces/service-options.interface';
|
|
@@ -39,7 +40,7 @@ export class CoreAuthResolver {
|
|
|
39
40
|
@Tokens('token') token: string,
|
|
40
41
|
@Args('allDevices', { nullable: true }) allDevices?: boolean,
|
|
41
42
|
): Promise<boolean> {
|
|
42
|
-
const result = await this.authService.logout(token, {
|
|
43
|
+
const result = await this.authService.logout(token, { allDevices, currentUser });
|
|
43
44
|
return this.processCookies(ctx, result);
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -3,12 +3,14 @@ import { GqlExecutionContext } from '@nestjs/graphql';
|
|
|
3
3
|
import { AuthModuleOptions, Type } from '@nestjs/passport';
|
|
4
4
|
import { defaultOptions } from '@nestjs/passport/dist/options';
|
|
5
5
|
import { memoize } from '@nestjs/passport/dist/utils/memoize.util';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
|
|
8
8
|
import { ExpiredRefreshTokenException } from '../exceptions/expired-refresh-token.exception';
|
|
9
9
|
import { ExpiredTokenException } from '../exceptions/expired-token.exception';
|
|
10
10
|
import { InvalidTokenException } from '../exceptions/invalid-token.exception';
|
|
11
11
|
|
|
12
|
+
import passport = require('passport');
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Missing strategy error
|
|
14
16
|
*/
|
|
@@ -132,4 +134,4 @@ function createAuthGuard(type?: string): Type<CanActivate> {
|
|
|
132
134
|
/**
|
|
133
135
|
* Export AuthGuard
|
|
134
136
|
*/
|
|
135
|
-
export const AuthGuard: (type?: string | string[]
|
|
137
|
+
export const AuthGuard: (type?: AuthGuardStrategy | string | string[]) => Type<IAuthGuard> = memoize(createAuthGuard);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
3
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
4
|
+
|
|
4
5
|
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
5
6
|
import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
|
|
6
7
|
import { ExpiredTokenException } from '../exceptions/expired-token.exception';
|
|
@@ -5,14 +5,14 @@ import { CoreTokenData } from './core-token-data.interface';
|
|
|
5
5
|
*/
|
|
6
6
|
export interface ICoreAuthUser {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Email of the user
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
email: string;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* ID of the user
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
id: string;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Password of the user
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface CoreTokenData {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Description of the device from which the token was generated
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
deviceDescription?: string;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* ID of the device from which the token was generated
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
deviceId?: string;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Token ID to make sure that there is only one RefreshToken for each device
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
1
|
import { BadRequestException, Injectable, UnauthorizedException } from '@nestjs/common';
|
|
3
2
|
import { JwtService } from '@nestjs/jwt';
|
|
4
|
-
import
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
5
4
|
import { sha256 } from 'js-sha256';
|
|
5
|
+
|
|
6
6
|
import { getStringIds } from '../../../common/helpers/db.helper';
|
|
7
7
|
import { prepareServiceOptions } from '../../../common/helpers/service.helper';
|
|
8
8
|
import { ServiceOptions } from '../../../common/interfaces/service-options.interface';
|
|
@@ -14,6 +14,8 @@ import { ICoreAuthUser } from '../interfaces/core-auth-user.interface';
|
|
|
14
14
|
import { JwtPayload } from '../interfaces/jwt-payload.interface';
|
|
15
15
|
import { CoreAuthUserService } from './core-auth-user.service';
|
|
16
16
|
|
|
17
|
+
import bcrypt = require('bcrypt');
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* CoreAuthService to handle user authentication
|
|
19
21
|
*/
|
|
@@ -72,8 +74,8 @@ export class CoreAuthService {
|
|
|
72
74
|
*/
|
|
73
75
|
async refreshTokens(user: ICoreAuthUser, currentRefreshToken: string) {
|
|
74
76
|
// Create new tokens
|
|
75
|
-
const {
|
|
76
|
-
const tokens = await this.createTokens(user.id, {
|
|
77
|
+
const { deviceDescription, deviceId } = this.decodeJwt(currentRefreshToken);
|
|
78
|
+
const tokens = await this.createTokens(user.id, { deviceDescription, deviceId });
|
|
77
79
|
tokens.refreshToken = await this.updateRefreshToken(user, currentRefreshToken, tokens.refreshToken);
|
|
78
80
|
|
|
79
81
|
// Return
|
|
@@ -97,7 +99,7 @@ export class CoreAuthService {
|
|
|
97
99
|
});
|
|
98
100
|
|
|
99
101
|
// Inputs
|
|
100
|
-
const {
|
|
102
|
+
const { deviceDescription, deviceId, email, password } = input;
|
|
101
103
|
|
|
102
104
|
// Get user
|
|
103
105
|
const user = await this.userService.getViaEmail(email, serviceOptionsForUserService);
|
|
@@ -109,7 +111,7 @@ export class CoreAuthService {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
// Return tokens and user
|
|
112
|
-
return this.getResult(user, {
|
|
114
|
+
return this.getResult(user, { deviceDescription, deviceId });
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/**
|
|
@@ -130,10 +132,10 @@ export class CoreAuthService {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
// Set device ID
|
|
133
|
-
const {
|
|
135
|
+
const { deviceDescription, deviceId } = input;
|
|
134
136
|
|
|
135
137
|
// Return tokens and user
|
|
136
|
-
return this.getResult(user, {
|
|
138
|
+
return this.getResult(user, { deviceDescription, deviceId });
|
|
137
139
|
} catch (err) {
|
|
138
140
|
if (err?.message === 'Unprocessable Entity') {
|
|
139
141
|
throw new BadRequestException('Email address already in use');
|
|
@@ -219,10 +221,10 @@ export class CoreAuthService {
|
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
const payload: { [key: string]: any;
|
|
224
|
+
const payload: { [key: string]: any; deviceId: string; id: string; tokenId: string } = {
|
|
223
225
|
...data,
|
|
224
|
-
id: userId,
|
|
225
226
|
deviceId,
|
|
227
|
+
id: userId,
|
|
226
228
|
tokenId,
|
|
227
229
|
};
|
|
228
230
|
const [token, refreshToken] = await Promise.all([
|
|
@@ -236,8 +238,8 @@ export class CoreAuthService {
|
|
|
236
238
|
}),
|
|
237
239
|
]);
|
|
238
240
|
return {
|
|
239
|
-
token,
|
|
240
241
|
refreshToken,
|
|
242
|
+
token,
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
245
|
|
|
@@ -2,6 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
|
2
2
|
import { PassportStrategy } from '@nestjs/passport';
|
|
3
3
|
import { Request, Request as RequestType } from 'express';
|
|
4
4
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
5
|
+
|
|
5
6
|
import { ConfigService } from '../../../common/services/config.service';
|
|
6
7
|
import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
|
|
7
8
|
import { CoreAuthService } from '../services/core-auth.service';
|
|
@@ -14,19 +15,19 @@ export class JwtRefreshStrategy extends PassportStrategy(Strategy, AuthGuardStra
|
|
|
14
15
|
JwtRefreshStrategy.extractJWTFromCookie,
|
|
15
16
|
ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
16
17
|
]),
|
|
18
|
+
passReqToCallback: true,
|
|
17
19
|
privateKey: configService.get('jwt.refresh.privateKey'),
|
|
18
20
|
publicKey: configService.get('jwt.refresh.publicKey'),
|
|
19
21
|
secret: configService.get('jwt.refresh.secret') || configService.get('jwt.refresh.secretOrPrivateKey'),
|
|
20
22
|
secretOrKey: configService.get('jwt.refresh.secretOrPrivateKey') || configService.get('jwt.refresh.secret'),
|
|
21
23
|
secretOrKeyProvider: configService.get('jwt.refresh.secretOrKeyProvider'),
|
|
22
|
-
passReqToCallback: true,
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Extract JWT from cookie
|
|
28
29
|
*/
|
|
29
|
-
private static extractJWTFromCookie(req: RequestType):
|
|
30
|
+
private static extractJWTFromCookie(req: RequestType): null | string {
|
|
30
31
|
return req?.cookies?.refreshToken || null;
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
2
|
import { PassportStrategy } from '@nestjs/passport';
|
|
3
|
-
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
4
3
|
import { Request as RequestType } from 'express';
|
|
4
|
+
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
5
|
+
|
|
5
6
|
import { ConfigService } from '../../../common/services/config.service';
|
|
6
7
|
import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
|
|
7
8
|
import { JwtPayload } from '../interfaces/jwt-payload.interface';
|
|
@@ -32,7 +33,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, AuthGuardStrategy.JW
|
|
|
32
33
|
/**
|
|
33
34
|
* Extract JWT from cookie
|
|
34
35
|
*/
|
|
35
|
-
private static extractJWTFromCookie(req: RequestType):
|
|
36
|
+
private static extractJWTFromCookie(req: RequestType): null | string {
|
|
36
37
|
return req?.cookies?.token || null;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
|
|
2
|
+
|
|
2
3
|
import { getContextData } from '../../common/helpers/context.helper';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -6,9 +7,9 @@ import { getContextData } from '../../common/helpers/context.helper';
|
|
|
6
7
|
*/
|
|
7
8
|
export const Tokens = createParamDecorator(
|
|
8
9
|
(
|
|
9
|
-
tokenId: '
|
|
10
|
+
tokenId: 'refreshToken' | 'token' | undefined,
|
|
10
11
|
ctx: ExecutionContext,
|
|
11
|
-
):
|
|
12
|
+
): { refreshToken: string; token: string } | string => {
|
|
12
13
|
// Get prepared context (REST or GraphQL)
|
|
13
14
|
const context = getContextData(ctx);
|
|
14
15
|
|
|
@@ -24,7 +25,7 @@ export const Tokens = createParamDecorator(
|
|
|
24
25
|
const refreshToken = context?.request?.cookies?.['refreshToken'] || token;
|
|
25
26
|
|
|
26
27
|
// Set tokens
|
|
27
|
-
const tokens = {
|
|
28
|
+
const tokens = { refreshToken, token };
|
|
28
29
|
|
|
29
30
|
// Return tokens
|
|
30
31
|
if (tokenId?.length) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
import { Prop } from '@nestjs/mongoose';
|
|
3
3
|
import { Types } from 'mongoose';
|
|
4
|
+
|
|
4
5
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -29,22 +30,22 @@ export class CoreFileInfo extends CoreModel {
|
|
|
29
30
|
+ 'except for the last, which is only as large as needed. The default size is 255 kilobytes (kB)',
|
|
30
31
|
nullable: true,
|
|
31
32
|
})
|
|
32
|
-
@Prop({
|
|
33
|
+
@Prop({ required: false, type: Number })
|
|
33
34
|
chunkSize: number = undefined;
|
|
34
35
|
|
|
35
36
|
@Field(() => String, { description: 'Content type', nullable: true })
|
|
36
|
-
@Prop({
|
|
37
|
+
@Prop({ required: false, type: String })
|
|
37
38
|
contentType?: string = undefined;
|
|
38
39
|
|
|
39
40
|
@Field(() => String, { description: 'Name of the file', nullable: true })
|
|
40
|
-
@Prop({
|
|
41
|
+
@Prop({ required: false, type: String })
|
|
41
42
|
filename?: string = undefined;
|
|
42
43
|
|
|
43
44
|
@Field(() => Number, { description: 'The size of the document in bytes', nullable: true })
|
|
44
|
-
@Prop({
|
|
45
|
+
@Prop({ required: false, type: Number })
|
|
45
46
|
length: number = undefined;
|
|
46
47
|
|
|
47
48
|
@Field(() => Date, { description: 'The date the file was first stored', nullable: true })
|
|
48
|
-
@Prop({
|
|
49
|
+
@Prop({ required: false, type: Date })
|
|
49
50
|
uploadDate: Date = undefined;
|
|
50
51
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
2
|
import * as GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { CoreFileService } from './core-file.service';
|
|
5
|
+
import { CoreFileInfo } from './core-file-info.model';
|
|
5
6
|
import { FileUpload } from './interfaces/file-upload.interface';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { MongoGridFSOptions, MongooseGridFS, createBucket } from '@lenne.tech/mongoose-gridfs';
|
|
1
2
|
import { NotFoundException } from '@nestjs/common';
|
|
2
3
|
import { GridFSBucket, GridFSBucketReadStream, GridFSBucketReadStreamOptions } from 'mongodb';
|
|
3
4
|
import { Connection, Types } from 'mongoose';
|
|
4
|
-
|
|
5
|
+
|
|
5
6
|
import { FilterArgs } from '../../common/args/filter.args';
|
|
6
7
|
import { getObjectIds, getStringIds } from '../../common/helpers/db.helper';
|
|
7
8
|
import { convertFilterArgsToQuery } from '../../common/helpers/filter.helper';
|
|
@@ -15,7 +16,7 @@ import { FileUpload } from './interfaces/file-upload.interface';
|
|
|
15
16
|
/**
|
|
16
17
|
* Type for checking input
|
|
17
18
|
*/
|
|
18
|
-
export type FileInputCheckType = 'file' | '
|
|
19
|
+
export type FileInputCheckType = 'file' | 'filename' | 'files' | 'filterArgs' | 'id';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Abstract core file service
|
|
@@ -39,9 +40,9 @@ export abstract class CoreFileService {
|
|
|
39
40
|
}
|
|
40
41
|
return await new Promise(async (resolve, reject) => {
|
|
41
42
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
42
|
-
const {
|
|
43
|
+
const { createReadStream, encoding, filename, mimetype } = await file;
|
|
43
44
|
const readStream = createReadStream();
|
|
44
|
-
const options: MongoGridFSOptions = {
|
|
45
|
+
const options: MongoGridFSOptions = { contentType: mimetype, filename };
|
|
45
46
|
this.files.writeFile(options, readStream, (error, fileInfo) => {
|
|
46
47
|
error ? reject(error) : resolve(this.prepareOutput(fileInfo, serviceOptions));
|
|
47
48
|
});
|
|
@@ -84,7 +85,7 @@ export abstract class CoreFileService {
|
|
|
84
85
|
/**
|
|
85
86
|
* Get info about file via file ID
|
|
86
87
|
*/
|
|
87
|
-
async getFileInfo(id:
|
|
88
|
+
async getFileInfo(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
|
|
88
89
|
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
89
90
|
return null;
|
|
90
91
|
}
|
|
@@ -112,7 +113,7 @@ export abstract class CoreFileService {
|
|
|
112
113
|
/**
|
|
113
114
|
* Get file stream (for big files) via file ID
|
|
114
115
|
*/
|
|
115
|
-
async getFileStream(id:
|
|
116
|
+
async getFileStream(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions) {
|
|
116
117
|
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
117
118
|
return null;
|
|
118
119
|
}
|
|
@@ -135,7 +136,7 @@ export abstract class CoreFileService {
|
|
|
135
136
|
/**
|
|
136
137
|
* Get file buffer (for small files) via file ID
|
|
137
138
|
*/
|
|
138
|
-
async getBuffer(id:
|
|
139
|
+
async getBuffer(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<Buffer> {
|
|
139
140
|
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
140
141
|
return null;
|
|
141
142
|
}
|
|
@@ -163,7 +164,7 @@ export abstract class CoreFileService {
|
|
|
163
164
|
/**
|
|
164
165
|
* Delete file reference of avatar
|
|
165
166
|
*/
|
|
166
|
-
async deleteFile(id:
|
|
167
|
+
async deleteFile(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
|
|
167
168
|
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
168
169
|
return null;
|
|
169
170
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Interface for service options in file services
|
|
3
3
|
*/
|
|
4
4
|
export interface FileServiceOptions {
|
|
5
|
-
currentUser?: {
|
|
5
|
+
currentUser?: { hasRole: (roles: string[]) => boolean; id: any };
|
|
6
6
|
force?: boolean;
|
|
7
7
|
roles?: string | string[];
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
2
1
|
import { WriteStream } from 'fs-capacitor';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for file uploads
|
|
@@ -15,7 +15,7 @@ export interface FileUpload {
|
|
|
15
15
|
*/
|
|
16
16
|
createReadStream: (options?: {
|
|
17
17
|
/** Specify an encoding for the chunks, default: utf8 */
|
|
18
|
-
encoding?: '
|
|
18
|
+
encoding?: 'ascii' | 'base64' | 'base64url' | 'hex' | 'latin1' | 'ucs2' | 'utf8' | 'utf8' | 'utf16le';
|
|
19
19
|
|
|
20
20
|
/** Maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource, default: 16384 */
|
|
21
21
|
highWaterMark?: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module } from '@nestjs/common';
|
|
2
2
|
import { TerminusModule } from '@nestjs/terminus';
|
|
3
|
+
|
|
3
4
|
import { CoreHealthCheckController } from './core-health-check.controller';
|
|
4
5
|
import { CoreHealthCheckResolver } from './core-health-check.resolver';
|
|
5
6
|
import { CoreHealthCheckService } from './core-health-check.service';
|
|
@@ -9,8 +10,8 @@ import { CoreHealthCheckService } from './core-health-check.service';
|
|
|
9
10
|
* Inspired by https://mobileappcircular.com/marketplace-backend-creating-a-health-check-endpoint-in-nestjs-app-using-terminus-25727e96c7d2
|
|
10
11
|
*/
|
|
11
12
|
@Module({
|
|
12
|
-
imports: [TerminusModule],
|
|
13
13
|
controllers: [CoreHealthCheckController],
|
|
14
|
+
imports: [TerminusModule],
|
|
14
15
|
providers: [CoreHealthCheckService, CoreHealthCheckResolver],
|
|
15
16
|
})
|
|
16
17
|
export class CoreHealthCheckModule {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Query, Resolver } from '@nestjs/graphql';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Roles } from '../../common/decorators/roles.decorator';
|
|
4
|
-
import {
|
|
4
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
5
5
|
import { CoreHealthCheckService } from './core-health-check.service';
|
|
6
|
+
import { CoreHealthCheckResult } from './core-health-check-result.model';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@nestjs/terminus';
|
|
8
8
|
import { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health';
|
|
9
9
|
import { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type';
|
|
10
|
+
|
|
10
11
|
import { ConfigService } from '../../common/services/config.service';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -52,8 +53,8 @@ export class CoreHealthCheckService {
|
|
|
52
53
|
healthIndicatorFunctions.push(() => this.disk.checkStorage(
|
|
53
54
|
this.config.get<string>('healthCheck.configs.storage.key') ?? 'storage',
|
|
54
55
|
this.config.get<DiskHealthIndicatorOptions>('healthCheck.configs.storage.options') ?? {
|
|
55
|
-
thresholdPercent: 0.8,
|
|
56
56
|
path: '/',
|
|
57
|
+
thresholdPercent: 0.8,
|
|
57
58
|
},
|
|
58
59
|
));
|
|
59
60
|
}
|
|
@@ -2,6 +2,7 @@ import { Field, ObjectType } from '@nestjs/graphql';
|
|
|
2
2
|
import { Schema as MongooseSchema, Prop, raw } from '@nestjs/mongoose';
|
|
3
3
|
import { IsEmail, IsOptional } from 'class-validator';
|
|
4
4
|
import { Document } from 'mongoose';
|
|
5
|
+
|
|
5
6
|
import { CorePersistenceModel } from '../../common/models/core-persistence.model';
|
|
6
7
|
import { CoreTokenData } from '../auth/interfaces/core-token-data.interface';
|
|
7
8
|
|
|
@@ -22,7 +23,7 @@ export abstract class CoreUserModel extends CorePersistenceModel {
|
|
|
22
23
|
*/
|
|
23
24
|
@Field({ description: 'Email of the user', nullable: true })
|
|
24
25
|
@IsEmail()
|
|
25
|
-
@Prop({
|
|
26
|
+
@Prop({ lowercase: true, trim: true, unique: true })
|
|
26
27
|
email: string = undefined;
|
|
27
28
|
|
|
28
29
|
/**
|