@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,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text } from '@react-email/components';
|
|
3
|
+
import { EmailProps, WelcomeData } from 'common/types';
|
|
4
|
+
import MainLayout, { Salutation, CN, CTAButton } from './main-layout';
|
|
5
|
+
|
|
6
|
+
const Welcome = ({
|
|
7
|
+
firstName,
|
|
8
|
+
clientLoginPage,
|
|
9
|
+
...props
|
|
10
|
+
}: EmailProps<WelcomeData>) => {
|
|
11
|
+
return (
|
|
12
|
+
<MainLayout {...props}>
|
|
13
|
+
<Salutation name={firstName} />
|
|
14
|
+
<Text className={CN.text}>
|
|
15
|
+
{
|
|
16
|
+
"Welcome! Your account is all set, and we're excited to have you here. You can now start using the application by clicking the button below."
|
|
17
|
+
}
|
|
18
|
+
</Text>
|
|
19
|
+
|
|
20
|
+
<CTAButton text="Go to your dashboard" url={clientLoginPage} />
|
|
21
|
+
<Text className={CN.text}>
|
|
22
|
+
If the button above doesn't work, copy and paste the link below into
|
|
23
|
+
your browser:
|
|
24
|
+
</Text>
|
|
25
|
+
<Text
|
|
26
|
+
className={`text-xs underline underline-offset-2 text-[#525f7f] select-all break-all`}
|
|
27
|
+
>
|
|
28
|
+
{clientLoginPage}
|
|
29
|
+
</Text>
|
|
30
|
+
<Text className={CN.text}>
|
|
31
|
+
{
|
|
32
|
+
'If you ever need help or have questions, our support team is always happy to assist you.'
|
|
33
|
+
}
|
|
34
|
+
</Text>
|
|
35
|
+
</MainLayout>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Welcome;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
|
|
6
|
+
export default tseslint.config(
|
|
7
|
+
{
|
|
8
|
+
ignores: ['node_modules/', 'dist/', 'coverage/', 'prisma/generated/**']
|
|
9
|
+
},
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
...tseslint.configs.recommended,
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
globals: { ...globals.node, ...globals.vitest }
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
19
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
20
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
21
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
22
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
23
|
+
'@typescript-eslint/no-empty-function': 'off'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
// Last, so Prettier owns formatting and turns off rules that fight it.
|
|
27
|
+
prettierRecommended
|
|
28
|
+
);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@starter/backend",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "API service",
|
|
5
|
+
"private": true,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"packageManager": "yarn@4.14.1",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "ts-node .bin/start.ts",
|
|
10
|
+
"start:prod": "node dist/src/main",
|
|
11
|
+
"build": "nest build",
|
|
12
|
+
"gen": "nest generate",
|
|
13
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
15
|
+
"email:dev": "email dev -p 5003",
|
|
16
|
+
"secrets": "ts-node .bin/secrets",
|
|
17
|
+
"db:generate": "ts-node ./.bin/db.ts",
|
|
18
|
+
"db:push": "ts-node ./.bin/db.ts -c push",
|
|
19
|
+
"db:migrate:create": "prisma migrate dev --create-only",
|
|
20
|
+
"db:migrate": "prisma migrate dev",
|
|
21
|
+
"db:migrate:prod": "prisma migrate deploy",
|
|
22
|
+
"db:seed": "ts-node ./.bin/db.ts -c seed",
|
|
23
|
+
"db:reset": "ts-node ./.bin/db.ts -c reset",
|
|
24
|
+
"db:studio": "ts-node ./.bin/db.ts -c studio",
|
|
25
|
+
"test:db:generate": "ts-node ./.bin/db.ts -e test",
|
|
26
|
+
"test:db:push": "ts-node ./.bin/db.ts -c push -e test",
|
|
27
|
+
"test:db:seed": "ts-node ./.bin/db.ts -c seed -e test",
|
|
28
|
+
"test": "dotenv -e .env.test -- vitest run --project unit",
|
|
29
|
+
"test:watch": "dotenv -e .env.test -- vitest --project unit",
|
|
30
|
+
"test:ui": "dotenv -e .env.test -- vitest --ui --project unit",
|
|
31
|
+
"test:e2e": "dotenv -e .env.test -- vitest run --project e2e",
|
|
32
|
+
"test:e2e:watch": "dotenv -e .env.test -- vitest --project e2e",
|
|
33
|
+
"test:e2e:ui": "dotenv -e .env.test -- vitest --ui --project e2e",
|
|
34
|
+
"test:cov": "dotenv -e .env.test -- vitest --coverage",
|
|
35
|
+
"test:all": "dotenv -e .env.test -- vitest run",
|
|
36
|
+
"test:all:ui": "dotenv -e .env.test -- vitest --ui",
|
|
37
|
+
"dc:up": "ts-node ./.bin/dc.ts -c up",
|
|
38
|
+
"dc:down": "ts-node ./.bin/dc.ts -c down",
|
|
39
|
+
"dc:wait": "ts-node ./.bin/dc.ts -c wait",
|
|
40
|
+
"dc:recreate": "ts-node ./.bin/dc.ts -c recreate",
|
|
41
|
+
"dc:reinstall": "yarn dc:recreate && yarn db:generate && yarn db:migrate && yarn db:seed",
|
|
42
|
+
"test:dc:up": "ts-node ./.bin/dc.ts -c up -e test",
|
|
43
|
+
"test:dc:wait": "ts-node ./.bin/dc.ts -c wait -e test",
|
|
44
|
+
"test:dc:down": "ts-node ./.bin/dc.ts -c down -e test",
|
|
45
|
+
"test:dc:recreate": "ts-node ./.bin/dc.ts -c recreate -e test",
|
|
46
|
+
"test:dc:reinstall": "yarn test:dc:recreate && yarn test:db:generate && yarn test:db:push && yarn test:db:seed",
|
|
47
|
+
"down": "yarn dc:down && yarn test:dc:down",
|
|
48
|
+
"reinstall": "yarn dc:reinstall && yarn test:dc:reinstall"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@apollo/server": "^5.5.1",
|
|
52
|
+
"@as-integrations/express5": "^1.1.2",
|
|
53
|
+
"@aws-sdk/client-s3": "^3.1013.0",
|
|
54
|
+
"@bull-board/api": "^9.10.1",
|
|
55
|
+
"@bull-board/express": "^9.10.1",
|
|
56
|
+
"@bull-board/nestjs": "^9.10.1",
|
|
57
|
+
"@faker-js/faker": "^8.0.2",
|
|
58
|
+
"@growthbook/growthbook": "^1.6.5",
|
|
59
|
+
"@nestjs-modules/mailer": "^2.3.7",
|
|
60
|
+
"@nestjs/apollo": "^14.0.2",
|
|
61
|
+
"@nestjs/axios": "^12.0.1",
|
|
62
|
+
"@nestjs/bullmq": "^12.0.0",
|
|
63
|
+
"@nestjs/common": "^12.1.0",
|
|
64
|
+
"@nestjs/config": "^12.0.1",
|
|
65
|
+
"@nestjs/core": "^12.1.0",
|
|
66
|
+
"@nestjs/graphql": "^14.0.2",
|
|
67
|
+
"@nestjs/platform-express": "^12.1.0",
|
|
68
|
+
"@nestjs/platform-socket.io": "^12.1.0",
|
|
69
|
+
"@nestjs/schedule": "^12.0.2",
|
|
70
|
+
"@nestjs/swagger": "^12.0.2",
|
|
71
|
+
"@nestjs/terminus": "^12.1.0",
|
|
72
|
+
"@nestjs/throttler": "^6.7.1",
|
|
73
|
+
"@nestjs/websockets": "^12.1.0",
|
|
74
|
+
"@paralleldrive/cuid2": "^3.3.0",
|
|
75
|
+
"@prisma/adapter-pg": "^7.4.2",
|
|
76
|
+
"@prisma/client": "^7.4.2",
|
|
77
|
+
"@react-email/components": "^0.0.7",
|
|
78
|
+
"@react-email/render": "^0.0.7",
|
|
79
|
+
"@scalar/nestjs-api-reference": "^1.2.22",
|
|
80
|
+
"@socket.io/redis-adapter": "^8",
|
|
81
|
+
"@thallesp/nestjs-better-auth": "^2.8.0",
|
|
82
|
+
"@willsoto/nestjs-prometheus": "^6.1.1",
|
|
83
|
+
"axios": "^1.4.0",
|
|
84
|
+
"better-auth": "^1.7.6",
|
|
85
|
+
"bullmq": "^5.79.2",
|
|
86
|
+
"express": "^5.2.1",
|
|
87
|
+
"express-basic-auth": "^1.2.1",
|
|
88
|
+
"graphql": "^16.12.0",
|
|
89
|
+
"helmet": "^7.0.0",
|
|
90
|
+
"ioredis": "^5.4.1",
|
|
91
|
+
"moment": "^2.29.4",
|
|
92
|
+
"nestjs-pino": "^5.2.0",
|
|
93
|
+
"nodemailer": "^8.0.11",
|
|
94
|
+
"pino": "^10.3.1",
|
|
95
|
+
"pino-http": "^11.0.0",
|
|
96
|
+
"prom-client": "^15.1.3",
|
|
97
|
+
"randomstring": "^1.3.0",
|
|
98
|
+
"react": "^18.2.0",
|
|
99
|
+
"react-email": "^1.9.4",
|
|
100
|
+
"reflect-metadata": "^0.1.13",
|
|
101
|
+
"rxjs": "^7.8.1",
|
|
102
|
+
"shelljs": "^0.10.0",
|
|
103
|
+
"socket.io": "4.8.3",
|
|
104
|
+
"uuid": "^13.0.0",
|
|
105
|
+
"yargs": "^18.0.0",
|
|
106
|
+
"zod": "^4.6.5"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@eslint/js": "^10.0.1",
|
|
110
|
+
"@golevelup/ts-vitest": "^2.2.0",
|
|
111
|
+
"@nestjs/cli": "^12.0.6",
|
|
112
|
+
"@nestjs/schematics": "^12.0.5",
|
|
113
|
+
"@nestjs/testing": "^12.1.0",
|
|
114
|
+
"@suites/di.nestjs": "^3.0.1",
|
|
115
|
+
"@suites/doubles.vitest": "^3.0.1",
|
|
116
|
+
"@suites/unit": "^3.0.1",
|
|
117
|
+
"@swc/core": "^1.15.18",
|
|
118
|
+
"@types/express": "^5.0.6",
|
|
119
|
+
"@types/multer": "^1.4.7",
|
|
120
|
+
"@types/node": "^25.0.9",
|
|
121
|
+
"@types/nodemailer": "^8.0.2",
|
|
122
|
+
"@types/randomstring": "^1.1.8",
|
|
123
|
+
"@types/react": "^18.2.14",
|
|
124
|
+
"@types/shelljs": "^0.10.0",
|
|
125
|
+
"@types/supertest": "^2.0.12",
|
|
126
|
+
"@types/yargs": "^17.0.35",
|
|
127
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
128
|
+
"@vitest/ui": "^4.1.11",
|
|
129
|
+
"cross-env": "^7.0.3",
|
|
130
|
+
"dotenv-cli": "^7.2.1",
|
|
131
|
+
"eslint": "^10.11.0",
|
|
132
|
+
"eslint-config-prettier": "^10.1.8",
|
|
133
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
134
|
+
"fishery": "^2.2.2",
|
|
135
|
+
"globals": "^17.12.0",
|
|
136
|
+
"pino-pretty": "^13.1.3",
|
|
137
|
+
"prettier": "^3.9.9",
|
|
138
|
+
"prisma": "^7.4.2",
|
|
139
|
+
"prisma-dbml-generator": "^0.12.0",
|
|
140
|
+
"source-map-support": "^0.5.21",
|
|
141
|
+
"supertest": "^6.3.3",
|
|
142
|
+
"ts-loader": "^9.4.3",
|
|
143
|
+
"ts-node": "^10.9.2",
|
|
144
|
+
"tsconfig-paths": "^4.2.0",
|
|
145
|
+
"typescript": "~6.0.3",
|
|
146
|
+
"typescript-eslint": "^8.70.1",
|
|
147
|
+
"unplugin-swc": "^1.5.9",
|
|
148
|
+
"vitest": "^4.1.11"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
model User {
|
|
2
|
+
id String @id(map: "user_pk")
|
|
3
|
+
name String
|
|
4
|
+
email String
|
|
5
|
+
emailVerified Boolean @default(false) @map("email_verified")
|
|
6
|
+
image String?
|
|
7
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
8
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
9
|
+
role String?
|
|
10
|
+
banned Boolean? @default(false)
|
|
11
|
+
banReason String? @map("ban_reason")
|
|
12
|
+
banExpires DateTime? @map("ban_expires")
|
|
13
|
+
/// Set once the user finishes onboarding. Declared as a better-auth
|
|
14
|
+
/// additionalField with `input: false`, so it rides on the session but a
|
|
15
|
+
/// client cannot set it for itself.
|
|
16
|
+
onboardingCompletedAt DateTime? @map("onboarding_completed_at")
|
|
17
|
+
|
|
18
|
+
sessions Session[]
|
|
19
|
+
accounts Account[]
|
|
20
|
+
notifications Notification[] // @feature notifications
|
|
21
|
+
|
|
22
|
+
@@unique([email], map: "user_email_idx")
|
|
23
|
+
@@map("user")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
model Session {
|
|
27
|
+
id String @id(map: "session_pk")
|
|
28
|
+
expiresAt DateTime @map("expires_at")
|
|
29
|
+
token String
|
|
30
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
31
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
32
|
+
ipAddress String? @map("ip_address")
|
|
33
|
+
userAgent String? @map("user_agent")
|
|
34
|
+
userId String @map("user_id")
|
|
35
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "session_user_fk")
|
|
36
|
+
impersonatedBy String? @map("impersonated_by")
|
|
37
|
+
|
|
38
|
+
@@unique([token], map: "session_token_idx")
|
|
39
|
+
@@index([userId], map: "session_user_id_idx")
|
|
40
|
+
@@map("session")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
model Account {
|
|
44
|
+
id String @id(map: "account_pk")
|
|
45
|
+
accountId String @map("account_id")
|
|
46
|
+
providerId String @map("provider_id")
|
|
47
|
+
userId String @map("user_id")
|
|
48
|
+
accessToken String? @map("access_token")
|
|
49
|
+
refreshToken String? @map("refresh_token")
|
|
50
|
+
idToken String? @map("id_token")
|
|
51
|
+
accessTokenExpiresAt DateTime? @map("access_token_expires_at")
|
|
52
|
+
refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
|
|
53
|
+
scope String?
|
|
54
|
+
password String?
|
|
55
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
56
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
57
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "account_user_fk")
|
|
58
|
+
|
|
59
|
+
@@index([userId], map: "account_user_idx")
|
|
60
|
+
@@index(providerId, map: "account_provider_idx")
|
|
61
|
+
@@index([accountId], map: "account_account_idx")
|
|
62
|
+
@@map("account")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
model Verification {
|
|
66
|
+
id String @id(map: "verification_pk")
|
|
67
|
+
identifier String
|
|
68
|
+
value String
|
|
69
|
+
expiresAt DateTime @map("expires_at")
|
|
70
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
71
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
72
|
+
|
|
73
|
+
@@index([identifier], map: "verification_identifier_idx")
|
|
74
|
+
@@map("verification")
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
datasource db {
|
|
2
|
+
provider = "postgresql"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
generator client {
|
|
6
|
+
provider = "prisma-client"
|
|
7
|
+
output = "../generated"
|
|
8
|
+
moduleFormat = "cjs"
|
|
9
|
+
previewFeatures = ["views", "fullTextSearchPostgres"]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generator dbml {
|
|
13
|
+
provider = "prisma-dbml-generator"
|
|
14
|
+
output = "../"
|
|
15
|
+
projectName = "AcmeCorp"
|
|
16
|
+
projectDatabaseType = "PostgreSQL"
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
enum Gender {
|
|
2
|
+
male
|
|
3
|
+
female
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// @feature:start notifications
|
|
7
|
+
/// Every kind of notification the app can raise. Extend this enum and the
|
|
8
|
+
/// producer's `NotificationsService.dispatch` call together — a value here with
|
|
9
|
+
/// no producer is dead, and a producer with no value will not compile.
|
|
10
|
+
enum NotificationType {
|
|
11
|
+
system
|
|
12
|
+
mention
|
|
13
|
+
comment
|
|
14
|
+
reply
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// @feature:end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
model Notification {
|
|
2
|
+
id String @id(map: "notifications_pk") @default(cuid())
|
|
3
|
+
userId String @map("user_id")
|
|
4
|
+
type NotificationType
|
|
5
|
+
data Json
|
|
6
|
+
readAt DateTime? @map("read_at")
|
|
7
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
8
|
+
|
|
9
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade, map: "notifications_user_fk")
|
|
10
|
+
|
|
11
|
+
@@index([userId, readAt], map: "notifications_user_read_idx")
|
|
12
|
+
@@index([userId, createdAt], map: "notifications_user_created_idx")
|
|
13
|
+
@@map("notifications")
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { defineConfig } from 'prisma/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
schema: 'prisma/schema',
|
|
6
|
+
migrations: {
|
|
7
|
+
path: 'prisma/migrations',
|
|
8
|
+
seed: 'ts-node seeders'
|
|
9
|
+
},
|
|
10
|
+
datasource: {
|
|
11
|
+
url: process.env['DATABASE_URL']
|
|
12
|
+
}
|
|
13
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { PrismaPg } from '@prisma/adapter-pg';
|
|
3
|
+
import { PrismaClient } from '../prisma/generated/client';
|
|
4
|
+
import Seeder from './util';
|
|
5
|
+
|
|
6
|
+
const prisma = new PrismaClient({
|
|
7
|
+
adapter: new PrismaPg({
|
|
8
|
+
connectionString: process.env.DATABASE_URL
|
|
9
|
+
})
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
const env = process.env.APP_ENV;
|
|
14
|
+
const email = process.env.SUPERUSER_EMAIL;
|
|
15
|
+
const password = process.env.SUPERUSER_PASSWORD;
|
|
16
|
+
if (!email || !password) {
|
|
17
|
+
throw Error('Missing admin credentials');
|
|
18
|
+
}
|
|
19
|
+
await Seeder.setup(prisma).seed({ email, password }, env === 'test');
|
|
20
|
+
})()
|
|
21
|
+
.catch((e) => {
|
|
22
|
+
console.error(e);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
})
|
|
25
|
+
.finally(async () => {
|
|
26
|
+
await prisma.$disconnect();
|
|
27
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { auth } from '../src/lib/auth';
|
|
3
|
+
import { PrismaClient } from '../prisma/generated/client';
|
|
4
|
+
|
|
5
|
+
interface Admin {
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Database seeder.
|
|
12
|
+
*
|
|
13
|
+
* Users are created through better-auth's own API rather than by inserting rows
|
|
14
|
+
* directly — password hashing, account linking and role assignment all live
|
|
15
|
+
* there, and a hand-written `user` row cannot sign in.
|
|
16
|
+
*
|
|
17
|
+
* Add reference-data seeds as private methods and call them from `seed()`.
|
|
18
|
+
* Anything only tests need goes behind the `isTest` flag.
|
|
19
|
+
*/
|
|
20
|
+
class Seeder {
|
|
21
|
+
private constructor(private readonly db: PrismaClient) {}
|
|
22
|
+
|
|
23
|
+
get instance() {
|
|
24
|
+
return this.db;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static setup(db: PrismaClient) {
|
|
28
|
+
return new Seeder(db);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async seed(admin: Admin, isTest = false) {
|
|
32
|
+
await this.seedSuperuser(admin);
|
|
33
|
+
|
|
34
|
+
if (isTest) {
|
|
35
|
+
await this.seedTestUsers();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private async seedSuperuser(admin: Admin) {
|
|
40
|
+
await auth.api.createUser({
|
|
41
|
+
body: {
|
|
42
|
+
name: 'Super User',
|
|
43
|
+
email: admin.email,
|
|
44
|
+
password: admin.password,
|
|
45
|
+
role: 'superuser'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
await this.db.user.update({
|
|
49
|
+
where: { email: admin.email },
|
|
50
|
+
data: { emailVerified: true }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private async seedTestUsers() {
|
|
55
|
+
const users = [
|
|
56
|
+
{
|
|
57
|
+
name: 'Test Admin',
|
|
58
|
+
email: 'test.admin@example.com',
|
|
59
|
+
password: 'secret',
|
|
60
|
+
role: 'admin' as const
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Test User',
|
|
64
|
+
email: 'test.user@example.com',
|
|
65
|
+
password: 'secret',
|
|
66
|
+
role: 'user' as const
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
for (const user of users) {
|
|
71
|
+
await auth.api.createUser({
|
|
72
|
+
body: {
|
|
73
|
+
name: user.name,
|
|
74
|
+
email: user.email,
|
|
75
|
+
password: user.password,
|
|
76
|
+
role: user.role
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await this.db.user.updateMany({
|
|
82
|
+
where: { email: { in: users.map((u) => u.email) } },
|
|
83
|
+
data: { emailVerified: true }
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default Seeder;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TestBed } from '@suites/unit';
|
|
2
|
+
import { SWAGGER_OPTIONS } from 'common/constants';
|
|
3
|
+
import { AppController } from 'app.controller';
|
|
4
|
+
|
|
5
|
+
describe('AppController', () => {
|
|
6
|
+
let controller: AppController;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
const { unit } = await TestBed.solitary(AppController).compile();
|
|
10
|
+
controller = unit;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be defined', () => {
|
|
14
|
+
expect(controller).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should return an object with title and description properties', () => {
|
|
18
|
+
const result = controller.index();
|
|
19
|
+
expect(result).toHaveProperty('title');
|
|
20
|
+
expect(result).toHaveProperty('description');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should use the SWAGGER_OPTIONS constant to retrieve the title and description', () => {
|
|
24
|
+
const result = controller.index();
|
|
25
|
+
const { info } = SWAGGER_OPTIONS;
|
|
26
|
+
expect(result.title).toBe(info.title);
|
|
27
|
+
expect(result.description).toBe(info.description);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Controller, Get, Version, VERSION_NEUTRAL } from '@nestjs/common';
|
|
2
|
+
import { Throttle } from '@nestjs/throttler'; // @feature rate-limit
|
|
3
|
+
import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger';
|
|
4
|
+
import { AllowAnonymous } from '@thallesp/nestjs-better-auth';
|
|
5
|
+
import { SWAGGER_OPTIONS } from 'common/constants';
|
|
6
|
+
import { Op } from 'common/decorators';
|
|
7
|
+
|
|
8
|
+
@ApiTags('App')
|
|
9
|
+
@Controller()
|
|
10
|
+
export class AppController {
|
|
11
|
+
@Get()
|
|
12
|
+
@ApiExcludeEndpoint()
|
|
13
|
+
@Op('index', '/', 'Get basic information about the API')
|
|
14
|
+
@Version(VERSION_NEUTRAL)
|
|
15
|
+
@AllowAnonymous()
|
|
16
|
+
index() {
|
|
17
|
+
const { info } = SWAGGER_OPTIONS;
|
|
18
|
+
return {
|
|
19
|
+
title: info.title,
|
|
20
|
+
description: info.description
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// @feature:start rate-limit
|
|
25
|
+
/**
|
|
26
|
+
* Demonstrates a per-route limit tighter than the global default. Tighten a
|
|
27
|
+
* route with `@Throttle({ default: { limit, ttl } })`; exempt one with
|
|
28
|
+
* `@SkipThrottle()`. Note the TTL is in **milliseconds**.
|
|
29
|
+
*/
|
|
30
|
+
@Get('ping')
|
|
31
|
+
@ApiExcludeEndpoint()
|
|
32
|
+
@Op('ping', '/ping', 'Liveness probe with a per-route rate limit')
|
|
33
|
+
@Version(VERSION_NEUTRAL)
|
|
34
|
+
@AllowAnonymous()
|
|
35
|
+
@Throttle({ default: { limit: 30, ttl: 60_000 } })
|
|
36
|
+
ping() {
|
|
37
|
+
return { ok: true };
|
|
38
|
+
}
|
|
39
|
+
// @feature:end
|
|
40
|
+
}
|