@lenne.tech/nest-server 11.13.5 → 11.14.1
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 +1 -3
- package/dist/core/common/args/filter.args.js +3 -6
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.js +6 -9
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/translatable.decorator.js +1 -1
- package/dist/core/common/decorators/translatable.decorator.js.map +1 -1
- package/dist/core/common/enums/role.enum.js.map +1 -1
- package/dist/core/common/filters/http-exception-log.filter.js +3 -1
- package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
- package/dist/core/common/helpers/config.helper.js +2 -2
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.js +12 -12
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- 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.js +7 -4
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/scim.helper.js +2 -2
- package/dist/core/common/helpers/scim.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.js +1 -1
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +3 -6
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/core-input.input.js +1 -1
- package/dist/core/common/inputs/core-input.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js +3 -6
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +9 -12
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +2 -5
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/interceptors/check-response.interceptor.js +12 -11
- package/dist/core/common/interceptors/check-response.interceptor.js.map +1 -1
- package/dist/core/common/interceptors/check-security.interceptor.js +5 -4
- package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
- package/dist/core/common/models/core-model.model.d.ts +2 -2
- package/dist/core/common/models/core-model.model.js +2 -2
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.js +3 -6
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/common/models/pagination-info.model.js +6 -0
- package/dist/core/common/models/pagination-info.model.js.map +1 -1
- package/dist/core/common/pipes/check-input.pipe.js +1 -0
- package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
- package/dist/core/common/plugins/complexity.plugin.js +2 -0
- package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
- package/dist/core/common/scalars/any.scalar.js +2 -4
- package/dist/core/common/scalars/any.scalar.js.map +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js +1 -3
- package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
- package/dist/core/common/scalars/date.scalar.js +1 -3
- package/dist/core/common/scalars/date.scalar.js.map +1 -1
- package/dist/core/common/scalars/json.scalar.js +2 -4
- package/dist/core/common/scalars/json.scalar.js.map +1 -1
- package/dist/core/common/services/brevo.service.js +3 -0
- package/dist/core/common/services/brevo.service.js.map +1 -1
- package/dist/core/common/services/config.service.js +15 -8
- package/dist/core/common/services/config.service.js.map +1 -1
- package/dist/core/common/services/core-cron-jobs.service.js +10 -7
- package/dist/core/common/services/core-cron-jobs.service.js.map +1 -1
- package/dist/core/common/services/crud.service.js +1 -9
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/email.service.js +2 -0
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/mailjet.service.js +5 -4
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/core/common/services/model-doc.service.js +1 -0
- package/dist/core/common/services/model-doc.service.js.map +1 -1
- package/dist/core/common/services/module.service.js +6 -3
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/services/template.service.js +2 -1
- package/dist/core/common/services/template.service.js.map +1 -1
- package/dist/core/common/types/array-element.type.d.ts +1 -1
- package/dist/core/modules/auth/core-auth.controller.js +2 -0
- package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js +3 -6
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +2 -0
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +6 -4
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/legacy-auth-rate-limit.guard.js +1 -0
- package/dist/core/modules/auth/guards/legacy-auth-rate-limit.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/roles-guard-registry.js +3 -3
- package/dist/core/modules/auth/guards/roles-guard-registry.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js +15 -7
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js +4 -7
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth.service.js +6 -1
- package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
- package/dist/core/modules/auth/services/legacy-auth-rate-limiter.service.js +4 -4
- package/dist/core/modules/auth/services/legacy-auth-rate-limiter.service.js.map +1 -1
- package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js +2 -0
- package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js.map +1 -1
- package/dist/core/modules/auth/strategies/jwt.strategy.js +2 -0
- package/dist/core/modules/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/core/modules/auth/tokens.decorator.js +2 -2
- package/dist/core/modules/auth/tokens.decorator.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-roles.guard.js +2 -4
- package/dist/core/modules/better-auth/better-auth-roles.guard.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-token.service.js +3 -1
- package/dist/core/modules/better-auth/better-auth-token.service.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth.resolver.js +4 -0
- package/dist/core/modules/better-auth/better-auth.resolver.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth.types.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-api.middleware.js +6 -3
- package/dist/core/modules/better-auth/core-better-auth-api.middleware.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-auth.model.js +7 -0
- package/dist/core/modules/better-auth/core-better-auth-auth.model.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-challenge.service.js +6 -4
- package/dist/core/modules/better-auth/core-better-auth-challenge.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-cookie.helper.js +3 -0
- package/dist/core/modules/better-auth/core-better-auth-cookie.helper.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js +16 -8
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-migration-status.model.js +8 -0
- package/dist/core/modules/better-auth/core-better-auth-migration-status.model.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-models.js +31 -0
- package/dist/core/modules/better-auth/core-better-auth-models.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js +2 -0
- package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js +4 -4
- package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-signup-validator.service.js +3 -2
- package/dist/core/modules/better-auth/core-better-auth-signup-validator.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-user.mapper.js +2 -1
- package/dist/core/modules/better-auth/core-better-auth-user.mapper.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.controller.js +27 -1
- package/dist/core/modules/better-auth/core-better-auth.controller.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.middleware.js +3 -1
- package/dist/core/modules/better-auth/core-better-auth.middleware.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.module.js +23 -18
- package/dist/core/modules/better-auth/core-better-auth.module.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.resolver.js +5 -1
- package/dist/core/modules/better-auth/core-better-auth.resolver.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.service.js +6 -1
- package/dist/core/modules/better-auth/core-better-auth.service.js.map +1 -1
- package/dist/core/modules/error-code/core-error-code.controller.js +1 -0
- package/dist/core/modules/error-code/core-error-code.controller.js.map +1 -1
- package/dist/core/modules/error-code/core-error-code.service.js +3 -3
- package/dist/core/modules/error-code/core-error-code.service.js.map +1 -1
- package/dist/core/modules/error-code/error-codes.js.map +1 -1
- package/dist/core/modules/file/core-file-info.model.js +6 -9
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.js +1 -0
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.resolver.js +1 -0
- package/dist/core/modules/file/core-file.resolver.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +1 -1
- package/dist/core/modules/file/core-file.service.js +4 -4
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.js +4 -7
- 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 +1 -0
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.resolver.js +1 -0
- 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 +5 -0
- package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
- package/dist/core/modules/migrate/cli/migrate-cli.js.map +1 -1
- package/dist/core/modules/migrate/helpers/migration.helper.js +11 -19
- package/dist/core/modules/migrate/helpers/migration.helper.js.map +1 -1
- package/dist/core/modules/migrate/migration-runner.js +2 -0
- package/dist/core/modules/migrate/migration-runner.js.map +1 -1
- package/dist/core/modules/migrate/mongo-state-store.js +3 -0
- package/dist/core/modules/migrate/mongo-state-store.js.map +1 -1
- package/dist/core/modules/system-setup/core-system-setup.controller.js +4 -0
- package/dist/core/modules/system-setup/core-system-setup.controller.js.map +1 -1
- package/dist/core/modules/system-setup/core-system-setup.service.js +6 -5
- package/dist/core/modules/system-setup/core-system-setup.service.js.map +1 -1
- package/dist/core/modules/tus/core-tus.controller.js +2 -1
- package/dist/core/modules/tus/core-tus.controller.js.map +1 -1
- package/dist/core/modules/tus/core-tus.service.js +6 -3
- package/dist/core/modules/tus/core-tus.service.js.map +1 -1
- package/dist/core/modules/tus/tus.module.js +7 -5
- package/dist/core/modules/tus/tus.module.js.map +1 -1
- package/dist/core/modules/user/core-user.model.js +15 -18
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.d.ts +1 -1
- package/dist/core/modules/user/core-user.service.js +7 -2
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user-create.input.js +1 -4
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +6 -9
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/server/common/models/persistence.model.js +2 -5
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/common/services/cron-jobs.service.js +2 -0
- package/dist/server/common/services/cron-jobs.service.js.map +1 -1
- package/dist/server/modules/auth/auth.controller.js +2 -0
- package/dist/server/modules/auth/auth.controller.js.map +1 -1
- package/dist/server/modules/auth/auth.model.js +1 -4
- package/dist/server/modules/auth/auth.model.js.map +1 -1
- package/dist/server/modules/auth/auth.module.js +1 -6
- package/dist/server/modules/auth/auth.module.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.js +2 -0
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/auth/auth.service.js +4 -0
- package/dist/server/modules/auth/auth.service.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js +2 -5
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
- package/dist/server/modules/better-auth/better-auth.controller.js +3 -0
- package/dist/server/modules/better-auth/better-auth.controller.js.map +1 -1
- package/dist/server/modules/better-auth/better-auth.resolver.js +4 -0
- package/dist/server/modules/better-auth/better-auth.resolver.js.map +1 -1
- package/dist/server/modules/error-code/error-code.controller.js +1 -0
- package/dist/server/modules/error-code/error-code.controller.js.map +1 -1
- package/dist/server/modules/file/file-info.model.d.ts +2 -2
- package/dist/server/modules/file/file.controller.js +1 -0
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/file/file.resolver.js +2 -1
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/file/file.service.js +2 -3
- package/dist/server/modules/file/file.service.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +1 -0
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/inputs/user-create.input.js +1 -4
- package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
- package/dist/server/modules/user/inputs/user.input.js +1 -4
- 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 +3 -0
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/server/modules/user/user.controller.js +1 -0
- package/dist/server/modules/user/user.controller.js.map +1 -1
- package/dist/server/modules/user/user.model.js +7 -10
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/modules/user/user.resolver.js +3 -1
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.js +6 -0
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/server/server.controller.js +1 -0
- package/dist/server/server.controller.js.map +1 -1
- package/dist/test/test.helper.js +18 -10
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +26 -58
- package/src/core/common/args/filter.args.ts +1 -1
- package/src/core/common/args/pagination.args.ts +1 -1
- package/src/core/common/decorators/translatable.decorator.ts +1 -1
- package/src/core/common/enums/role.enum.ts +0 -1
- package/src/core/common/filters/http-exception-log.filter.ts +3 -3
- package/src/core/common/helpers/config.helper.ts +2 -2
- package/src/core/common/helpers/db.helper.ts +12 -12
- package/src/core/common/helpers/graphql.helper.ts +1 -1
- package/src/core/common/helpers/input.helper.ts +7 -4
- package/src/core/common/helpers/scim.helper.ts +16 -13
- package/src/core/common/helpers/service.helper.ts +1 -1
- package/src/core/common/inputs/combined-filter.input.ts +1 -1
- package/src/core/common/inputs/core-input.input.ts +1 -1
- package/src/core/common/inputs/filter.input.ts +13 -13
- package/src/core/common/inputs/single-filter.input.ts +2 -2
- package/src/core/common/interceptors/check-response.interceptor.ts +2 -2
- package/src/core/common/interfaces/cron-job-config-with-time-zone.interface.ts +4 -2
- package/src/core/common/interfaces/cron-job-config-with-utc-offset.interface.ts +4 -2
- package/src/core/common/interfaces/scim-array-filter-node.interface.ts +1 -1
- package/src/core/common/interfaces/scim-condition-node.interface.ts +1 -1
- package/src/core/common/interfaces/scim-logical-node.interface.ts +1 -1
- package/src/core/common/models/core-model.model.ts +2 -4
- package/src/core/common/scalars/any.scalar.ts +1 -1
- package/src/core/common/scalars/json.scalar.ts +3 -3
- package/src/core/common/services/config.service.ts +17 -11
- package/src/core/common/services/core-cron-jobs.service.ts +6 -6
- package/src/core/common/services/crud.service.ts +3 -12
- package/src/core/common/services/mailjet.service.ts +4 -5
- package/src/core/common/services/module.service.ts +3 -3
- package/src/core/common/types/array-element.type.ts +3 -2
- package/src/core/common/types/require-only-one.type.ts +2 -2
- package/src/core/common/types/required-at-least-one.type.ts +2 -2
- package/src/core/common/types/scim-comparator.type.ts +1 -1
- package/src/core/common/types/scim-logical-operator.type.ts +1 -1
- package/src/core/common/types/scim-node.type.ts +1 -1
- package/src/core/modules/auth/guards/auth.guard.ts +4 -2
- package/src/core/modules/auth/guards/roles.guard.ts +17 -3
- package/src/core/modules/auth/tokens.decorator.ts +3 -3
- package/src/core/modules/better-auth/ARCHITECTURE.md +23 -20
- package/src/core/modules/better-auth/CUSTOMIZATION.md +64 -56
- package/src/core/modules/better-auth/INTEGRATION-CHECKLIST.md +67 -40
- package/src/core/modules/better-auth/README.md +268 -230
- package/src/core/modules/better-auth/better-auth-roles.guard.ts +8 -1
- package/src/core/modules/better-auth/better-auth-token.service.ts +10 -3
- package/src/core/modules/better-auth/better-auth.resolver.ts +3 -1
- package/src/core/modules/better-auth/better-auth.types.ts +3 -1
- package/src/core/modules/better-auth/core-better-auth-api.middleware.ts +3 -1
- package/src/core/modules/better-auth/core-better-auth-challenge.service.ts +3 -1
- package/src/core/modules/better-auth/core-better-auth-email-verification.service.ts +35 -26
- package/src/core/modules/better-auth/core-better-auth-signup-validator.service.ts +3 -1
- package/src/core/modules/better-auth/core-better-auth.middleware.ts +6 -2
- package/src/core/modules/error-code/INTEGRATION-CHECKLIST.md +28 -21
- package/src/core/modules/error-code/error-codes.ts +0 -2
- package/src/core/modules/file/README.md +12 -10
- package/src/core/modules/file/core-file.service.ts +5 -9
- package/src/core/modules/migrate/MIGRATION_FROM_NODEPIT.md +21 -9
- package/src/core/modules/migrate/README.md +30 -28
- package/src/core/modules/migrate/cli/migrate-cli.ts +0 -3
- package/src/core/modules/migrate/helpers/migration.helper.ts +13 -21
- package/src/core/modules/migrate/migration-runner.ts +0 -3
- package/src/core/modules/system-setup/INTEGRATION-CHECKLIST.md +15 -14
- package/src/core/modules/system-setup/README.md +28 -20
- package/src/core/modules/system-setup/core-system-setup.service.ts +4 -5
- package/src/core/modules/tus/INTEGRATION-CHECKLIST.md +15 -14
- package/src/core/modules/tus/README.md +50 -44
- package/src/core/modules/user/core-user.service.ts +1 -2
- package/src/server/modules/auth/auth.module.ts +1 -9
- package/src/server/modules/better-auth/better-auth.resolver.ts +3 -1
- package/src/server/modules/error-code/README.md +19 -16
- package/src/server/modules/error-code/error-code.controller.ts +4 -1
- package/src/server/modules/file/file.resolver.ts +1 -1
- package/src/server/modules/file/file.service.ts +1 -3
- package/src/server/modules/user/user.resolver.ts +1 -1
- package/src/test/README.md +31 -27
- package/src/test/test.helper.ts +18 -10
|
@@ -25,11 +25,13 @@ npm uninstall @nodepit/migrate-state-store-mongodb
|
|
|
25
25
|
### 2. Update your imports
|
|
26
26
|
|
|
27
27
|
**Before:**
|
|
28
|
+
|
|
28
29
|
```typescript
|
|
29
30
|
import { MongoStateStore, synchronizedUp } from '@nodepit/migrate-state-store-mongodb';
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
**After:**
|
|
34
|
+
|
|
33
35
|
```typescript
|
|
34
36
|
import { MongoStateStore, synchronizedUp } from '@lenne.tech/nest-server';
|
|
35
37
|
```
|
|
@@ -58,7 +60,7 @@ const stateStore = new MongoStateStore('mongodb://localhost/mydb');
|
|
|
58
60
|
const stateStore = new MongoStateStore({
|
|
59
61
|
uri: 'mongodb://localhost/mydb',
|
|
60
62
|
collectionName: 'custom_migrations', // optional, defaults to 'migrations'
|
|
61
|
-
lockCollectionName: 'migration_lock' // optional, for cluster environments
|
|
63
|
+
lockCollectionName: 'migration_lock', // optional, for cluster environments
|
|
62
64
|
});
|
|
63
65
|
```
|
|
64
66
|
|
|
@@ -76,10 +78,8 @@ stateStore.load((err, state) => {
|
|
|
76
78
|
|
|
77
79
|
// Save migration state
|
|
78
80
|
const migrationState = {
|
|
79
|
-
migrations: [
|
|
80
|
-
|
|
81
|
-
],
|
|
82
|
-
lastRun: '1234-my-migration.js'
|
|
81
|
+
migrations: [{ title: '1234-my-migration.js', timestamp: Date.now() }],
|
|
82
|
+
lastRun: '1234-my-migration.js',
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
stateStore.save(migrationState, (err) => {
|
|
@@ -121,9 +121,9 @@ import { MongoStateStore, synchronizedMigration, synchronizedUp } from '@lenne.t
|
|
|
121
121
|
const migrationOptions = {
|
|
122
122
|
stateStore: new MongoStateStore({
|
|
123
123
|
uri: 'mongodb://localhost/mydb',
|
|
124
|
-
lockCollectionName: 'migration_lock' // Required for synchronized migrations
|
|
124
|
+
lockCollectionName: 'migration_lock', // Required for synchronized migrations
|
|
125
125
|
}),
|
|
126
|
-
migrationsDirectory: './migrations'
|
|
126
|
+
migrationsDirectory: './migrations',
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// Custom migration logic
|
|
@@ -148,6 +148,7 @@ new MongoStateStore(options: string | MongoStateStoreOptions)
|
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
**Parameters:**
|
|
151
|
+
|
|
151
152
|
- `options`: MongoDB URI string or configuration object
|
|
152
153
|
- `uri`: MongoDB connection URI (required)
|
|
153
154
|
- `collectionName`: Name of the collection to store migration state (default: 'migrations')
|
|
@@ -196,8 +197,8 @@ Wraps migrations with a lock to prevent simultaneous execution in clustered envi
|
|
|
196
197
|
```typescript
|
|
197
198
|
async function synchronizedMigration(
|
|
198
199
|
opts: MigrationOptions,
|
|
199
|
-
callback: (set: MigrationSet) => Promise<void
|
|
200
|
-
): Promise<void
|
|
200
|
+
callback: (set: MigrationSet) => Promise<void>,
|
|
201
|
+
): Promise<void>;
|
|
201
202
|
```
|
|
202
203
|
|
|
203
204
|
#### synchronizedUp
|
|
@@ -205,7 +206,7 @@ async function synchronizedMigration(
|
|
|
205
206
|
Convenience function that executes all pending migrations in a synchronized manner.
|
|
206
207
|
|
|
207
208
|
```typescript
|
|
208
|
-
async function synchronizedUp(opts: MigrationOptions): Promise<void
|
|
209
|
+
async function synchronizedUp(opts: MigrationOptions): Promise<void>;
|
|
209
210
|
```
|
|
210
211
|
|
|
211
212
|
## How It Works
|
|
@@ -260,10 +261,10 @@ module.exports.up = function (next) {
|
|
|
260
261
|
callbackify(async () => {
|
|
261
262
|
const client = await MongoClient.connect(mongoUrl);
|
|
262
263
|
try {
|
|
263
|
-
await client
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
await client
|
|
265
|
+
.db()
|
|
266
|
+
.collection('users')
|
|
267
|
+
.updateMany({ email: { $exists: false } }, { $set: { email: '' } });
|
|
267
268
|
} finally {
|
|
268
269
|
await client.close();
|
|
269
270
|
}
|
|
@@ -274,10 +275,10 @@ module.exports.down = function (next) {
|
|
|
274
275
|
callbackify(async () => {
|
|
275
276
|
const client = await MongoClient.connect(mongoUrl);
|
|
276
277
|
try {
|
|
277
|
-
await client
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
await client
|
|
279
|
+
.db()
|
|
280
|
+
.collection('users')
|
|
281
|
+
.updateMany({}, { $unset: { email: '' } });
|
|
281
282
|
} finally {
|
|
282
283
|
await client.close();
|
|
283
284
|
}
|
|
@@ -295,9 +296,9 @@ async function runMigrations() {
|
|
|
295
296
|
const migrationOptions = {
|
|
296
297
|
stateStore: new MongoStateStore({
|
|
297
298
|
uri: process.env.MONGODB_URL || 'mongodb://localhost/mydb',
|
|
298
|
-
lockCollectionName: 'migration_lock'
|
|
299
|
+
lockCollectionName: 'migration_lock',
|
|
299
300
|
}),
|
|
300
|
-
migrationsDirectory: path.join(__dirname, 'migrations')
|
|
301
|
+
migrationsDirectory: path.join(__dirname, 'migrations'),
|
|
301
302
|
};
|
|
302
303
|
|
|
303
304
|
try {
|
|
@@ -357,8 +358,8 @@ const config = require('../src/config.env');
|
|
|
357
358
|
|
|
358
359
|
module.exports = createMigrationStore(
|
|
359
360
|
config.default.mongoose.uri,
|
|
360
|
-
'migrations',
|
|
361
|
-
'migration_lock'
|
|
361
|
+
'migrations', // optional collection name
|
|
362
|
+
'migration_lock', // optional lock collection for clusters
|
|
362
363
|
);
|
|
363
364
|
```
|
|
364
365
|
|
|
@@ -380,11 +381,10 @@ Helper function to upload files to GridFS during migrations:
|
|
|
380
381
|
```typescript
|
|
381
382
|
import { uploadFileToGridFS } from '@lenne.tech/nest-server';
|
|
382
383
|
|
|
383
|
-
const fileId = await uploadFileToGridFS(
|
|
384
|
-
'
|
|
385
|
-
'
|
|
386
|
-
|
|
387
|
-
);
|
|
384
|
+
const fileId = await uploadFileToGridFS('mongodb://localhost/mydb', '../assets/image.png', {
|
|
385
|
+
bucketName: 'images',
|
|
386
|
+
filename: 'logo.png',
|
|
387
|
+
});
|
|
388
388
|
```
|
|
389
389
|
|
|
390
390
|
### Migration Templates
|
|
@@ -417,6 +417,7 @@ For a complete step-by-step guide on migrating from @nodepit/migrate-state-store
|
|
|
417
417
|
4. Run migrations using the built-in CLI
|
|
418
418
|
|
|
419
419
|
**Example package.json scripts:**
|
|
420
|
+
|
|
420
421
|
```json
|
|
421
422
|
{
|
|
422
423
|
"scripts": {
|
|
@@ -449,5 +450,6 @@ MIT
|
|
|
449
450
|
## Support
|
|
450
451
|
|
|
451
452
|
For issues and questions:
|
|
453
|
+
|
|
452
454
|
- GitHub: https://github.com/lenneTech/nest-server/issues
|
|
453
|
-
- Documentation: https://nest-server.lenne.tech
|
|
455
|
+
- Documentation: https://nest-server.lenne.tech
|
|
@@ -99,29 +99,21 @@ export const uploadFileToGridFS = async (
|
|
|
99
99
|
...options,
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const db = client.db();
|
|
107
|
-
const bucket = new GridFSBucket(db, { bucketName });
|
|
108
|
-
const writeStream = bucket.openUploadStream(filename);
|
|
109
|
-
|
|
110
|
-
const rs = fs.createReadStream(path.resolve(__dirname, relativePath)).pipe(writeStream);
|
|
111
|
-
|
|
112
|
-
rs.on('finish', () => {
|
|
113
|
-
resolve(writeStream.id as ObjectId);
|
|
114
|
-
});
|
|
102
|
+
const client = await MongoClient.connect(mongoUrl);
|
|
103
|
+
const db = client.db();
|
|
104
|
+
const bucket = new GridFSBucket(db, { bucketName });
|
|
105
|
+
const writeStream = bucket.openUploadStream(filename);
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
const rs = fs.createReadStream(path.resolve(__dirname, relativePath)).pipe(writeStream);
|
|
108
|
+
|
|
109
|
+
return new Promise<ObjectId>((resolve, reject) => {
|
|
110
|
+
rs.on('finish', () => {
|
|
111
|
+
resolve(writeStream.id as ObjectId);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
rs.on('error', (err) => {
|
|
120
115
|
reject(err);
|
|
121
|
-
}
|
|
122
|
-
// Note: Connection will be closed when stream finishes
|
|
123
|
-
// but we keep the client reference for proper error handling
|
|
124
|
-
}
|
|
116
|
+
});
|
|
125
117
|
});
|
|
126
118
|
};
|
|
127
119
|
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
## Do You Need This Checklist?
|
|
10
10
|
|
|
11
|
-
| Scenario
|
|
12
|
-
|
|
13
|
-
| Fresh deployment needs initial admin creation
|
|
14
|
-
| Automated deployment (Docker/CI) needs auto-creation | Set ENV variables (Step 1)
|
|
15
|
-
| Want to disable system setup
|
|
16
|
-
| Custom setup logic (extra fields, notifications)
|
|
11
|
+
| Scenario | Action Needed |
|
|
12
|
+
| ---------------------------------------------------- | ----------------------------------------------- |
|
|
13
|
+
| Fresh deployment needs initial admin creation | None - endpoints are available by default |
|
|
14
|
+
| Automated deployment (Docker/CI) needs auto-creation | Set ENV variables (Step 1) |
|
|
15
|
+
| Want to disable system setup | Set `systemSetup: { enabled: false }` in config |
|
|
16
|
+
| Custom setup logic (extra fields, notifications) | Step 2 (Custom Controller) |
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## Reference Implementation
|
|
21
21
|
|
|
22
22
|
**Local (in your node_modules):**
|
|
23
|
+
|
|
23
24
|
```
|
|
24
25
|
node_modules/@lenne.tech/nest-server/src/core/modules/system-setup/
|
|
25
26
|
```
|
|
@@ -91,17 +92,17 @@ export class SystemSetupController extends CoreSystemSetupController {
|
|
|
91
92
|
|
|
92
93
|
## Common Mistakes
|
|
93
94
|
|
|
94
|
-
| Mistake
|
|
95
|
-
|
|
96
|
-
| BetterAuth not enabled
|
|
97
|
-
| Calling init with existing users
|
|
98
|
-
| Password too short
|
|
99
|
-
| Missing ENV password
|
|
100
|
-
| `systemSetup: { enabled: false }` in config | 404 on endpoints
|
|
95
|
+
| Mistake | Symptom | Fix |
|
|
96
|
+
| ------------------------------------------- | -------------------------------- | ---------------------------------------- |
|
|
97
|
+
| BetterAuth not enabled | 404 on endpoints or 403 on init | Ensure `betterAuth` is configured |
|
|
98
|
+
| Calling init with existing users | 403 "System setup not available" | Init only works on empty database |
|
|
99
|
+
| Password too short | 400 validation error | Password must be at least 8 characters |
|
|
100
|
+
| Missing ENV password | Auto-creation silently skipped | Set both `email` and `password` ENV vars |
|
|
101
|
+
| `systemSetup: { enabled: false }` in config | 404 on endpoints | Remove the explicit disable |
|
|
101
102
|
|
|
102
103
|
---
|
|
103
104
|
|
|
104
105
|
## Detailed Documentation
|
|
105
106
|
|
|
106
107
|
- **README.md:** `node_modules/@lenne.tech/nest-server/src/core/modules/system-setup/README.md`
|
|
107
|
-
- **GitHub:** https://github.com/lenneTech/nest-server/blob/develop/src/core/modules/system-setup/README.md
|
|
108
|
+
- **GitHub:** https://github.com/lenneTech/nest-server/blob/develop/src/core/modules/system-setup/README.md
|
|
@@ -42,16 +42,17 @@ Once any user exists, the init endpoint is permanently locked (returns 403) and
|
|
|
42
42
|
|
|
43
43
|
## Endpoints
|
|
44
44
|
|
|
45
|
-
| Method | Endpoint
|
|
46
|
-
|
|
47
|
-
| GET
|
|
48
|
-
| POST
|
|
45
|
+
| Method | Endpoint | Description |
|
|
46
|
+
| ------ | -------------------------- | --------------------------- |
|
|
47
|
+
| GET | `/api/system-setup/status` | Check if system needs setup |
|
|
48
|
+
| POST | `/api/system-setup/init` | Create initial admin user |
|
|
49
49
|
|
|
50
50
|
### GET /api/system-setup/status
|
|
51
51
|
|
|
52
52
|
Returns the current setup status.
|
|
53
53
|
|
|
54
54
|
**Response:**
|
|
55
|
+
|
|
55
56
|
```json
|
|
56
57
|
{
|
|
57
58
|
"needsSetup": true,
|
|
@@ -64,6 +65,7 @@ Returns the current setup status.
|
|
|
64
65
|
Creates the initial admin user. Only works when zero users exist.
|
|
65
66
|
|
|
66
67
|
**Request Body:**
|
|
68
|
+
|
|
67
69
|
```json
|
|
68
70
|
{
|
|
69
71
|
"email": "admin@example.com",
|
|
@@ -72,13 +74,14 @@ Creates the initial admin user. Only works when zero users exist.
|
|
|
72
74
|
}
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
| Field
|
|
76
|
-
|
|
77
|
-
| `email`
|
|
78
|
-
| `password` | string | Yes
|
|
79
|
-
| `name`
|
|
77
|
+
| Field | Type | Required | Validation |
|
|
78
|
+
| ---------- | ------ | -------- | ------------------------ |
|
|
79
|
+
| `email` | string | Yes | Valid email format |
|
|
80
|
+
| `password` | string | Yes | Minimum 8 characters |
|
|
81
|
+
| `name` | string | No | Defaults to email prefix |
|
|
80
82
|
|
|
81
83
|
**Success Response (201):**
|
|
84
|
+
|
|
82
85
|
```json
|
|
83
86
|
{
|
|
84
87
|
"success": true,
|
|
@@ -88,6 +91,7 @@ Creates the initial admin user. Only works when zero users exist.
|
|
|
88
91
|
```
|
|
89
92
|
|
|
90
93
|
**Error Response (403):**
|
|
94
|
+
|
|
91
95
|
```json
|
|
92
96
|
{
|
|
93
97
|
"message": "LTNS_0050: System setup not available - users already exist"
|
|
@@ -100,11 +104,11 @@ Creates the initial admin user. Only works when zero users exist.
|
|
|
100
104
|
|
|
101
105
|
System setup is **enabled by default** when BetterAuth is active:
|
|
102
106
|
|
|
103
|
-
| Config
|
|
104
|
-
|
|
105
|
-
|
|
|
106
|
-
| `systemSetup: { enabled: false }`
|
|
107
|
-
| `systemSetup: { initialAdmin: { ... } }` | Enabled with auto-creation
|
|
107
|
+
| Config | Effect |
|
|
108
|
+
| ---------------------------------------- | ----------------------------------- |
|
|
109
|
+
| _(not set)_ | Enabled (when BetterAuth is active) |
|
|
110
|
+
| `systemSetup: { enabled: false }` | Disabled explicitly |
|
|
111
|
+
| `systemSetup: { initialAdmin: { ... } }` | Enabled with auto-creation |
|
|
108
112
|
|
|
109
113
|
```typescript
|
|
110
114
|
// config.env.ts
|
|
@@ -220,6 +224,7 @@ if (needsSetup) {
|
|
|
220
224
|
**Cause:** Users already exist in the database.
|
|
221
225
|
|
|
222
226
|
**Solutions:**
|
|
227
|
+
|
|
223
228
|
1. Check `GET /api/system-setup/status` - `needsSetup` should be `true`
|
|
224
229
|
2. If this is a fresh deployment, verify the database is empty
|
|
225
230
|
|
|
@@ -228,6 +233,7 @@ if (needsSetup) {
|
|
|
228
233
|
**Cause:** BetterAuth is not configured or not enabled.
|
|
229
234
|
|
|
230
235
|
**Solutions:**
|
|
236
|
+
|
|
231
237
|
1. Ensure `betterAuth` is configured in `config.env.ts`
|
|
232
238
|
2. Verify BetterAuth is running (check server startup logs)
|
|
233
239
|
|
|
@@ -236,6 +242,7 @@ if (needsSetup) {
|
|
|
236
242
|
**Cause:** Missing or incomplete ENV variables.
|
|
237
243
|
|
|
238
244
|
**Solutions:**
|
|
245
|
+
|
|
239
246
|
1. Verify both `email` and `password` are set
|
|
240
247
|
2. Check server logs for `Auto-created initial admin on startup` or warning messages
|
|
241
248
|
3. Ensure BetterAuth is fully initialized (check startup logs)
|
|
@@ -245,6 +252,7 @@ if (needsSetup) {
|
|
|
245
252
|
**Cause:** System setup module is disabled.
|
|
246
253
|
|
|
247
254
|
**Solutions:**
|
|
255
|
+
|
|
248
256
|
1. Check that BetterAuth is enabled (system setup requires it)
|
|
249
257
|
2. Ensure `systemSetup` is not set to `{ enabled: false }`
|
|
250
258
|
|
|
@@ -252,11 +260,11 @@ if (needsSetup) {
|
|
|
252
260
|
|
|
253
261
|
## Error Codes
|
|
254
262
|
|
|
255
|
-
| Code
|
|
256
|
-
|
|
257
|
-
| LTNS_0050 | `SYSTEM_SETUP_NOT_AVAILABLE`
|
|
258
|
-
| LTNS_0051 | `SYSTEM_SETUP_DISABLED`
|
|
259
|
-
| LTNS_0052 | `SYSTEM_SETUP_BETTERAUTH_REQUIRED` | BetterAuth must be enabled
|
|
263
|
+
| Code | Key | Description |
|
|
264
|
+
| --------- | ---------------------------------- | ---------------------------------- |
|
|
265
|
+
| LTNS_0050 | `SYSTEM_SETUP_NOT_AVAILABLE` | Users already exist, setup locked |
|
|
266
|
+
| LTNS_0051 | `SYSTEM_SETUP_DISABLED` | System setup is disabled in config |
|
|
267
|
+
| LTNS_0052 | `SYSTEM_SETUP_BETTERAUTH_REQUIRED` | BetterAuth must be enabled |
|
|
260
268
|
|
|
261
269
|
---
|
|
262
270
|
|
|
@@ -264,4 +272,4 @@ if (needsSetup) {
|
|
|
264
272
|
|
|
265
273
|
- [Integration Checklist](./INTEGRATION-CHECKLIST.md)
|
|
266
274
|
- [BetterAuth Module](../better-auth/README.md)
|
|
267
|
-
- [Configurable Features Pattern](../../../.claude/rules/configurable-features.md)
|
|
275
|
+
- [Configurable Features Pattern](../../../.claude/rules/configurable-features.md)
|
|
@@ -74,10 +74,7 @@ export class CoreSystemSetupService implements OnApplicationBootstrap {
|
|
|
74
74
|
|
|
75
75
|
// Partial credentials → warn and skip
|
|
76
76
|
if (!initialAdmin.email || !initialAdmin.password) {
|
|
77
|
-
const missing = [
|
|
78
|
-
!initialAdmin.email && 'email',
|
|
79
|
-
!initialAdmin.password && 'password',
|
|
80
|
-
].filter(Boolean).join(', ');
|
|
77
|
+
const missing = [!initialAdmin.email && 'email', !initialAdmin.password && 'password'].filter(Boolean).join(', ');
|
|
81
78
|
this.logger.warn(`Incomplete initialAdmin config - missing: ${missing}. Auto-creation skipped.`);
|
|
82
79
|
return;
|
|
83
80
|
}
|
|
@@ -115,7 +112,9 @@ export class CoreSystemSetupService implements OnApplicationBootstrap {
|
|
|
115
112
|
if (error instanceof ForbiddenException) {
|
|
116
113
|
this.logger.log('Initial admin auto-creation skipped (users already exist)');
|
|
117
114
|
} else {
|
|
118
|
-
this.logger.warn(
|
|
115
|
+
this.logger.warn(
|
|
116
|
+
`Initial admin auto-creation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
117
|
+
);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
}
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
## Do You Need This Checklist?
|
|
10
10
|
|
|
11
|
-
| Scenario
|
|
12
|
-
|
|
13
|
-
| Use TUS with defaults (everyone can upload)
|
|
14
|
-
| Require authentication for uploads
|
|
15
|
-
| Custom upload handling (notifications, etc.) | Yes - Step 2
|
|
16
|
-
| Disable TUS completely
|
|
11
|
+
| Scenario | Checklist Needed? |
|
|
12
|
+
| -------------------------------------------- | ---------------------------------------------------- |
|
|
13
|
+
| Use TUS with defaults (everyone can upload) | No - works automatically |
|
|
14
|
+
| Require authentication for uploads | Yes - Step 1 |
|
|
15
|
+
| Custom upload handling (notifications, etc.) | Yes - Step 2 |
|
|
16
|
+
| Disable TUS completely | No - just use `TusModule.forRoot({ config: false })` |
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## Reference Implementation
|
|
21
21
|
|
|
22
22
|
**Local (in your node_modules):**
|
|
23
|
+
|
|
23
24
|
```
|
|
24
25
|
node_modules/@lenne.tech/nest-server/src/server/server.module.ts
|
|
25
26
|
```
|
|
@@ -116,13 +117,13 @@ TusModule.forRoot({
|
|
|
116
117
|
path: '/uploads',
|
|
117
118
|
expiration: { expiresIn: '12h' },
|
|
118
119
|
},
|
|
119
|
-
})
|
|
120
|
+
});
|
|
120
121
|
```
|
|
121
122
|
|
|
122
123
|
### Disable TUS
|
|
123
124
|
|
|
124
125
|
```typescript
|
|
125
|
-
TusModule.forRoot({ config: false })
|
|
126
|
+
TusModule.forRoot({ config: false });
|
|
126
127
|
```
|
|
127
128
|
|
|
128
129
|
---
|
|
@@ -140,11 +141,11 @@ TusModule.forRoot({ config: false })
|
|
|
140
141
|
|
|
141
142
|
## Common Mistakes
|
|
142
143
|
|
|
143
|
-
| Mistake
|
|
144
|
-
|
|
145
|
-
| Forgot to register custom controller | Default S_EVERYONE permissions | Add `controller: TusController` to forRoot()
|
|
146
|
-
| Custom controller missing @Roles
|
|
147
|
-
| Using wrong endpoint path
|
|
144
|
+
| Mistake | Symptom | Fix |
|
|
145
|
+
| ------------------------------------ | ------------------------------ | ------------------------------------------------- |
|
|
146
|
+
| Forgot to register custom controller | Default S_EVERYONE permissions | Add `controller: TusController` to forRoot() |
|
|
147
|
+
| Custom controller missing @Roles | No authentication required | Add `@Roles(RoleEnum.S_USER)` to controller class |
|
|
148
|
+
| Using wrong endpoint path | 404 on upload | Ensure client uses same path as config |
|
|
148
149
|
|
|
149
150
|
---
|
|
150
151
|
|
|
@@ -173,4 +174,4 @@ upload.start();
|
|
|
173
174
|
## Detailed Documentation
|
|
174
175
|
|
|
175
176
|
- **README.md:** `node_modules/@lenne.tech/nest-server/src/core/modules/tus/README.md`
|
|
176
|
-
- **GitHub:** https://github.com/lenneTech/nest-server/blob/develop/src/core/modules/tus/README.md
|
|
177
|
+
- **GitHub:** https://github.com/lenneTech/nest-server/blob/develop/src/core/modules/tus/README.md
|