@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,225 @@
|
|
|
1
|
+
import { Job } from 'bullmq';
|
|
2
|
+
import { ISendMailOptions } from '@nestjs-modules/mailer';
|
|
3
|
+
import { render } from '@react-email/render';
|
|
4
|
+
import Activation from '@emails/activation';
|
|
5
|
+
import ActivationTwofa from '@emails/activation-twofa';
|
|
6
|
+
import Welcome from '@emails/welcome';
|
|
7
|
+
import ForgotPassword from '@emails/forgot-password';
|
|
8
|
+
import PasswordChanged from '@emails/password-changed';
|
|
9
|
+
import ResetPassword from '@emails/reset-password';
|
|
10
|
+
import SetPassword from '@emails/set-password';
|
|
11
|
+
import {
|
|
12
|
+
MailJob,
|
|
13
|
+
EmailGlobalProps,
|
|
14
|
+
ActivationData,
|
|
15
|
+
ActivationTwoFaData,
|
|
16
|
+
WelcomeData,
|
|
17
|
+
SetPasswordData,
|
|
18
|
+
ForgotPasswordData
|
|
19
|
+
} from 'common/types';
|
|
20
|
+
|
|
21
|
+
type Options = Omit<ISendMailOptions, 'from'>;
|
|
22
|
+
|
|
23
|
+
abstract class ProcessAbstract<T> {
|
|
24
|
+
abstract subject: string;
|
|
25
|
+
abstract preview?: string;
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
protected readonly job: Job<T, any, string>,
|
|
29
|
+
protected readonly globals: EmailGlobalProps
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
abstract process(): Options;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class ActivationProcess extends ProcessAbstract<ActivationData> {
|
|
36
|
+
subject = 'Account Activation';
|
|
37
|
+
preview = 'Activate your account!';
|
|
38
|
+
|
|
39
|
+
process(): Options {
|
|
40
|
+
const {
|
|
41
|
+
subject,
|
|
42
|
+
preview,
|
|
43
|
+
job: {
|
|
44
|
+
data: { to, firstName, token, url }
|
|
45
|
+
}
|
|
46
|
+
} = this;
|
|
47
|
+
const html = render(
|
|
48
|
+
Activation({ ...this.globals, subject, preview, firstName, token, url })
|
|
49
|
+
);
|
|
50
|
+
return { to, subject, html };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class ActivationTwofaProcess extends ProcessAbstract<ActivationTwoFaData> {
|
|
55
|
+
subject = 'Enable Two Factor Authentication';
|
|
56
|
+
preview = 'Scan the code!';
|
|
57
|
+
|
|
58
|
+
process(): Options {
|
|
59
|
+
const {
|
|
60
|
+
subject,
|
|
61
|
+
preview,
|
|
62
|
+
job: {
|
|
63
|
+
data: { to, firstName, qrcode }
|
|
64
|
+
}
|
|
65
|
+
} = this;
|
|
66
|
+
const html = render(
|
|
67
|
+
ActivationTwofa({ ...this.globals, subject, preview, firstName })
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
to,
|
|
71
|
+
subject,
|
|
72
|
+
html,
|
|
73
|
+
attachments: [
|
|
74
|
+
{
|
|
75
|
+
filename: 'qrcode.png',
|
|
76
|
+
path: qrcode,
|
|
77
|
+
cid: 'qrcode'
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class ForgotPasswordProcess extends ProcessAbstract<ForgotPasswordData> {
|
|
85
|
+
subject = 'Password Reset Request';
|
|
86
|
+
preview = 'Reset your password!';
|
|
87
|
+
|
|
88
|
+
process(): Options {
|
|
89
|
+
const {
|
|
90
|
+
subject,
|
|
91
|
+
preview,
|
|
92
|
+
job: {
|
|
93
|
+
data: { to, token, url }
|
|
94
|
+
}
|
|
95
|
+
} = this;
|
|
96
|
+
const html = render(
|
|
97
|
+
ForgotPassword({
|
|
98
|
+
...this.globals,
|
|
99
|
+
subject,
|
|
100
|
+
preview,
|
|
101
|
+
token,
|
|
102
|
+
url
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
return { to, subject, html };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class WelcomeProcess extends ProcessAbstract<WelcomeData> {
|
|
110
|
+
subject = `Welcome aboard 🎉`;
|
|
111
|
+
preview = 'Your account has been activated!';
|
|
112
|
+
|
|
113
|
+
process(): Options {
|
|
114
|
+
const {
|
|
115
|
+
subject,
|
|
116
|
+
preview,
|
|
117
|
+
job: {
|
|
118
|
+
data: { to, firstName, clientLoginPage, supportEmail }
|
|
119
|
+
}
|
|
120
|
+
} = this;
|
|
121
|
+
const html = render(
|
|
122
|
+
Welcome({
|
|
123
|
+
...this.globals,
|
|
124
|
+
firstName,
|
|
125
|
+
subject,
|
|
126
|
+
preview,
|
|
127
|
+
clientLoginPage,
|
|
128
|
+
supportEmail
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
return { to, subject, html };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
class SetPasswordProcess extends ProcessAbstract<SetPasswordData> {
|
|
136
|
+
subject = 'Account Created';
|
|
137
|
+
preview = 'Set your account password!';
|
|
138
|
+
|
|
139
|
+
process(): Options {
|
|
140
|
+
const {
|
|
141
|
+
subject,
|
|
142
|
+
preview,
|
|
143
|
+
job: {
|
|
144
|
+
data: { to, firstName, token }
|
|
145
|
+
}
|
|
146
|
+
} = this;
|
|
147
|
+
const html = render(
|
|
148
|
+
SetPassword({
|
|
149
|
+
...this.globals,
|
|
150
|
+
firstName,
|
|
151
|
+
subject,
|
|
152
|
+
preview,
|
|
153
|
+
token
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
return { to, subject, html };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class ResetPasswordProcess extends ProcessAbstract<string> {
|
|
161
|
+
subject = 'Password Reset';
|
|
162
|
+
preview = 'New password created!';
|
|
163
|
+
|
|
164
|
+
process(): Options {
|
|
165
|
+
const {
|
|
166
|
+
subject,
|
|
167
|
+
preview,
|
|
168
|
+
job: { data: to }
|
|
169
|
+
} = this;
|
|
170
|
+
const html = render(
|
|
171
|
+
ResetPassword({
|
|
172
|
+
...this.globals,
|
|
173
|
+
subject,
|
|
174
|
+
preview
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
return { to, subject, html };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
class PasswordChangedProcess extends ProcessAbstract<string> {
|
|
182
|
+
subject = 'Password Changed';
|
|
183
|
+
preview = 'New password created!';
|
|
184
|
+
|
|
185
|
+
process(): Options {
|
|
186
|
+
const {
|
|
187
|
+
subject,
|
|
188
|
+
preview,
|
|
189
|
+
job: { data: to }
|
|
190
|
+
} = this;
|
|
191
|
+
const html = render(
|
|
192
|
+
PasswordChanged({
|
|
193
|
+
...this.globals,
|
|
194
|
+
subject,
|
|
195
|
+
preview
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
return { to, subject, html };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export class ProcessFactory {
|
|
203
|
+
private static jobs = {
|
|
204
|
+
[MailJob.Activation]: ActivationProcess,
|
|
205
|
+
[MailJob.ActivationTwofa]: ActivationTwofaProcess,
|
|
206
|
+
[MailJob.Welcome]: WelcomeProcess,
|
|
207
|
+
[MailJob.ForgotPassword]: ForgotPasswordProcess,
|
|
208
|
+
[MailJob.ResetPassword]: ResetPasswordProcess,
|
|
209
|
+
[MailJob.PasswordChanged]: PasswordChangedProcess,
|
|
210
|
+
[MailJob.SetPassword]: SetPasswordProcess
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
private static getProcess(name: MailJob) {
|
|
214
|
+
const entry = Object.entries(ProcessFactory.jobs).find(
|
|
215
|
+
(item) => item[0] === name
|
|
216
|
+
);
|
|
217
|
+
return entry ? entry[1] : null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static init(job: Job<any, any, string>, globals: EmailGlobalProps) {
|
|
221
|
+
const Process = ProcessFactory.getProcess(job.name as MailJob);
|
|
222
|
+
if (!Process) return null;
|
|
223
|
+
return new Process(job, globals);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Prisma } from '@db/client';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reusable Zod fields. Request schemas validate and coerce what arrives;
|
|
6
|
+
* response schemas are codecs that turn what a service returns (Date, Decimal)
|
|
7
|
+
* into what goes over the wire, and OpenAPI documents the wire side.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** `Date` → ISO 8601 date-time string. */
|
|
11
|
+
export const dateTime = () =>
|
|
12
|
+
z.codec(z.date(), z.iso.datetime(), {
|
|
13
|
+
decode: (date) => date.toISOString(),
|
|
14
|
+
encode: (iso) => new Date(iso)
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** `Date` → `YYYY-MM-DD`. */
|
|
18
|
+
export const dateOnly = () =>
|
|
19
|
+
z.codec(z.date(), z.iso.date(), {
|
|
20
|
+
decode: (date) => date.toISOString().slice(0, 10),
|
|
21
|
+
encode: (iso) => new Date(iso)
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/** `Prisma.Decimal` (or a numeric string) → number, rounded to 4 places. */
|
|
25
|
+
export const decimal = () =>
|
|
26
|
+
z.codec(z.union([z.instanceof(Prisma.Decimal), z.string()]), z.number(), {
|
|
27
|
+
decode: (value) => new Prisma.Decimal(value).toDecimalPlaces(4).toNumber(),
|
|
28
|
+
encode: (value) => new Prisma.Decimal(value)
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** An email address, stored and compared in lower case. */
|
|
32
|
+
export const email = () => z.email().toLowerCase();
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Free-text search: at least three characters, with a blank value (a cleared
|
|
36
|
+
* search box sends `?search=`) treated as absent rather than rejected.
|
|
37
|
+
*/
|
|
38
|
+
export const search = () =>
|
|
39
|
+
z
|
|
40
|
+
.union([z.string().trim().min(3), z.literal('')])
|
|
41
|
+
.transform((value) => value || undefined)
|
|
42
|
+
.optional();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A comma-separated sort spec over `keys`, each optionally prefixed with `-`
|
|
46
|
+
* for descending, e.g. `name,-createdAt`.
|
|
47
|
+
*/
|
|
48
|
+
export const sortKeys = (keys: readonly string[]) =>
|
|
49
|
+
z
|
|
50
|
+
.string()
|
|
51
|
+
.refine(
|
|
52
|
+
(value) =>
|
|
53
|
+
value.split(',').every((key) => keys.includes(key.replace(/^-/, ''))),
|
|
54
|
+
{ message: `Sort key must be one of the following: ${keys.join(', ')}` }
|
|
55
|
+
)
|
|
56
|
+
.meta({ example: keys.join(',') })
|
|
57
|
+
.optional();
|
|
58
|
+
|
|
59
|
+
/** A file part in a multipart/form-data body (documentation only). */
|
|
60
|
+
export const binary = () => z.string().meta({ format: 'binary' });
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Require two fields of an object schema to be equal, e.g. a password and its
|
|
64
|
+
* confirmation. The issue is reported on `confirm`.
|
|
65
|
+
*/
|
|
66
|
+
export const mustMatch =
|
|
67
|
+
<T extends Record<string, unknown>>(field: keyof T, confirm: keyof T) =>
|
|
68
|
+
(value: T, ctx: z.RefinementCtx) => {
|
|
69
|
+
if (value[field] !== value[confirm]) {
|
|
70
|
+
ctx.addIssue({
|
|
71
|
+
code: 'custom',
|
|
72
|
+
path: [confirm as string],
|
|
73
|
+
message: `${String(confirm)} must match ${String(field)}`
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fields';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type IoRedis from 'ioredis';
|
|
2
|
+
import { CacheService } from './cache.service';
|
|
3
|
+
|
|
4
|
+
const PREFIX = 'auth:rl';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Count one request against a fixed window and decide whether it is allowed,
|
|
8
|
+
* in a single round-trip. A separate GET + SET would let concurrent requests
|
|
9
|
+
* all read a below-limit count before any increment lands.
|
|
10
|
+
*
|
|
11
|
+
* Denied requests are not counted, so the window is not extended while a
|
|
12
|
+
* client keeps retrying.
|
|
13
|
+
*
|
|
14
|
+
* KEYS: counter. ARGV: window(ms), max.
|
|
15
|
+
* Returns: { allowed(0|1), pttl(ms) } — pttl is only meaningful when denied.
|
|
16
|
+
*/
|
|
17
|
+
const CONSUME_SCRIPT = `
|
|
18
|
+
local key = KEYS[1]
|
|
19
|
+
local window = tonumber(ARGV[1])
|
|
20
|
+
local max = tonumber(ARGV[2])
|
|
21
|
+
|
|
22
|
+
local count = tonumber(redis.call('GET', key)) or 0
|
|
23
|
+
if count >= max then
|
|
24
|
+
local pttl = redis.call('PTTL', key)
|
|
25
|
+
if pttl < 0 then
|
|
26
|
+
-- Key exists without a TTL; re-arm it so the client is not locked out.
|
|
27
|
+
redis.call('PEXPIRE', key, window)
|
|
28
|
+
pttl = window
|
|
29
|
+
end
|
|
30
|
+
return { 0, pttl }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if redis.call('INCR', key) == 1 then
|
|
34
|
+
redis.call('PEXPIRE', key, window)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
return { 1, 0 }
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
type AuthRateLimitRedis = IoRedis & {
|
|
41
|
+
authRateLimitConsume(
|
|
42
|
+
key: string,
|
|
43
|
+
window: number,
|
|
44
|
+
max: number
|
|
45
|
+
): Promise<[number, number]>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Redis-backed storage for better-auth's `/auth/*` rate limiter.
|
|
50
|
+
*
|
|
51
|
+
* Passed as `rateLimit.customStorage` rather than `secondaryStorage`: the latter
|
|
52
|
+
* is also consumed by better-auth's internal adapter for **session** persistence,
|
|
53
|
+
* so setting it would silently relocate sessions out of Postgres. `customStorage`
|
|
54
|
+
* is rate-limit-scoped and takes precedence over `rateLimit.storage`.
|
|
55
|
+
*
|
|
56
|
+
* better-auth passes each rule's `window` in seconds and expects `retryAfter`
|
|
57
|
+
* back in seconds.
|
|
58
|
+
*/
|
|
59
|
+
export const createAuthRateLimitStorage = (cache: CacheService) => {
|
|
60
|
+
const redis = cache.db as AuthRateLimitRedis;
|
|
61
|
+
redis.defineCommand('authRateLimitConsume', {
|
|
62
|
+
numberOfKeys: 1,
|
|
63
|
+
lua: CONSUME_SCRIPT
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
consume: async (key: string, rule: { window: number; max: number }) => {
|
|
68
|
+
const [allowed, pttl] = await redis.authRateLimitConsume(
|
|
69
|
+
`${PREFIX}:${key}`,
|
|
70
|
+
rule.window * 1000,
|
|
71
|
+
rule.max
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return allowed === 1
|
|
75
|
+
? { allowed: true, retryAfter: null }
|
|
76
|
+
: { allowed: false, retryAfter: Math.ceil(pttl / 1000) };
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { AuthService } from '@thallesp/nestjs-better-auth';
|
|
3
|
+
import { BetterAuth } from 'lib/auth';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class CustomAuthService {
|
|
7
|
+
constructor(private readonly auth: AuthService<BetterAuth>) {}
|
|
8
|
+
|
|
9
|
+
get api() {
|
|
10
|
+
return this.auth.api;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get instance() {
|
|
14
|
+
return this.auth;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Injectable, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import IoRedis from 'ioredis';
|
|
3
|
+
import { CustomConfigService } from './config.service';
|
|
4
|
+
import { User } from '@db/client';
|
|
5
|
+
// import { RoleFull } from 'common/types';
|
|
6
|
+
import { Key } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class CacheService implements OnModuleDestroy {
|
|
10
|
+
readonly db: IoRedis;
|
|
11
|
+
readonly DEFAULT_EXPIRY = 86400; // 24 hours
|
|
12
|
+
|
|
13
|
+
constructor(private cfg: CustomConfigService) {
|
|
14
|
+
this.db = new IoRedis({ ...cfg.redis });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async disconnect() {
|
|
18
|
+
await this.db.disconnect();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async onModuleDestroy() {
|
|
22
|
+
await this.db.disconnect();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async truncate() {
|
|
26
|
+
await this.db.flushall();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Delete a plain string key (no-op if it does not exist). */
|
|
30
|
+
async delete(key: string) {
|
|
31
|
+
await this.db.del(key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async store<T = string>(key: string, data: T, exp = this.DEFAULT_EXPIRY) {
|
|
35
|
+
if (typeof data === 'string') {
|
|
36
|
+
await this.db.setex(key, exp, data);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const stringified = JSON.stringify(data);
|
|
41
|
+
await this.db.setex(key, exp, stringified);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async hashStore<T extends { id: string | number }>(
|
|
45
|
+
key: Key.TypeKey,
|
|
46
|
+
item: T
|
|
47
|
+
) {
|
|
48
|
+
await this.db.hset(
|
|
49
|
+
Key.Type[key],
|
|
50
|
+
Key.id(key, item.id),
|
|
51
|
+
JSON.stringify(item)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Atomic counter with a fixed window — returns the count after incrementing.
|
|
57
|
+
* The TTL is set only on first hit, so the window is fixed (not sliding).
|
|
58
|
+
*/
|
|
59
|
+
async incr(key: string, windowSeconds: number): Promise<number> {
|
|
60
|
+
const count = await this.db.incr(key);
|
|
61
|
+
if (count === 1) await this.db.expire(key, windowSeconds);
|
|
62
|
+
return count;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async fetch<T = string>(key: string): Promise<T | null> {
|
|
66
|
+
const cached = await this.db.get(key);
|
|
67
|
+
if (!cached) return null;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(cached) as T;
|
|
71
|
+
} catch {
|
|
72
|
+
return cached as T;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async hashFetch<Key extends Key.TypeKey, ID extends string | number>(
|
|
77
|
+
key: Key,
|
|
78
|
+
id: ID
|
|
79
|
+
): Promise<Key.EntityMap<Key> | null> {
|
|
80
|
+
const result = await this.db.hget(Key.Type[key], Key.id(key, id));
|
|
81
|
+
return result ? (JSON.parse(result) as Key.EntityMap<Key>) : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async hashFetchAll<Key extends Key.TypeKey>(
|
|
85
|
+
key: Key
|
|
86
|
+
): Promise<Key.EntityMap<Key>[]> {
|
|
87
|
+
const result = await this.db.hvals(Key.Type[key]);
|
|
88
|
+
return result.map((item) => JSON.parse(item) as Key.EntityMap<Key>);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async hashDelete<Key extends Key.TypeKey, ID extends string | number>(
|
|
92
|
+
key: Key,
|
|
93
|
+
id: ID
|
|
94
|
+
): Promise<void> {
|
|
95
|
+
await this.db.hdel(Key.Type[key], Key.id(key, id));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async deleteKey(key: Key.TypeKey) {
|
|
99
|
+
await this.db.del(Key.Type[key]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Bulk-load a set of entities into their hash in one round trip. Model new
|
|
104
|
+
* bulk loaders on this — a per-item `hset` in a loop costs one round trip
|
|
105
|
+
* each, which is what the pipeline avoids.
|
|
106
|
+
*/
|
|
107
|
+
async storeUsers(list: User[]) {
|
|
108
|
+
const pipeline = this.db.pipeline();
|
|
109
|
+
for (const item of list) {
|
|
110
|
+
pipeline.hset(
|
|
111
|
+
Key.Type.Users,
|
|
112
|
+
Key.id('Users', item.id),
|
|
113
|
+
JSON.stringify(item)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
await pipeline.exec();
|
|
117
|
+
}
|
|
118
|
+
}
|