@aurostack/stacks 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/LICENSE +21 -0
- package/README.md +209 -0
- package/cli/src/extract.mjs +165 -0
- package/cli/src/fsx.mjs +197 -0
- package/cli/src/generate.mjs +235 -0
- package/cli/src/hooks.mjs +55 -0
- package/cli/src/manifest.mjs +163 -0
- package/cli/src/strip.mjs +208 -0
- package/cli/src/tokens.mjs +102 -0
- package/cli/stack.mjs +672 -0
- package/package.json +37 -0
- package/templates/nest-api/files/.bin/db.ts +123 -0
- package/templates/nest-api/files/.bin/dc.ts +74 -0
- package/templates/nest-api/files/.bin/helpers.ts +49 -0
- package/templates/nest-api/files/.bin/secrets.ts +68 -0
- package/templates/nest-api/files/.bin/start.ts +47 -0
- package/templates/nest-api/files/.dockerignore +7 -0
- package/templates/nest-api/files/.env.example +91 -0
- package/templates/nest-api/files/.env.test.example +75 -0
- package/templates/nest-api/files/.forgejo/workflows/build-and-push.yml +41 -0
- package/templates/nest-api/files/.forgejo/workflows/test-e2e.yml +83 -0
- package/templates/nest-api/files/.forgejo/workflows/test.yml +53 -0
- package/templates/nest-api/files/.npmrc.example +1 -0
- package/templates/nest-api/files/.nvmrc +1 -0
- package/templates/nest-api/files/.prettierrc +8 -0
- package/templates/nest-api/files/.swcrc +15 -0
- package/templates/nest-api/files/.watchmanconfig +3 -0
- package/templates/nest-api/files/.yarnrc.yml +1 -0
- package/templates/nest-api/files/Dockerfile +40 -0
- package/templates/nest-api/files/__mocks__/activation-twofa.js +7 -0
- package/templates/nest-api/files/__mocks__/activation.js +7 -0
- package/templates/nest-api/files/__mocks__/forgot-password.js +7 -0
- package/templates/nest-api/files/__mocks__/main-layout.js +7 -0
- package/templates/nest-api/files/__mocks__/password-changed.js +7 -0
- package/templates/nest-api/files/__mocks__/reset-password.js +7 -0
- package/templates/nest-api/files/__mocks__/set-password.js +7 -0
- package/templates/nest-api/files/__mocks__/welcome.js +7 -0
- package/templates/nest-api/files/_gitignore +62 -0
- package/templates/nest-api/files/compose.test.yml +33 -0
- package/templates/nest-api/files/compose.yml +39 -0
- package/templates/nest-api/files/emails/activation-twofa.tsx +58 -0
- package/templates/nest-api/files/emails/activation.tsx +36 -0
- package/templates/nest-api/files/emails/forgot-password.tsx +29 -0
- package/templates/nest-api/files/emails/main-layout.tsx +134 -0
- package/templates/nest-api/files/emails/password-changed.tsx +24 -0
- package/templates/nest-api/files/emails/reset-password.tsx +24 -0
- package/templates/nest-api/files/emails/set-password.tsx +25 -0
- package/templates/nest-api/files/emails/welcome.tsx +39 -0
- package/templates/nest-api/files/eslint.config.mjs +28 -0
- package/templates/nest-api/files/global.d.ts +5 -0
- package/templates/nest-api/files/nest-cli.json +8 -0
- package/templates/nest-api/files/package.json +150 -0
- package/templates/nest-api/files/prisma/schema/auth.prisma +75 -0
- package/templates/nest-api/files/prisma/schema/base.prisma +17 -0
- package/templates/nest-api/files/prisma/schema/enum.prisma +17 -0
- package/templates/nest-api/files/prisma/schema/notification.prisma +14 -0
- package/templates/nest-api/files/prisma.config.ts +13 -0
- package/templates/nest-api/files/public/.gitkeep +0 -0
- package/templates/nest-api/files/seeders/index.ts +27 -0
- package/templates/nest-api/files/seeders/util.ts +88 -0
- package/templates/nest-api/files/src/__tests__/app.controller.spec.ts +29 -0
- package/templates/nest-api/files/src/app.controller.ts +40 -0
- package/templates/nest-api/files/src/app.module.ts +268 -0
- package/templates/nest-api/files/src/app.resolver.ts +32 -0
- package/templates/nest-api/files/src/app.setup.ts +178 -0
- package/templates/nest-api/files/src/common/__tests__/auth.service.spec.ts +31 -0
- package/templates/nest-api/files/src/common/__tests__/cache.service.spec.ts +214 -0
- package/templates/nest-api/files/src/common/__tests__/config.service.spec.ts +56 -0
- package/templates/nest-api/files/src/common/__tests__/generator.service.spec.ts +114 -0
- package/templates/nest-api/files/src/common/__tests__/health.controller.spec.ts +72 -0
- package/templates/nest-api/files/src/common/__tests__/helpers.spec.ts +124 -0
- package/templates/nest-api/files/src/common/__tests__/mail.service.spec.ts +75 -0
- package/templates/nest-api/files/src/common/__tests__/prisma.indicator.spec.ts +39 -0
- package/templates/nest-api/files/src/common/__tests__/prisma.service.spec.ts +15 -0
- package/templates/nest-api/files/src/common/__tests__/records.spec.ts +87 -0
- package/templates/nest-api/files/src/common/__tests__/schemas.spec.ts +142 -0
- package/templates/nest-api/files/src/common/__tests__/throttler-storage.service.spec.ts +80 -0
- package/templates/nest-api/files/src/common/common.module.ts +72 -0
- package/templates/nest-api/files/src/common/constants/index.ts +2 -0
- package/templates/nest-api/files/src/common/constants/options.ts +52 -0
- package/templates/nest-api/files/src/common/constants/pino.ts +24 -0
- package/templates/nest-api/files/src/common/controllers/health.controller.ts +54 -0
- package/templates/nest-api/files/src/common/controllers/index.ts +2 -0
- package/templates/nest-api/files/src/common/controllers/metrics.controller.ts +21 -0
- package/templates/nest-api/files/src/common/decorators/index.ts +2 -0
- package/templates/nest-api/files/src/common/decorators/misc.decorator.ts +49 -0
- package/templates/nest-api/files/src/common/decorators/multi-part.decorator.ts +6 -0
- package/templates/nest-api/files/src/common/dto/filters.dto.ts +25 -0
- package/templates/nest-api/files/src/common/dto/index.ts +1 -0
- package/templates/nest-api/files/src/common/entity/index.ts +2 -0
- package/templates/nest-api/files/src/common/entity/ok.entity.ts +11 -0
- package/templates/nest-api/files/src/common/entity/pagination.entity.ts +24 -0
- package/templates/nest-api/files/src/common/exceptions/index.ts +1 -0
- package/templates/nest-api/files/src/common/exceptions/prisma.exception.ts +57 -0
- package/templates/nest-api/files/src/common/guards/feature-flag.guard.ts +51 -0
- package/templates/nest-api/files/src/common/guards/index.ts +1 -0
- package/templates/nest-api/files/src/common/interceptors/index.ts +1 -0
- package/templates/nest-api/files/src/common/interceptors/metrics.interceptor.ts +37 -0
- package/templates/nest-api/files/src/common/misc/helpers.ts +26 -0
- package/templates/nest-api/files/src/common/misc/index.ts +3 -0
- package/templates/nest-api/files/src/common/misc/origin-builder.ts +56 -0
- package/templates/nest-api/files/src/common/misc/prisma.indicator.ts +24 -0
- package/templates/nest-api/files/src/common/modules/index.ts +3 -0
- package/templates/nest-api/files/src/common/modules/logger.module.ts +104 -0
- package/templates/nest-api/files/src/common/modules/metrics.module.ts +28 -0
- package/templates/nest-api/files/src/common/modules/queue.module.ts +23 -0
- package/templates/nest-api/files/src/common/processors/index.ts +1 -0
- package/templates/nest-api/files/src/common/processors/mail/index.ts +47 -0
- package/templates/nest-api/files/src/common/processors/mail/process.ts +225 -0
- package/templates/nest-api/files/src/common/schemas/fields.ts +76 -0
- package/templates/nest-api/files/src/common/schemas/index.ts +1 -0
- package/templates/nest-api/files/src/common/services/auth-rate-limit.storage.ts +79 -0
- package/templates/nest-api/files/src/common/services/auth.service.ts +16 -0
- package/templates/nest-api/files/src/common/services/cache.service.ts +118 -0
- package/templates/nest-api/files/src/common/services/config.service.ts +388 -0
- package/templates/nest-api/files/src/common/services/feature-flag.service.ts +117 -0
- package/templates/nest-api/files/src/common/services/generator.service.ts +54 -0
- package/templates/nest-api/files/src/common/services/index.ts +10 -0
- package/templates/nest-api/files/src/common/services/logger.service.ts +14 -0
- package/templates/nest-api/files/src/common/services/mail.service.ts +44 -0
- package/templates/nest-api/files/src/common/services/prisma.service.ts +106 -0
- package/templates/nest-api/files/src/common/services/throttler-storage.service.ts +112 -0
- package/templates/nest-api/files/src/common/types/email.ts +55 -0
- package/templates/nest-api/files/src/common/types/index.ts +3 -0
- package/templates/nest-api/files/src/common/types/misc.ts +20 -0
- package/templates/nest-api/files/src/common/types/prisma.ts +18 -0
- package/templates/nest-api/files/src/common/utils/enum.ts +39 -0
- package/templates/nest-api/files/src/common/utils/helpers.ts +139 -0
- package/templates/nest-api/files/src/common/utils/index.ts +5 -0
- package/templates/nest-api/files/src/common/utils/ip.ts +22 -0
- package/templates/nest-api/files/src/common/utils/records.ts +66 -0
- package/templates/nest-api/files/src/common/utils/redis.keys.ts +31 -0
- package/templates/nest-api/files/src/lib/__tests__/access.spec.ts +33 -0
- package/templates/nest-api/files/src/lib/access.ts +114 -0
- package/templates/nest-api/files/src/lib/auth.ts +76 -0
- package/templates/nest-api/files/src/lib/rate-limit.ts +20 -0
- package/templates/nest-api/files/src/main.ts +28 -0
- package/templates/nest-api/files/src/media/__tests__/media.service.spec.ts +60 -0
- package/templates/nest-api/files/src/media/__tests__/s3.service.spec.ts +159 -0
- package/templates/nest-api/files/src/media/entity/file.entity.ts +7 -0
- package/templates/nest-api/files/src/media/entity/index.ts +1 -0
- package/templates/nest-api/files/src/media/media.module.ts +20 -0
- package/templates/nest-api/files/src/media/processors/index.ts +44 -0
- package/templates/nest-api/files/src/media/services/index.ts +2 -0
- package/templates/nest-api/files/src/media/services/media.service.ts +29 -0
- package/templates/nest-api/files/src/media/services/s3.service.ts +168 -0
- package/templates/nest-api/files/src/notifications/controllers/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/controllers/notifications.controller.ts +72 -0
- package/templates/nest-api/files/src/notifications/dto/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/dto/notification.dto.ts +11 -0
- package/templates/nest-api/files/src/notifications/entity/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/entity/notification.entity.ts +37 -0
- package/templates/nest-api/files/src/notifications/notifications.module.ts +11 -0
- package/templates/nest-api/files/src/notifications/services/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/services/notifications.service.ts +98 -0
- package/templates/nest-api/files/src/realtime/__tests__/events.gateway.spec.ts +88 -0
- package/templates/nest-api/files/src/realtime/__tests__/rooms.spec.ts +29 -0
- package/templates/nest-api/files/src/realtime/__tests__/ws-permissions.guard.spec.ts +54 -0
- package/templates/nest-api/files/src/realtime/adapters/redis-io.adapter.ts +57 -0
- package/templates/nest-api/files/src/realtime/constants/index.ts +68 -0
- package/templates/nest-api/files/src/realtime/decorators/index.ts +1 -0
- package/templates/nest-api/files/src/realtime/decorators/ws-permissions.decorator.ts +14 -0
- package/templates/nest-api/files/src/realtime/gateways/events.gateway.ts +187 -0
- package/templates/nest-api/files/src/realtime/guards/index.ts +2 -0
- package/templates/nest-api/files/src/realtime/guards/ws-auth.guard.ts +20 -0
- package/templates/nest-api/files/src/realtime/guards/ws-permissions.guard.ts +35 -0
- package/templates/nest-api/files/src/realtime/misc/session-from-socket.ts +54 -0
- package/templates/nest-api/files/src/realtime/realtime.module.ts +26 -0
- package/templates/nest-api/files/src/realtime/services/presence.service.ts +56 -0
- package/templates/nest-api/files/src/realtime/services/realtime.service.ts +72 -0
- package/templates/nest-api/files/src/users/__tests__/current-user.controller.spec.ts +77 -0
- package/templates/nest-api/files/src/users/__tests__/current-user.service.spec.ts +159 -0
- package/templates/nest-api/files/src/users/__tests__/user.entity.spec.ts +175 -0
- package/templates/nest-api/files/src/users/__tests__/users.controller.spec.ts +89 -0
- package/templates/nest-api/files/src/users/__tests__/users.service.spec.ts +398 -0
- package/templates/nest-api/files/src/users/controllers/current-user.controller.ts +82 -0
- package/templates/nest-api/files/src/users/controllers/index.ts +2 -0
- package/templates/nest-api/files/src/users/controllers/users.controller.ts +40 -0
- package/templates/nest-api/files/src/users/decorators/index.ts +1 -0
- package/templates/nest-api/files/src/users/decorators/permissions.decorator.ts +24 -0
- package/templates/nest-api/files/src/users/dto/avatar.dto.ts +13 -0
- package/templates/nest-api/files/src/users/dto/filters.dto.ts +8 -0
- package/templates/nest-api/files/src/users/dto/index.ts +2 -0
- package/templates/nest-api/files/src/users/entity/index.ts +1 -0
- package/templates/nest-api/files/src/users/entity/user.entity.ts +53 -0
- package/templates/nest-api/files/src/users/services/current-user.service.ts +46 -0
- package/templates/nest-api/files/src/users/services/index.ts +2 -0
- package/templates/nest-api/files/src/users/services/users.service.ts +88 -0
- package/templates/nest-api/files/src/users/users.module.ts +10 -0
- package/templates/nest-api/files/test/app.spec.ts +102 -0
- package/templates/nest-api/files/test/auth.spec.ts +108 -0
- package/templates/nest-api/files/test/current-user.spec.ts +154 -0
- package/templates/nest-api/files/test/factory/app.ts +172 -0
- package/templates/nest-api/files/test/factory/constants.ts +22 -0
- package/templates/nest-api/files/test/factory/dto.ts +27 -0
- package/templates/nest-api/files/test/factory/entity.ts +70 -0
- package/templates/nest-api/files/test/factory/gen.ts +75 -0
- package/templates/nest-api/files/test/factory/util.ts +21 -0
- package/templates/nest-api/files/test/notifications.spec.ts +176 -0
- package/templates/nest-api/files/test/rate-limit.spec.ts +180 -0
- package/templates/nest-api/files/test/setup.ts +1 -0
- package/templates/nest-api/files/test/users.spec.ts +437 -0
- package/templates/nest-api/files/tsconfig.build.json +13 -0
- package/templates/nest-api/files/tsconfig.json +35 -0
- package/templates/nest-api/files/vitest.config.ts +53 -0
- package/templates/nest-api/template.json +452 -0
- package/templates/node-worker/files/.bin/db.ts +123 -0
- package/templates/node-worker/files/.bin/helpers.ts +49 -0
- package/templates/node-worker/files/.bin/secrets.ts +68 -0
- package/templates/node-worker/files/.dockerignore +5 -0
- package/templates/node-worker/files/.env.example +21 -0
- package/templates/node-worker/files/.forgejo/workflows/build-and-push.yml +41 -0
- package/templates/node-worker/files/.nvmrc +1 -0
- package/templates/node-worker/files/.prettierignore +4 -0
- package/templates/node-worker/files/.prettierrc +8 -0
- package/templates/node-worker/files/.yarnrc.yml +5 -0
- package/templates/node-worker/files/Dockerfile +63 -0
- package/templates/node-worker/files/Dockerfile.dev +59 -0
- package/templates/node-worker/files/_gitignore +48 -0
- package/templates/node-worker/files/ecosystem.config.cjs +10 -0
- package/templates/node-worker/files/eslint.config.js +37 -0
- package/templates/node-worker/files/package.json +67 -0
- package/templates/node-worker/files/prisma/_gitignore +1 -0
- package/templates/node-worker/files/prisma/schema/base.prisma +36 -0
- package/templates/node-worker/files/prisma.config.ts +13 -0
- package/templates/node-worker/files/src/config.ts +55 -0
- package/templates/node-worker/files/src/db.ts +118 -0
- package/templates/node-worker/files/src/index.ts +7 -0
- package/templates/node-worker/files/src/logger.ts +45 -0
- package/templates/node-worker/files/src/types.ts +23 -0
- package/templates/node-worker/files/src/utils/browser.ts +16 -0
- package/templates/node-worker/files/src/utils/date.ts +68 -0
- package/templates/node-worker/files/src/utils/helpers.ts +17 -0
- package/templates/node-worker/files/src/utils/number.ts +47 -0
- package/templates/node-worker/files/src/utils/worker.ts +29 -0
- package/templates/node-worker/files/src/workers/constants.ts +6 -0
- package/templates/node-worker/files/src/workers/example/index.ts +27 -0
- package/templates/node-worker/files/src/workers/index.ts +1 -0
- package/templates/node-worker/files/tsconfig.json +30 -0
- package/templates/node-worker/template.json +135 -0
- package/templates/py-worker/files/.dockerignore +176 -0
- package/templates/py-worker/files/.env.example +20 -0
- package/templates/py-worker/files/.forgejo/workflows/build-amd-push.yml +39 -0
- package/templates/py-worker/files/Dockerfile +10 -0
- package/templates/py-worker/files/README.md +3 -0
- package/templates/py-worker/files/_gitignore +176 -0
- package/templates/py-worker/files/config.py +89 -0
- package/templates/py-worker/files/models/decorators.py +42 -0
- package/templates/py-worker/files/models/enums.py +32 -0
- package/templates/py-worker/files/models/mixins.py +61 -0
- package/templates/py-worker/files/requirements.txt +18 -0
- package/templates/py-worker/files/utils/db.py +67 -0
- package/templates/py-worker/files/utils/logger.py +97 -0
- package/templates/py-worker/files/utils/misc.py +45 -0
- package/templates/py-worker/files/utils/worker.py +80 -0
- package/templates/py-worker/files/worker.py +41 -0
- package/templates/py-worker/files/workers/hello/process.py +22 -0
- package/templates/py-worker/template.json +87 -0
- package/templates/react-app/README.md +78 -0
- package/templates/react-app/derive.sh +128 -0
- package/templates/react-app/files/.bin/openapi.js +32 -0
- package/templates/react-app/files/.bin/secrets.js +47 -0
- package/templates/react-app/files/.dockerignore +16 -0
- package/templates/react-app/files/.editorconfig +12 -0
- package/templates/react-app/files/.env.example +34 -0
- package/templates/react-app/files/.forgejo/workflows/build-and-push.yml +55 -0
- package/templates/react-app/files/.forgejo/workflows/ci.yml +39 -0
- package/templates/react-app/files/.husky/pre-commit +1 -0
- package/templates/react-app/files/.nvmrc +1 -0
- package/templates/react-app/files/.prettierignore +6 -0
- package/templates/react-app/files/.prettierrc +9 -0
- package/templates/react-app/files/.yarnrc.yml +2 -0
- package/templates/react-app/files/Dockerfile +52 -0
- package/templates/react-app/files/_gitignore +33 -0
- package/templates/react-app/files/build.sh +53 -0
- package/templates/react-app/files/docker/nginx.conf +134 -0
- package/templates/react-app/files/eslint.config.mjs +75 -0
- package/templates/react-app/files/index.html +62 -0
- package/templates/react-app/files/openapi-ts.config.ts +22 -0
- package/templates/react-app/files/package.json +80 -0
- package/templates/react-app/files/src/app/nav.tsx +32 -0
- package/templates/react-app/files/src/app/providers.tsx +39 -0
- package/templates/react-app/files/src/app/router.tsx +142 -0
- package/templates/react-app/files/src/app/store.ts +20 -0
- package/templates/react-app/files/src/features/auth/components/auth-card.tsx +23 -0
- package/templates/react-app/files/src/features/auth/components/checkbox-field.tsx +32 -0
- package/templates/react-app/files/src/features/auth/components/google-button.tsx +41 -0
- package/templates/react-app/files/src/features/auth/components/or-divider.tsx +9 -0
- package/templates/react-app/files/src/features/auth/components/password-field.tsx +70 -0
- package/templates/react-app/files/src/features/auth/components/submit-button.tsx +16 -0
- package/templates/react-app/files/src/features/auth/lib/auth-actions.ts +68 -0
- package/templates/react-app/files/src/features/auth/lib/password-strength.ts +20 -0
- package/templates/react-app/files/src/features/auth/lib/redirect.ts +6 -0
- package/templates/react-app/files/src/features/auth/lib/schemas.ts +37 -0
- package/templates/react-app/files/src/features/seo/routes.ts +65 -0
- package/templates/react-app/files/src/lib/env.ts +28 -0
- package/templates/react-app/files/src/lib/paths.ts +58 -0
- package/templates/react-app/files/src/main.tsx +19 -0
- package/templates/react-app/files/src/routes/admin/home.tsx +24 -0
- package/templates/react-app/files/src/routes/auth/forgot-password.tsx +93 -0
- package/templates/react-app/files/src/routes/auth/login.tsx +87 -0
- package/templates/react-app/files/src/routes/auth/reset-password.tsx +83 -0
- package/templates/react-app/files/src/routes/auth/signup.tsx +117 -0
- package/templates/react-app/files/src/routes/auth/verified.tsx +31 -0
- package/templates/react-app/files/src/routes/auth/verify-email.tsx +97 -0
- package/templates/react-app/files/src/routes/home.tsx +17 -0
- package/templates/react-app/files/src/routes/legal/privacy.tsx +26 -0
- package/templates/react-app/files/src/routes/legal/terms.tsx +28 -0
- package/templates/react-app/files/src/routes/marketing/home.tsx +18 -0
- package/templates/react-app/files/src/routes/settings.tsx +10 -0
- package/templates/react-app/files/src/shared/api/base-api.ts +24 -0
- package/templates/react-app/files/src/shared/api/base-query.ts +29 -0
- package/templates/react-app/files/src/shared/api/config.ts +21 -0
- package/templates/react-app/files/src/shared/api/index.ts +15 -0
- package/templates/react-app/files/src/shared/api/realtime-events.ts +34 -0
- package/templates/react-app/files/src/shared/api/socket.ts +41 -0
- package/templates/react-app/files/src/shared/api/store.ts +39 -0
- package/templates/react-app/files/src/shared/api/upload-query.ts +115 -0
- package/templates/react-app/files/src/shared/auth/client.ts +27 -0
- package/templates/react-app/files/src/shared/auth/config.ts +28 -0
- package/templates/react-app/files/src/shared/auth/guards.tsx +75 -0
- package/templates/react-app/files/src/shared/auth/hooks.ts +13 -0
- package/templates/react-app/files/src/shared/auth/index.ts +20 -0
- package/templates/react-app/files/src/shared/auth/logout.ts +23 -0
- package/templates/react-app/files/src/shared/auth/provider.tsx +52 -0
- package/templates/react-app/files/src/shared/auth/redirect.ts +65 -0
- package/templates/react-app/files/src/shared/auth/slice.ts +54 -0
- package/templates/react-app/files/src/shared/hooks/index.ts +6 -0
- package/templates/react-app/files/src/shared/layouts/app-shell/app-shell.tsx +225 -0
- package/templates/react-app/files/src/shared/layouts/app-shell/user-menu.tsx +74 -0
- package/templates/react-app/files/src/shared/layouts/auth-layout.tsx +137 -0
- package/templates/react-app/files/src/shared/layouts/error-boundary.tsx +38 -0
- package/templates/react-app/files/src/shared/layouts/index.ts +23 -0
- package/templates/react-app/files/src/shared/layouts/marketing/marketing-layout.tsx +29 -0
- package/templates/react-app/files/src/shared/layouts/marketing/section-heading.tsx +38 -0
- package/templates/react-app/files/src/shared/layouts/marketing/section.tsx +30 -0
- package/templates/react-app/files/src/shared/layouts/states/app-shell-skeleton.tsx +47 -0
- package/templates/react-app/files/src/shared/layouts/states/empty.tsx +22 -0
- package/templates/react-app/files/src/shared/layouts/states/forbidden.tsx +14 -0
- package/templates/react-app/files/src/shared/layouts/states/loading.tsx +11 -0
- package/templates/react-app/files/src/shared/layouts/states/not-found.tsx +21 -0
- package/templates/react-app/files/src/shared/layouts/states/page-skeleton.tsx +39 -0
- package/templates/react-app/files/src/shared/layouts/states/route-fallback.tsx +26 -0
- package/templates/react-app/files/src/shared/layouts/states/state-screen.tsx +22 -0
- package/templates/react-app/files/src/shared/types/README.md +28 -0
- package/templates/react-app/files/src/shared/types/api/index.ts +9 -0
- package/templates/react-app/files/src/shared/types/api/zod.gen.ts +5 -0
- package/templates/react-app/files/src/shared/types/index.ts +4 -0
- package/templates/react-app/files/src/shared/ui/components/brand/logo.tsx +51 -0
- package/templates/react-app/files/src/shared/ui/components/brand/social-icons.tsx +37 -0
- package/templates/react-app/files/src/shared/ui/components/form/form.tsx +120 -0
- package/templates/react-app/files/src/shared/ui/components/ui/alert.tsx +25 -0
- package/templates/react-app/files/src/shared/ui/components/ui/button.tsx +43 -0
- package/templates/react-app/files/src/shared/ui/components/ui/calendar.tsx +78 -0
- package/templates/react-app/files/src/shared/ui/components/ui/card.tsx +44 -0
- package/templates/react-app/files/src/shared/ui/components/ui/checkbox.tsx +16 -0
- package/templates/react-app/files/src/shared/ui/components/ui/date-picker.tsx +76 -0
- package/templates/react-app/files/src/shared/ui/components/ui/input.tsx +22 -0
- package/templates/react-app/files/src/shared/ui/components/ui/label.tsx +19 -0
- package/templates/react-app/files/src/shared/ui/components/ui/modal.tsx +94 -0
- package/templates/react-app/files/src/shared/ui/components/ui/popover.tsx +31 -0
- package/templates/react-app/files/src/shared/ui/components/ui/progress.tsx +33 -0
- package/templates/react-app/files/src/shared/ui/components/ui/search-input.tsx +69 -0
- package/templates/react-app/files/src/shared/ui/components/ui/select.tsx +80 -0
- package/templates/react-app/files/src/shared/ui/components/ui/skeleton.tsx +12 -0
- package/templates/react-app/files/src/shared/ui/components/ui/sonner.tsx +23 -0
- package/templates/react-app/files/src/shared/ui/components/ui/spinner.tsx +8 -0
- package/templates/react-app/files/src/shared/ui/components/ui/textarea.tsx +22 -0
- package/templates/react-app/files/src/shared/ui/index.ts +45 -0
- package/templates/react-app/files/src/shared/ui/lib/utils.ts +7 -0
- package/templates/react-app/files/src/shared/ui/lib/zod-setup.ts +28 -0
- package/templates/react-app/files/src/shared/ui/meta/brand.ts +18 -0
- package/templates/react-app/files/src/shared/ui/meta/meta-context.ts +30 -0
- package/templates/react-app/files/src/shared/ui/meta/meta-provider.tsx +24 -0
- package/templates/react-app/files/src/shared/ui/meta/page-meta.tsx +69 -0
- package/templates/react-app/files/src/shared/ui/meta/use-meta-config.ts +11 -0
- package/templates/react-app/files/src/shared/ui/styles/globals.css +285 -0
- package/templates/react-app/files/src/shared/ui/styles/theme.css +48 -0
- package/templates/react-app/files/src/shared/ui/theme/init-script.ts +23 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-colors.ts +14 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-context.ts +60 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-provider.tsx +101 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-toggle.tsx +40 -0
- package/templates/react-app/files/src/shared/ui/theme/use-theme.ts +11 -0
- package/templates/react-app/files/src/vite-env.d.ts +13 -0
- package/templates/react-app/files/tsconfig.json +26 -0
- package/templates/react-app/files/tsconfig.node.json +25 -0
- package/templates/react-app/files/vite.config.ts +344 -0
- package/templates/react-app/overrides/src/routes/auth/forgot-password.tsx +93 -0
- package/templates/react-app/overrides/src/routes/auth/login.tsx +87 -0
- package/templates/react-app/overrides/src/routes/auth/signup.tsx +117 -0
- package/templates/react-app/overrides/src/routes/auth/verified.tsx +31 -0
- package/templates/react-app/overrides/src/routes/auth/verify-email.tsx +97 -0
- package/templates/react-app/overrides/src/shared/auth/config.ts +28 -0
- package/templates/react-app/overrides/src/shared/auth/guards.tsx +75 -0
- package/templates/react-app/overrides/src/shared/auth/index.ts +20 -0
- package/templates/react-app/overrides/src/shared/auth/redirect.ts +65 -0
- package/templates/react-app/overrides/src/shared/hooks/index.ts +6 -0
- package/templates/react-app/overrides/src/shared/types/README.md +28 -0
- package/templates/react-app/template.json +222 -0
- package/templates/react-monorepo/files/.dockerignore +19 -0
- package/templates/react-monorepo/files/.editorconfig +12 -0
- package/templates/react-monorepo/files/.forgejo/workflows/build-and-push.yml +98 -0
- package/templates/react-monorepo/files/.forgejo/workflows/ci.yml +35 -0
- package/templates/react-monorepo/files/.husky/pre-commit +1 -0
- package/templates/react-monorepo/files/.nvmrc +1 -0
- package/templates/react-monorepo/files/.prettierignore +6 -0
- package/templates/react-monorepo/files/.prettierrc +9 -0
- package/templates/react-monorepo/files/.yarnrc.yml +2 -0
- package/templates/react-monorepo/files/Dockerfile +90 -0
- package/templates/react-monorepo/files/_gitignore +35 -0
- package/templates/react-monorepo/files/apps/admin/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/admin/.env.example +16 -0
- package/templates/react-monorepo/files/apps/admin/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/admin/index.html +57 -0
- package/templates/react-monorepo/files/apps/admin/package.json +33 -0
- package/templates/react-monorepo/files/apps/admin/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/admin/src/app/nav.tsx +14 -0
- package/templates/react-monorepo/files/apps/admin/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/admin/src/app/router.tsx +50 -0
- package/templates/react-monorepo/files/apps/admin/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/admin/src/lib/env.ts +12 -0
- package/templates/react-monorepo/files/apps/admin/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/admin/src/routes/home.tsx +17 -0
- package/templates/react-monorepo/files/apps/admin/src/routes/settings.tsx +10 -0
- package/templates/react-monorepo/files/apps/admin/src/vite-env.d.ts +14 -0
- package/templates/react-monorepo/files/apps/admin/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/admin/vite.config.ts +13 -0
- package/templates/react-monorepo/files/apps/auth/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/auth/.env.example +16 -0
- package/templates/react-monorepo/files/apps/auth/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/auth/index.html +57 -0
- package/templates/react-monorepo/files/apps/auth/package.json +32 -0
- package/templates/react-monorepo/files/apps/auth/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/auth/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/auth/src/app/router.tsx +19 -0
- package/templates/react-monorepo/files/apps/auth/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/auth/src/components/auth-card.tsx +23 -0
- package/templates/react-monorepo/files/apps/auth/src/components/checkbox-field.tsx +32 -0
- package/templates/react-monorepo/files/apps/auth/src/components/google-button.tsx +41 -0
- package/templates/react-monorepo/files/apps/auth/src/components/or-divider.tsx +9 -0
- package/templates/react-monorepo/files/apps/auth/src/components/password-field.tsx +70 -0
- package/templates/react-monorepo/files/apps/auth/src/components/submit-button.tsx +16 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/auth-actions.ts +68 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/env.ts +8 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/password-strength.ts +20 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/redirect.ts +6 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/schemas.ts +37 -0
- package/templates/react-monorepo/files/apps/auth/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/forgot-password.tsx +91 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/login.tsx +82 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/reset-password.tsx +83 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/signup.tsx +117 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/verified.tsx +30 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/verify-email.tsx +96 -0
- package/templates/react-monorepo/files/apps/auth/src/vite-env.d.ts +14 -0
- package/templates/react-monorepo/files/apps/auth/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/auth/vite.config.ts +13 -0
- package/templates/react-monorepo/files/apps/client/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/client/.env.example +16 -0
- package/templates/react-monorepo/files/apps/client/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/client/index.html +57 -0
- package/templates/react-monorepo/files/apps/client/package.json +35 -0
- package/templates/react-monorepo/files/apps/client/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/client/src/app/nav.tsx +14 -0
- package/templates/react-monorepo/files/apps/client/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/client/src/app/router.tsx +50 -0
- package/templates/react-monorepo/files/apps/client/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/client/src/lib/env.ts +12 -0
- package/templates/react-monorepo/files/apps/client/src/main.tsx +19 -0
- package/templates/react-monorepo/files/apps/client/src/routes/home.tsx +17 -0
- package/templates/react-monorepo/files/apps/client/src/routes/settings.tsx +10 -0
- package/templates/react-monorepo/files/apps/client/src/vite-env.d.ts +15 -0
- package/templates/react-monorepo/files/apps/client/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/client/vite.config.ts +120 -0
- package/templates/react-monorepo/files/apps/landing/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/landing/.env.example +20 -0
- package/templates/react-monorepo/files/apps/landing/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/landing/index.html +51 -0
- package/templates/react-monorepo/files/apps/landing/package.json +33 -0
- package/templates/react-monorepo/files/apps/landing/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/landing/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/landing/src/app/router.tsx +21 -0
- package/templates/react-monorepo/files/apps/landing/src/app/store.ts +18 -0
- package/templates/react-monorepo/files/apps/landing/src/features/seo/routes.ts +65 -0
- package/templates/react-monorepo/files/apps/landing/src/lib/env.ts +10 -0
- package/templates/react-monorepo/files/apps/landing/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/landing/src/routes/home.tsx +18 -0
- package/templates/react-monorepo/files/apps/landing/src/vite-env.d.ts +15 -0
- package/templates/react-monorepo/files/apps/landing/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/landing/vite.config.ts +169 -0
- package/templates/react-monorepo/files/build.sh +61 -0
- package/templates/react-monorepo/files/docker/nginx.conf +136 -0
- package/templates/react-monorepo/files/package.json +37 -0
- package/templates/react-monorepo/files/packages/.gitkeep +0 -0
- package/templates/react-monorepo/files/packages/api/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/api/package.json +30 -0
- package/templates/react-monorepo/files/packages/api/src/base-api.ts +24 -0
- package/templates/react-monorepo/files/packages/api/src/base-query.ts +29 -0
- package/templates/react-monorepo/files/packages/api/src/config.ts +21 -0
- package/templates/react-monorepo/files/packages/api/src/index.ts +15 -0
- package/templates/react-monorepo/files/packages/api/src/realtime-events.ts +34 -0
- package/templates/react-monorepo/files/packages/api/src/socket.ts +41 -0
- package/templates/react-monorepo/files/packages/api/src/store.ts +39 -0
- package/templates/react-monorepo/files/packages/api/src/upload-query.ts +115 -0
- package/templates/react-monorepo/files/packages/api/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/auth/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/auth/package.json +33 -0
- package/templates/react-monorepo/files/packages/auth/src/client.ts +27 -0
- package/templates/react-monorepo/files/packages/auth/src/config.ts +22 -0
- package/templates/react-monorepo/files/packages/auth/src/guards.tsx +61 -0
- package/templates/react-monorepo/files/packages/auth/src/hooks.ts +13 -0
- package/templates/react-monorepo/files/packages/auth/src/index.ts +20 -0
- package/templates/react-monorepo/files/packages/auth/src/logout.ts +23 -0
- package/templates/react-monorepo/files/packages/auth/src/provider.tsx +52 -0
- package/templates/react-monorepo/files/packages/auth/src/redirect.ts +37 -0
- package/templates/react-monorepo/files/packages/auth/src/slice.ts +54 -0
- package/templates/react-monorepo/files/packages/auth/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/config/README.md +47 -0
- package/templates/react-monorepo/files/packages/config/eslint/base.mjs +83 -0
- package/templates/react-monorepo/files/packages/config/package.json +37 -0
- package/templates/react-monorepo/files/packages/config/tailwind/theme.css +48 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/base.json +22 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/node.json +9 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/react.json +9 -0
- package/templates/react-monorepo/files/packages/config/vite/index.d.ts +18 -0
- package/templates/react-monorepo/files/packages/config/vite/index.mjs +129 -0
- package/templates/react-monorepo/files/packages/hooks/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/hooks/package.json +16 -0
- package/templates/react-monorepo/files/packages/hooks/src/index.ts +3 -0
- package/templates/react-monorepo/files/packages/hooks/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/layouts/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/layouts/package.json +30 -0
- package/templates/react-monorepo/files/packages/layouts/src/app-shell/app-shell.tsx +225 -0
- package/templates/react-monorepo/files/packages/layouts/src/app-shell/user-menu.tsx +74 -0
- package/templates/react-monorepo/files/packages/layouts/src/auth-layout.tsx +137 -0
- package/templates/react-monorepo/files/packages/layouts/src/error-boundary.tsx +38 -0
- package/templates/react-monorepo/files/packages/layouts/src/index.ts +23 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/marketing-layout.tsx +29 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/section-heading.tsx +38 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/section.tsx +30 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/app-shell-skeleton.tsx +47 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/empty.tsx +22 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/forbidden.tsx +14 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/loading.tsx +11 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/not-found.tsx +21 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/page-skeleton.tsx +39 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/route-fallback.tsx +26 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/state-screen.tsx +22 -0
- package/templates/react-monorepo/files/packages/layouts/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/types/.bin/openapi.js +32 -0
- package/templates/react-monorepo/files/packages/types/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/packages/types/README.md +28 -0
- package/templates/react-monorepo/files/packages/types/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/types/openapi-ts.config.ts +22 -0
- package/templates/react-monorepo/files/packages/types/package.json +29 -0
- package/templates/react-monorepo/files/packages/types/src/index.ts +4 -0
- package/templates/react-monorepo/files/packages/types/src/types/api/index.ts +9 -0
- package/templates/react-monorepo/files/packages/types/src/types/api/zod.gen.ts +5 -0
- package/templates/react-monorepo/files/packages/types/tsconfig.json +7 -0
- package/templates/react-monorepo/files/packages/ui/components.json +21 -0
- package/templates/react-monorepo/files/packages/ui/eslint.config.mjs +13 -0
- package/templates/react-monorepo/files/packages/ui/package.json +44 -0
- package/templates/react-monorepo/files/packages/ui/src/components/brand/logo.tsx +51 -0
- package/templates/react-monorepo/files/packages/ui/src/components/brand/social-icons.tsx +37 -0
- package/templates/react-monorepo/files/packages/ui/src/components/form/form.tsx +120 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/alert.tsx +25 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/button.tsx +43 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/calendar.tsx +78 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/card.tsx +44 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/checkbox.tsx +16 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/date-picker.tsx +76 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/input.tsx +22 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/label.tsx +19 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/modal.tsx +94 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/popover.tsx +31 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/progress.tsx +33 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/search-input.tsx +69 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/select.tsx +80 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/skeleton.tsx +12 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/sonner.tsx +23 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/spinner.tsx +8 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/textarea.tsx +22 -0
- package/templates/react-monorepo/files/packages/ui/src/index.ts +45 -0
- package/templates/react-monorepo/files/packages/ui/src/lib/utils.ts +7 -0
- package/templates/react-monorepo/files/packages/ui/src/lib/zod-setup.ts +28 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/brand.ts +18 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/meta-context.ts +30 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/meta-provider.tsx +24 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/page-meta.tsx +69 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/use-meta-config.ts +11 -0
- package/templates/react-monorepo/files/packages/ui/src/styles/globals.css +285 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/init-script.ts +23 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-colors.ts +14 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-context.ts +60 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-provider.tsx +101 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-toggle.tsx +40 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/use-theme.ts +11 -0
- package/templates/react-monorepo/files/packages/ui/tsconfig.json +9 -0
- package/templates/react-monorepo/files/turbo.json +24 -0
- package/templates/react-monorepo/template.json +230 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The single door onto the environment.
|
|
7
|
+
*
|
|
8
|
+
* App code must never read `process.env` directly — go through the injected
|
|
9
|
+
* `CustomConfigService` instead. Everything is validated once, at boot, against
|
|
10
|
+
* the Zod `schema`, so a missing variable fails the process immediately rather
|
|
11
|
+
* than surfacing as `undefined` deep inside a request.
|
|
12
|
+
*
|
|
13
|
+
* Adding a variable means three edits in this file: the interface, the Zod
|
|
14
|
+
* schema, and `getVariables` — plus a line in `.env.example`.
|
|
15
|
+
*/
|
|
16
|
+
namespace Config {
|
|
17
|
+
export interface App {
|
|
18
|
+
name: string;
|
|
19
|
+
twofaAppName: string;
|
|
20
|
+
env: string;
|
|
21
|
+
host: string;
|
|
22
|
+
appHost: string;
|
|
23
|
+
frontendHost: string;
|
|
24
|
+
miscCorsOrigins?: string;
|
|
25
|
+
port: number;
|
|
26
|
+
key: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Logger {
|
|
30
|
+
level: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// @feature:start observability
|
|
34
|
+
/** Limits past which /health reports the process as down. */
|
|
35
|
+
export interface Health {
|
|
36
|
+
heapMaxMb: number;
|
|
37
|
+
rssMaxMb: number;
|
|
38
|
+
/** Fraction of `diskPath`'s volume that may be used, 0–1. */
|
|
39
|
+
diskThreshold: number;
|
|
40
|
+
diskPath: string;
|
|
41
|
+
}
|
|
42
|
+
// @feature:end
|
|
43
|
+
|
|
44
|
+
export interface Database {
|
|
45
|
+
url: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// @feature:start cache
|
|
49
|
+
export interface Redis {
|
|
50
|
+
host: string;
|
|
51
|
+
port: number;
|
|
52
|
+
username?: string;
|
|
53
|
+
password?: string;
|
|
54
|
+
}
|
|
55
|
+
// @feature:end
|
|
56
|
+
|
|
57
|
+
// @feature:start openapi, queue, observability
|
|
58
|
+
export interface BasicAuth {
|
|
59
|
+
user: string;
|
|
60
|
+
password: string;
|
|
61
|
+
}
|
|
62
|
+
// @feature:end
|
|
63
|
+
|
|
64
|
+
export interface BetterAuth {
|
|
65
|
+
secret: string;
|
|
66
|
+
url: string;
|
|
67
|
+
cookieDomain: string;
|
|
68
|
+
cookiePrefix: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// @feature:start feature-flags
|
|
72
|
+
export interface Growthbook {
|
|
73
|
+
apiHost: string;
|
|
74
|
+
clientKey: string;
|
|
75
|
+
}
|
|
76
|
+
// @feature:end
|
|
77
|
+
|
|
78
|
+
export interface Superuser {
|
|
79
|
+
email: string;
|
|
80
|
+
username: string;
|
|
81
|
+
password: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// @feature:start mail
|
|
85
|
+
export interface SMTP {
|
|
86
|
+
host: string;
|
|
87
|
+
port: number;
|
|
88
|
+
user: string;
|
|
89
|
+
password: string;
|
|
90
|
+
from: string;
|
|
91
|
+
supportEmail: string;
|
|
92
|
+
secure: boolean;
|
|
93
|
+
}
|
|
94
|
+
// @feature:end
|
|
95
|
+
|
|
96
|
+
// @feature:start media
|
|
97
|
+
export interface S3 {
|
|
98
|
+
accessKeyId: string;
|
|
99
|
+
secretAccessKey: string;
|
|
100
|
+
endpoint: string;
|
|
101
|
+
bucket: string;
|
|
102
|
+
region: string;
|
|
103
|
+
}
|
|
104
|
+
// @feature:end
|
|
105
|
+
|
|
106
|
+
// @feature:start rate-limit
|
|
107
|
+
export interface RateLimit {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
ttl: number;
|
|
110
|
+
limit: number;
|
|
111
|
+
authWindow: number;
|
|
112
|
+
authMax: number;
|
|
113
|
+
ipHeaders: string[];
|
|
114
|
+
}
|
|
115
|
+
// @feature:end
|
|
116
|
+
|
|
117
|
+
export interface OAuthGoogle {
|
|
118
|
+
clientId: string;
|
|
119
|
+
clientSecret: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface OAuth {
|
|
123
|
+
google: OAuthGoogle;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface Env {
|
|
127
|
+
app: App;
|
|
128
|
+
logger: Logger;
|
|
129
|
+
health: Health; // @feature observability
|
|
130
|
+
database: Database;
|
|
131
|
+
redis: Redis; // @feature cache
|
|
132
|
+
basicAuth: BasicAuth; // @feature openapi, queue, observability
|
|
133
|
+
betterAuth: BetterAuth;
|
|
134
|
+
growthbook: Growthbook; // @feature feature-flags
|
|
135
|
+
superuser: Superuser;
|
|
136
|
+
smtp: SMTP; // @feature mail
|
|
137
|
+
s3: S3; // @feature media
|
|
138
|
+
rateLimit: RateLimit; // @feature rate-limit
|
|
139
|
+
oauth: OAuth;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const { env } = process;
|
|
143
|
+
|
|
144
|
+
// Env primitives: a required string must be non-empty, and a number arrives
|
|
145
|
+
// as text that must parse (a blank is an error, not 0).
|
|
146
|
+
const str = () => z.string().min(1);
|
|
147
|
+
const num = (schema: z.ZodNumber = z.number()) =>
|
|
148
|
+
z.string().trim().min(1).transform(Number).pipe(schema);
|
|
149
|
+
|
|
150
|
+
export const schema = z.object({
|
|
151
|
+
APP_ENV: z
|
|
152
|
+
.enum(['development', 'production', 'test'])
|
|
153
|
+
.default('development'),
|
|
154
|
+
APP_HOST: str(),
|
|
155
|
+
APP_NAME: str(),
|
|
156
|
+
SERVER_HOST: str(),
|
|
157
|
+
FRONTEND_HOST: str(),
|
|
158
|
+
MISC_CORS_ORIGINS: z.string().default(''),
|
|
159
|
+
PORT: num().default(5000),
|
|
160
|
+
DATABASE_URL: str(),
|
|
161
|
+
BETTER_AUTH_SECRET: str(),
|
|
162
|
+
BETTER_AUTH_URL: str(),
|
|
163
|
+
BETTER_AUTH_COOKIE_DOMAIN: str(),
|
|
164
|
+
BETTER_AUTH_COOKIE_PREFIX: str(),
|
|
165
|
+
SUPERUSER_EMAIL: str(),
|
|
166
|
+
SUPERUSER_PASSWORD: str(),
|
|
167
|
+
OAUTH_GOOGLE_CLIENT_ID: z.string().optional(),
|
|
168
|
+
OAUTH_GOOGLE_CLIENT_SECRET: z.string().optional(),
|
|
169
|
+
LOG_LEVEL: str().default('info'),
|
|
170
|
+
// @feature:start observability
|
|
171
|
+
HEALTH_HEAP_MAX_MB: num(z.number().positive()).default(300),
|
|
172
|
+
HEALTH_RSS_MAX_MB: num(z.number().positive()).default(300),
|
|
173
|
+
HEALTH_DISK_THRESHOLD: num(z.number().min(0).max(1)).default(0.8),
|
|
174
|
+
HEALTH_DISK_PATH: str().default('/'),
|
|
175
|
+
// @feature:end
|
|
176
|
+
// @feature:start openapi, queue, observability
|
|
177
|
+
BASIC_AUTH_USER: str(),
|
|
178
|
+
BASIC_AUTH_PASS: str(),
|
|
179
|
+
// @feature:end
|
|
180
|
+
// @feature:start cache
|
|
181
|
+
REDIS_HOST: str().default('localhost'),
|
|
182
|
+
REDIS_PORT: num().default(6379),
|
|
183
|
+
REDIS_USER: z.string().optional(),
|
|
184
|
+
REDIS_PASSWORD: z.string().optional(),
|
|
185
|
+
// @feature:end
|
|
186
|
+
// @feature:start mail
|
|
187
|
+
SMTP_HOST: str(),
|
|
188
|
+
SMTP_PORT: z.enum(['465', '587']),
|
|
189
|
+
SMTP_SECURE: z.enum(['true', 'false']),
|
|
190
|
+
SMTP_USER: str(),
|
|
191
|
+
SMTP_PASSWORD: str(),
|
|
192
|
+
SMTP_FROM: str(),
|
|
193
|
+
SMTP_SUPPORT_EMAIL: str(),
|
|
194
|
+
// @feature:end
|
|
195
|
+
// @feature:start media
|
|
196
|
+
S3_REGION: str().default('us-east-1'),
|
|
197
|
+
S3_ENDPOINT: z.string().optional(),
|
|
198
|
+
S3_BUCKET_NAME: str(),
|
|
199
|
+
S3_ACCESS_KEY_ID: z.string().optional(),
|
|
200
|
+
S3_SECRET_ACCESS_KEY: z.string().optional(),
|
|
201
|
+
// @feature:end
|
|
202
|
+
// @feature:start rate-limit
|
|
203
|
+
RATE_LIMIT_ENABLED: z.enum(['true', 'false']).default('true'),
|
|
204
|
+
RATE_LIMIT_TTL: num().default(60_000),
|
|
205
|
+
RATE_LIMIT_MAX: num().default(120),
|
|
206
|
+
RATE_LIMIT_AUTH_WINDOW: num().default(10),
|
|
207
|
+
RATE_LIMIT_AUTH_MAX: num().default(100),
|
|
208
|
+
RATE_LIMIT_IP_HEADERS: str().default('x-forwarded-for'),
|
|
209
|
+
// @feature:end
|
|
210
|
+
// @feature:start feature-flags
|
|
211
|
+
GROWTHBOOK_API_HOST: str(),
|
|
212
|
+
GROWTHBOOK_CLIENT_KEY: str()
|
|
213
|
+
// @feature:end
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export const getVariables = (): Config.Env => ({
|
|
217
|
+
app: {
|
|
218
|
+
name: env.APP_NAME || '',
|
|
219
|
+
twofaAppName: env.TWOFA_APP_NAME || env.APP_NAME || '',
|
|
220
|
+
env: env.APP_ENV || '',
|
|
221
|
+
host: env.SERVER_HOST || '',
|
|
222
|
+
appHost: env.APP_HOST || '',
|
|
223
|
+
frontendHost: env.FRONTEND_HOST || '',
|
|
224
|
+
miscCorsOrigins: env.MISC_CORS_ORIGINS,
|
|
225
|
+
port: Number(env.PORT) || 5000,
|
|
226
|
+
key: env.APP_KEY || ''
|
|
227
|
+
},
|
|
228
|
+
logger: {
|
|
229
|
+
level: env.LOG_LEVEL || 'info'
|
|
230
|
+
},
|
|
231
|
+
// @feature:start observability
|
|
232
|
+
health: {
|
|
233
|
+
heapMaxMb: Number(env.HEALTH_HEAP_MAX_MB) || 300,
|
|
234
|
+
rssMaxMb: Number(env.HEALTH_RSS_MAX_MB) || 300,
|
|
235
|
+
diskThreshold: env.HEALTH_DISK_THRESHOLD
|
|
236
|
+
? Number(env.HEALTH_DISK_THRESHOLD)
|
|
237
|
+
: 0.8,
|
|
238
|
+
diskPath: env.HEALTH_DISK_PATH || '/'
|
|
239
|
+
},
|
|
240
|
+
// @feature:end
|
|
241
|
+
database: {
|
|
242
|
+
url: env.DATABASE_URL || ''
|
|
243
|
+
},
|
|
244
|
+
// @feature:start cache
|
|
245
|
+
redis: {
|
|
246
|
+
host: env.REDIS_HOST || 'localhost',
|
|
247
|
+
port: Number(env.REDIS_PORT) || 6379,
|
|
248
|
+
username: env.REDIS_USER || '',
|
|
249
|
+
password: env.REDIS_PASSWORD || ''
|
|
250
|
+
},
|
|
251
|
+
// @feature:end
|
|
252
|
+
// @feature:start openapi, queue, observability
|
|
253
|
+
basicAuth: {
|
|
254
|
+
user: env.BASIC_AUTH_USER || 'user',
|
|
255
|
+
password: env.BASIC_AUTH_PASS || 'password'
|
|
256
|
+
},
|
|
257
|
+
// @feature:end
|
|
258
|
+
betterAuth: {
|
|
259
|
+
secret: env.BETTER_AUTH_SECRET || '',
|
|
260
|
+
url: env.BETTER_AUTH_URL || env.SERVER_HOST || '',
|
|
261
|
+
cookieDomain: env.BETTER_AUTH_COOKIE_DOMAIN || '',
|
|
262
|
+
cookiePrefix: env.BETTER_AUTH_COOKIE_PREFIX || ''
|
|
263
|
+
},
|
|
264
|
+
// @feature:start feature-flags
|
|
265
|
+
growthbook: {
|
|
266
|
+
apiHost: env.GROWTHBOOK_API_HOST || '',
|
|
267
|
+
clientKey: env.GROWTHBOOK_CLIENT_KEY || ''
|
|
268
|
+
},
|
|
269
|
+
// @feature:end
|
|
270
|
+
superuser: {
|
|
271
|
+
email: env.SUPERUSER_EMAIL || '',
|
|
272
|
+
username: env.SUPERUSER_USERNAME || '',
|
|
273
|
+
password: env.SUPERUSER_PASSWORD || ''
|
|
274
|
+
},
|
|
275
|
+
// @feature:start mail
|
|
276
|
+
smtp: {
|
|
277
|
+
host: env.SMTP_HOST || '',
|
|
278
|
+
port: Number(env.SMTP_PORT) || 465,
|
|
279
|
+
user: env.SMTP_USER || '',
|
|
280
|
+
password: env.SMTP_PASSWORD || '',
|
|
281
|
+
from: env.SMTP_FROM || '',
|
|
282
|
+
secure: env.SMTP_SECURE === 'true',
|
|
283
|
+
supportEmail: env.SMTP_SUPPORT_EMAIL || ''
|
|
284
|
+
},
|
|
285
|
+
// @feature:end
|
|
286
|
+
// @feature:start media
|
|
287
|
+
s3: {
|
|
288
|
+
accessKeyId: env.S3_ACCESS_KEY_ID || '',
|
|
289
|
+
secretAccessKey: env.S3_SECRET_ACCESS_KEY || '',
|
|
290
|
+
endpoint: env.S3_ENDPOINT || '',
|
|
291
|
+
bucket: env.S3_BUCKET_NAME || '',
|
|
292
|
+
region: env.S3_REGION || 'us-east-1'
|
|
293
|
+
},
|
|
294
|
+
// @feature:end
|
|
295
|
+
// @feature:start rate-limit
|
|
296
|
+
rateLimit: {
|
|
297
|
+
enabled: env.RATE_LIMIT_ENABLED !== 'false',
|
|
298
|
+
ttl: Number(env.RATE_LIMIT_TTL) || 60_000,
|
|
299
|
+
limit: Number(env.RATE_LIMIT_MAX) || 120,
|
|
300
|
+
authWindow: Number(env.RATE_LIMIT_AUTH_WINDOW) || 10,
|
|
301
|
+
authMax: Number(env.RATE_LIMIT_AUTH_MAX) || 100,
|
|
302
|
+
ipHeaders: (env.RATE_LIMIT_IP_HEADERS || 'x-forwarded-for')
|
|
303
|
+
.split(',')
|
|
304
|
+
.map((header) => header.trim().toLowerCase())
|
|
305
|
+
.filter(Boolean)
|
|
306
|
+
},
|
|
307
|
+
// @feature:end
|
|
308
|
+
oauth: {
|
|
309
|
+
google: {
|
|
310
|
+
clientId: env.OAUTH_GOOGLE_CLIENT_ID || '',
|
|
311
|
+
clientSecret: env.OAUTH_GOOGLE_CLIENT_SECRET || ''
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@Injectable()
|
|
318
|
+
export class CustomConfigService {
|
|
319
|
+
constructor(private readonly config: ConfigService<Config.Env, true>) {}
|
|
320
|
+
|
|
321
|
+
get app() {
|
|
322
|
+
return this.config.get('app', { infer: true });
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
get logger() {
|
|
326
|
+
return this.config.get('logger', { infer: true });
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// @feature:start observability
|
|
330
|
+
get health() {
|
|
331
|
+
return this.config.get('health', { infer: true });
|
|
332
|
+
}
|
|
333
|
+
// @feature:end
|
|
334
|
+
|
|
335
|
+
get database() {
|
|
336
|
+
return this.config.get('database', { infer: true });
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// @feature:start cache
|
|
340
|
+
get redis() {
|
|
341
|
+
return this.config.get('redis', { infer: true });
|
|
342
|
+
}
|
|
343
|
+
// @feature:end
|
|
344
|
+
|
|
345
|
+
// @feature:start openapi, queue, observability
|
|
346
|
+
get basicAuth() {
|
|
347
|
+
return this.config.get('basicAuth', { infer: true });
|
|
348
|
+
}
|
|
349
|
+
// @feature:end
|
|
350
|
+
|
|
351
|
+
get betterAuth() {
|
|
352
|
+
return this.config.get('betterAuth', { infer: true });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// @feature:start feature-flags
|
|
356
|
+
get growthbook() {
|
|
357
|
+
return this.config.get('growthbook', { infer: true });
|
|
358
|
+
}
|
|
359
|
+
// @feature:end
|
|
360
|
+
|
|
361
|
+
get superuser() {
|
|
362
|
+
return this.config.get('superuser', { infer: true });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// @feature:start mail
|
|
366
|
+
get smtp() {
|
|
367
|
+
return this.config.get('smtp', { infer: true });
|
|
368
|
+
}
|
|
369
|
+
// @feature:end
|
|
370
|
+
|
|
371
|
+
// @feature:start media
|
|
372
|
+
get s3() {
|
|
373
|
+
return this.config.get('s3', { infer: true });
|
|
374
|
+
}
|
|
375
|
+
// @feature:end
|
|
376
|
+
|
|
377
|
+
// @feature:start rate-limit
|
|
378
|
+
get rateLimit() {
|
|
379
|
+
return this.config.get('rateLimit', { infer: true });
|
|
380
|
+
}
|
|
381
|
+
// @feature:end
|
|
382
|
+
|
|
383
|
+
get oauth() {
|
|
384
|
+
return this.config.get('oauth', { infer: true });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export default Config;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { Interval } from '@nestjs/schedule';
|
|
3
|
+
import {
|
|
4
|
+
GrowthBookClient,
|
|
5
|
+
UserScopedGrowthBook,
|
|
6
|
+
type Attributes,
|
|
7
|
+
type FeatureResult
|
|
8
|
+
} from '@growthbook/growthbook';
|
|
9
|
+
import { CustomConfigService } from './config.service';
|
|
10
|
+
import { LoggerService } from './logger.service';
|
|
11
|
+
|
|
12
|
+
const POLL_INTERVAL_MS = 60_000;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Declare each flag here so `isOn`/`getValue` are typed against real keys
|
|
16
|
+
* instead of arbitrary strings — a renamed flag then fails to compile rather
|
|
17
|
+
* than silently evaluating to its default forever.
|
|
18
|
+
*/
|
|
19
|
+
export interface AppFeatures extends Record<string, unknown> {
|
|
20
|
+
example: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Injectable()
|
|
24
|
+
export class FeatureFlagService implements OnModuleInit, OnModuleDestroy {
|
|
25
|
+
private readonly client: GrowthBookClient<AppFeatures>;
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
private readonly config: CustomConfigService,
|
|
29
|
+
private readonly logger: LoggerService
|
|
30
|
+
) {
|
|
31
|
+
const { apiHost, clientKey } = this.config.growthbook;
|
|
32
|
+
this.client = new GrowthBookClient<AppFeatures>({
|
|
33
|
+
apiHost,
|
|
34
|
+
clientKey,
|
|
35
|
+
enabled: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async onModuleInit() {
|
|
40
|
+
try {
|
|
41
|
+
const { success, error } = await this.client.init({ timeout: 2000 });
|
|
42
|
+
if (success) {
|
|
43
|
+
this.logger.info('GrowthBook initialized');
|
|
44
|
+
} else {
|
|
45
|
+
this.logger.warn(
|
|
46
|
+
{ err: error },
|
|
47
|
+
'GrowthBook init did not load features — using defaults'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
this.logger.error(
|
|
52
|
+
{ err },
|
|
53
|
+
'GrowthBook init failed — feature flags will use defaults'
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onModuleDestroy() {
|
|
59
|
+
this.client.destroy();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Poll GrowthBook for updated feature definitions.
|
|
64
|
+
* Used instead of SSE streaming
|
|
65
|
+
*/
|
|
66
|
+
@Interval('growthbook-refresh', POLL_INTERVAL_MS)
|
|
67
|
+
async poll() {
|
|
68
|
+
try {
|
|
69
|
+
await this.client.refreshFeatures({ skipCache: true });
|
|
70
|
+
} catch (err) {
|
|
71
|
+
this.logger.warn(
|
|
72
|
+
{ err },
|
|
73
|
+
'GrowthBook poll refresh failed — keeping last known flags'
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Bind a set of user attributes (e.g. from the session) to a scoped
|
|
80
|
+
* instance. Prefer this when evaluating several flags for the same user.
|
|
81
|
+
*/
|
|
82
|
+
forUser(attributes: Attributes): UserScopedGrowthBook<AppFeatures> {
|
|
83
|
+
return this.client.createScopedInstance({ attributes });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async refresh() {
|
|
87
|
+
await this.client.refreshFeatures();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
isOn<K extends string & keyof AppFeatures = string>(
|
|
91
|
+
key: K,
|
|
92
|
+
attributes: Attributes = {}
|
|
93
|
+
): boolean {
|
|
94
|
+
return this.client.isOn(key, { attributes });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
isOff<K extends string & keyof AppFeatures = string>(
|
|
98
|
+
key: K,
|
|
99
|
+
attributes: Attributes = {}
|
|
100
|
+
): boolean {
|
|
101
|
+
return this.client.isOff(key, { attributes });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getValue<
|
|
105
|
+
V extends AppFeatures[K],
|
|
106
|
+
K extends string & keyof AppFeatures = string
|
|
107
|
+
>(key: K, defaultValue: V, attributes: Attributes = {}) {
|
|
108
|
+
return this.client.getFeatureValue(key, defaultValue, { attributes });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
evalFeature<
|
|
112
|
+
V extends AppFeatures[K],
|
|
113
|
+
K extends string & keyof AppFeatures = string
|
|
114
|
+
>(key: K, attributes: Attributes = {}): FeatureResult<V | null> {
|
|
115
|
+
return this.client.evalFeature(key, { attributes });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { v4 as ID } from 'uuid';
|
|
3
|
+
import { createId as CUID } from '@paralleldrive/cuid2';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import crypto from 'crypto';
|
|
6
|
+
import { generate } from 'randomstring';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class GeneratorService {
|
|
10
|
+
avatar(name: string) {
|
|
11
|
+
const seed = name.toLowerCase().replace(' ', '+');
|
|
12
|
+
const options = `seed=${seed}%size=500`;
|
|
13
|
+
return `https://api.dicebear.com/7.x/initials/png?${options}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
numeric(length: number) {
|
|
17
|
+
return generate({ charset: 'numeric', length });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
alphabet = (size = 64) => {
|
|
21
|
+
return crypto.randomBytes(size).toString('hex');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
uuid() {
|
|
25
|
+
return ID();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
cuid() {
|
|
29
|
+
return CUID();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
now() {
|
|
33
|
+
return moment.utc();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
currentDate() {
|
|
37
|
+
return new Date().toISOString().slice(0, 10);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
currentHour() {
|
|
41
|
+
return new Date().toISOString().slice(0, 13);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addPrefix(prefix: string, text: string, delimiter = ':') {
|
|
45
|
+
return prefix + delimiter + text;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
expiry(
|
|
49
|
+
amount: moment.DurationInputArg1,
|
|
50
|
+
unit: moment.unitOfTime.DurationConstructor
|
|
51
|
+
) {
|
|
52
|
+
return this.now().add(amount, unit);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './config.service';
|
|
2
|
+
export * from './generator.service';
|
|
3
|
+
export * from './prisma.service';
|
|
4
|
+
export * from './auth.service';
|
|
5
|
+
export * from './logger.service';
|
|
6
|
+
export * from './cache.service'; // @feature cache
|
|
7
|
+
export * from './mail.service'; // @feature mail
|
|
8
|
+
export * from './throttler-storage.service'; // @feature rate-limit
|
|
9
|
+
export * from './auth-rate-limit.storage'; // @feature rate-limit
|
|
10
|
+
export * from './feature-flag.service'; // @feature feature-flags
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Injectable, Inject, Scope } from '@nestjs/common';
|
|
2
|
+
import { INQUIRER } from '@nestjs/core';
|
|
3
|
+
import { PinoLogger, Params, PARAMS_PROVIDER_TOKEN } from 'nestjs-pino';
|
|
4
|
+
|
|
5
|
+
@Injectable({ scope: Scope.TRANSIENT })
|
|
6
|
+
export class LoggerService extends PinoLogger {
|
|
7
|
+
constructor(
|
|
8
|
+
@Inject(PARAMS_PROVIDER_TOKEN) params: Params,
|
|
9
|
+
@Inject(INQUIRER) parent: object
|
|
10
|
+
) {
|
|
11
|
+
super(params);
|
|
12
|
+
this.setContext(parent?.constructor?.name ?? 'App');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectQueue } from '@nestjs/bullmq';
|
|
3
|
+
import { Queue } from 'bullmq';
|
|
4
|
+
import {
|
|
5
|
+
MailJob,
|
|
6
|
+
ActivationData,
|
|
7
|
+
ActivationTwoFaData,
|
|
8
|
+
WelcomeData,
|
|
9
|
+
ForgotPasswordData,
|
|
10
|
+
SetPasswordData
|
|
11
|
+
} from 'common/types';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class MailService {
|
|
15
|
+
constructor(@InjectQueue('mail') private mail: Queue) {}
|
|
16
|
+
|
|
17
|
+
activation = (data: ActivationData) => {
|
|
18
|
+
this.mail.add(MailJob.Activation, data);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
activationTwofa = (data: ActivationTwoFaData) => {
|
|
22
|
+
this.mail.add(MailJob.ActivationTwofa, data);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
welcome = (data: WelcomeData) => {
|
|
26
|
+
this.mail.add(MailJob.Welcome, data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
forgotPassword = (data: ForgotPasswordData) => {
|
|
30
|
+
this.mail.add(MailJob.ForgotPassword, data);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
resetPassword = (data: string) => {
|
|
34
|
+
this.mail.add(MailJob.ResetPassword, data);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
passwordChanged = (data: string) => {
|
|
38
|
+
this.mail.add(MailJob.PasswordChanged, data);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
setPassword = (data: SetPasswordData) => {
|
|
42
|
+
this.mail.add(MailJob.SetPassword, data);
|
|
43
|
+
};
|
|
44
|
+
}
|