create-huenei-template 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/templates.js +7 -0
- package/dist/templates/README.md +7 -1
- package/dist/templates/backend/README.md +19 -9
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/dist/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/dist/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/dist/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/dist/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/dist/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/dist/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/dist/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/dist/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/dist/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/dist/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/dist/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/dist/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/dist/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/dist/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/dist/templates/frontend/react-vite/README.md +34 -34
- package/dist/templates/frontend/react-vite/package.json +82 -82
- package/dist/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/dist/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/dist/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/dist/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/dist/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/dist/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/dist/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/dist/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/dist/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/dist/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/dist/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/dist/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/dist/templates/frontend/react-vite/vite.config.ts +2 -2
- package/dist/templates/frontend/react-vite/vitest.config.ts +13 -2
- package/package.json +1 -1
- package/templates/README.md +7 -1
- package/templates/backend/README.md +19 -9
- package/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/templates/backend/nestjs-api-mysql/dist/tsconfig.build.tsbuildinfo +1 -1
- package/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/templates/frontend/react-vite/README.md +34 -34
- package/templates/frontend/react-vite/package.json +82 -82
- package/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/templates/frontend/react-vite/vite.config.ts +2 -2
- package/templates/frontend/react-vite/vitest.config.ts +13 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
interface BeforeShellPayload {
|
|
2
|
+
command: string;
|
|
3
|
+
cwd: string;
|
|
4
|
+
workspace_roots: string[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function readStdin(): Promise<string> {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
let data = "";
|
|
11
|
+
process.stdin.setEncoding("utf8");
|
|
12
|
+
process.stdin.on("data", (chunk: string) => {
|
|
13
|
+
data += chunk;
|
|
14
|
+
});
|
|
15
|
+
process.stdin.on("end", () => resolve(data));
|
|
16
|
+
process.stdin.on("error", () => resolve(""));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function respond(output: Record<string, unknown>): void {
|
|
21
|
+
process.stdout.write(JSON.stringify(output) + "\n");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const DENY_PATTERNS: Array<{ pattern: RegExp; label: string }> = [
|
|
25
|
+
{
|
|
26
|
+
pattern: /prisma\s+migrate\s+reset/,
|
|
27
|
+
label: "prisma migrate reset (destruye todos los datos de SQL Server)",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
pattern: /prisma\s+db\s+push\s+--force-reset/,
|
|
31
|
+
label: "prisma db push --force-reset (recrea la DB desde cero)",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
pattern: /prisma\s+db\s+execute/,
|
|
35
|
+
label: "prisma db execute (SQL arbitrario contra la DB)",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const ASK_PATTERNS: Array<{ pattern: RegExp; label: string }> = [
|
|
40
|
+
{
|
|
41
|
+
pattern: /prisma\s+migrate\s+dev/,
|
|
42
|
+
label: "prisma migrate dev (puede modificar el schema de SQL Server)",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: /prisma\s+db\s+push(?!\s+--force-reset)/,
|
|
46
|
+
label: "prisma db push (sincroniza schema sin migraciones)",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: /prisma\s+db\s+seed/,
|
|
50
|
+
label: "prisma db seed (ejecuta el script de seed)",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const SAFE_PATTERNS: RegExp[] = [
|
|
55
|
+
/prisma\s+generate/,
|
|
56
|
+
/prisma\s+studio/,
|
|
57
|
+
/prisma\s+format/,
|
|
58
|
+
/prisma\s+validate/,
|
|
59
|
+
/prisma\s+--version/,
|
|
60
|
+
/prisma\s+--help/,
|
|
61
|
+
/prisma\s+init/,
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
async function main(): Promise<void> {
|
|
65
|
+
try {
|
|
66
|
+
const raw = await readStdin();
|
|
67
|
+
if (!raw?.trim()) {
|
|
68
|
+
respond({ permission: "allow" });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const payload = JSON.parse(
|
|
73
|
+
raw.replace(/^\uFEFF/, "").trim(),
|
|
74
|
+
) as BeforeShellPayload;
|
|
75
|
+
const { command } = payload;
|
|
76
|
+
if (!command) {
|
|
77
|
+
respond({ permission: "allow" });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const safe of SAFE_PATTERNS) {
|
|
82
|
+
if (safe.test(command)) {
|
|
83
|
+
respond({ permission: "allow" });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const { pattern, label } of DENY_PATTERNS) {
|
|
89
|
+
if (pattern.test(command)) {
|
|
90
|
+
respond({
|
|
91
|
+
permission: "deny",
|
|
92
|
+
user_message: `Comando Prisma bloqueado: ${label}`,
|
|
93
|
+
agent_message: `El comando '${command}' fue bloqueado porque es destructivo ('${label}'). Si realmente necesitás ejecutarlo, pedile al usuario que lo haga manualmente en la terminal.`,
|
|
94
|
+
});
|
|
95
|
+
console.error(`[validatePrisma] Bloqueado: ${label}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (const { pattern, label } of ASK_PATTERNS) {
|
|
101
|
+
if (pattern.test(command)) {
|
|
102
|
+
respond({
|
|
103
|
+
permission: "ask",
|
|
104
|
+
user_message: `Comando Prisma requiere confirmación: ${label}`,
|
|
105
|
+
});
|
|
106
|
+
console.error(`[validatePrisma] Requiere confirmación: ${label}`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
respond({ permission: "allow" });
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error(
|
|
114
|
+
"[validatePrisma] Error:",
|
|
115
|
+
err instanceof Error ? err.message : String(err),
|
|
116
|
+
);
|
|
117
|
+
respond({ permission: "allow" });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
main();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"hooks": {
|
|
4
|
+
"sessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"command": "npx tsx .cursor/hooks/sessionInit.ts",
|
|
7
|
+
"timeout": 15
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"afterFileEdit": [
|
|
11
|
+
{
|
|
12
|
+
"command": "npx tsx .cursor/hooks/ensureTestsExist.ts",
|
|
13
|
+
"timeout": 15
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"command": "npx tsx .cursor/hooks/formatOnEdit.ts",
|
|
17
|
+
"timeout": 10
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"beforeShellExecution": [
|
|
21
|
+
{
|
|
22
|
+
"command": "npx tsx .cursor/hooks/blockDangerous.ts",
|
|
23
|
+
"matcher": "rm|del|rmdir|drop|truncate|format|mkfs|Remove-Item",
|
|
24
|
+
"timeout": 5
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"command": "npx tsx .cursor/hooks/validatePrisma.ts",
|
|
28
|
+
"matcher": "prisma",
|
|
29
|
+
"timeout": 5
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"beforeReadFile": [
|
|
33
|
+
{
|
|
34
|
+
"command": "npx tsx .cursor/hooks/protectSecrets.ts",
|
|
35
|
+
"timeout": 5
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"stop": [
|
|
39
|
+
{
|
|
40
|
+
"command": "npx tsx .cursor/hooks/autoTestOnStop.ts",
|
|
41
|
+
"timeout": 10,
|
|
42
|
+
"loop_limit": 2
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: REST API architecture and technical standards for modern TypeScript applications
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# REST API - Architecture & Standards
|
|
7
|
+
|
|
8
|
+
## Primary Goal
|
|
9
|
+
|
|
10
|
+
Build **production-ready, scalable REST APIs** using modern TypeScript technologies with enterprise-grade quality, security, and maintainability.
|
|
11
|
+
|
|
12
|
+
## Core Technical Stack
|
|
13
|
+
|
|
14
|
+
### Backend Framework
|
|
15
|
+
- **NestJS 11**: Progressive Node.js framework with TypeScript-first approach
|
|
16
|
+
- **Fastify**: High-performance HTTP server optimized for speed
|
|
17
|
+
- **TypeScript**: Strict type safety throughout the application
|
|
18
|
+
|
|
19
|
+
### Data Layer
|
|
20
|
+
- **Prisma ORM**: Type-safe database access with excellent developer experience
|
|
21
|
+
- **SQL Server Database**: Use SQL Server for all environments (dev via Docker, production via hosted service)
|
|
22
|
+
- **Migration system**: Version-controlled database schema changes
|
|
23
|
+
|
|
24
|
+
### Security & Authentication
|
|
25
|
+
- **JWT Authentication**: Stateless token-based authentication
|
|
26
|
+
- **Role-Based Access Control (RBAC)**: Granular permission system
|
|
27
|
+
- **Password Security**: bcrypt hashing, secure credential storage
|
|
28
|
+
|
|
29
|
+
## Architecture Principles
|
|
30
|
+
|
|
31
|
+
### 1. Modular Design
|
|
32
|
+
- **Feature-based modules**: Each domain (auth, users, posts) in isolated modules
|
|
33
|
+
- **Clear boundaries**: Well-defined interfaces between modules
|
|
34
|
+
- **Dependency injection**: Loose coupling, easy testing
|
|
35
|
+
- **Single Responsibility**: Each module handles one domain concern
|
|
36
|
+
|
|
37
|
+
### 2. Layered Architecture
|
|
38
|
+
```
|
|
39
|
+
Controllers (HTTP Layer)
|
|
40
|
+
↓
|
|
41
|
+
Services (Business Logic)
|
|
42
|
+
↓
|
|
43
|
+
Repositories/Prisma (Data Access)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Type Safety & Validation
|
|
47
|
+
- **End-to-end TypeScript**: From request to database to response
|
|
48
|
+
- **DTOs with decorators**: class-validator for automatic validation
|
|
49
|
+
- **Prisma types**: Auto-generated, type-safe database models
|
|
50
|
+
- **No implicit any**: Strict TypeScript configuration
|
|
51
|
+
|
|
52
|
+
### 4. API Documentation
|
|
53
|
+
- **Swagger/OpenAPI**: Auto-generated, always up-to-date
|
|
54
|
+
- **Decorator-based**: Documentation as code (@ApiProperty, @ApiOperation)
|
|
55
|
+
- **Interactive UI**: Available at `/docs` endpoint
|
|
56
|
+
- **Schema validation**: DTO definitions visible in Swagger
|
|
57
|
+
|
|
58
|
+
### 5. Security by Design
|
|
59
|
+
- **Protected by default**: All endpoints require authentication unless explicitly public
|
|
60
|
+
- **JWT Guards**: Automatic token validation
|
|
61
|
+
- **CORS configuration**: Secure cross-origin policies
|
|
62
|
+
- **Input validation**: All incoming data validated against DTOs
|
|
63
|
+
- **Error sanitization**: No sensitive data in error responses
|
|
64
|
+
|
|
65
|
+
## Development Standards
|
|
66
|
+
|
|
67
|
+
### Code Quality
|
|
68
|
+
- **ESLint**: Enforced coding standards
|
|
69
|
+
- **Prettier**: Consistent code formatting
|
|
70
|
+
- **Type safety**: No `any` types without explicit justification
|
|
71
|
+
- **Error handling**: Proper try-catch blocks with typed errors
|
|
72
|
+
|
|
73
|
+
### Database Practices
|
|
74
|
+
- **Migrations**: All schema changes through Prisma migrations
|
|
75
|
+
- **Seeding**: Automated test data creation for development
|
|
76
|
+
- **Relations**: Proper foreign keys and cascade rules
|
|
77
|
+
- **Indexes**: Performance-optimized queries
|
|
78
|
+
|
|
79
|
+
### API Design
|
|
80
|
+
- **RESTful conventions**: Standard HTTP methods (GET, POST, PATCH, DELETE)
|
|
81
|
+
- **HTTP status codes**: Semantic response codes (200, 201, 400, 401, 404, etc.)
|
|
82
|
+
- **Consistent naming**: kebab-case for URLs, camelCase for JSON
|
|
83
|
+
- **Versioning ready**: API structure prepared for future versions
|
|
84
|
+
|
|
85
|
+
### Developer Experience
|
|
86
|
+
- **Hot reload**: Fast development cycle with watch mode
|
|
87
|
+
- **Auto-seeding**: Pre-populated test data on startup
|
|
88
|
+
- **Health checks**: `/health` endpoint for monitoring
|
|
89
|
+
- **Clear error messages**: Helpful validation errors
|
|
90
|
+
|
|
91
|
+
## Production Readiness
|
|
92
|
+
|
|
93
|
+
### Performance
|
|
94
|
+
- **Fastify speed**: High-throughput HTTP handling
|
|
95
|
+
- **Prisma optimization**: Efficient database queries
|
|
96
|
+
- **Connection pooling**: Managed database connections
|
|
97
|
+
- **Async operations**: Non-blocking I/O throughout
|
|
98
|
+
|
|
99
|
+
### Scalability
|
|
100
|
+
- **Stateless design**: Horizontal scaling capable
|
|
101
|
+
- **Database flexibility**: Easy migration to production databases
|
|
102
|
+
- **Modular growth**: New features as independent modules
|
|
103
|
+
- **Resource efficiency**: Optimized memory and CPU usage
|
|
104
|
+
|
|
105
|
+
### Monitoring & Debugging
|
|
106
|
+
- **Logging**: Structured application logs
|
|
107
|
+
- **Error tracking**: Proper error propagation and handling
|
|
108
|
+
- **Health endpoints**: System status monitoring
|
|
109
|
+
- **Swagger docs**: Runtime API exploration
|
|
110
|
+
|
|
111
|
+
### Testing
|
|
112
|
+
- **Jest framework**: Unit and integration tests
|
|
113
|
+
- **E2E testing**: Full request-response cycle tests
|
|
114
|
+
- **Test coverage**: Comprehensive test suite capability
|
|
115
|
+
- **Mocking support**: Easy dependency mocking
|
|
116
|
+
|
|
117
|
+
## Quality Standards
|
|
118
|
+
|
|
119
|
+
✅ **Type Safety**: 100% TypeScript coverage, no implicit any
|
|
120
|
+
✅ **Validation**: All inputs validated with class-validator
|
|
121
|
+
✅ **Documentation**: All endpoints documented in Swagger
|
|
122
|
+
✅ **Security**: Authentication, authorization, input sanitization
|
|
123
|
+
✅ **Error Handling**: Proper HTTP codes and error responses
|
|
124
|
+
✅ **Code Quality**: ESLint/Prettier compliance
|
|
125
|
+
✅ **Database Integrity**: Migrations, relations, constraints
|
|
126
|
+
✅ **Performance**: Fastify optimizations, efficient queries
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: JWT authentication and security patterns
|
|
3
|
+
globs: src/auth/**/*.ts
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Authentication & Security Standards
|
|
8
|
+
|
|
9
|
+
## JWT Guard Protection
|
|
10
|
+
|
|
11
|
+
Protected endpoints MUST use `@UseGuards(JwtAuthGuard)`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// ❌ BAD - Unprotected endpoint
|
|
15
|
+
@Get('me')
|
|
16
|
+
async getCurrentUser(@Request() req) {
|
|
17
|
+
return req.user;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ✅ GOOD - Protected with JWT
|
|
21
|
+
@UseGuards(JwtAuthGuard)
|
|
22
|
+
@ApiBearerAuth('JWT-auth')
|
|
23
|
+
@Get('me')
|
|
24
|
+
async getCurrentUser(@Request() req) {
|
|
25
|
+
return req.user;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Swagger Security Documentation
|
|
30
|
+
|
|
31
|
+
Protected endpoints MUST be marked with `@ApiBearerAuth()`:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
@UseGuards(JwtAuthGuard)
|
|
35
|
+
@ApiBearerAuth('JWT-auth') // Required for Swagger
|
|
36
|
+
@Get('protected')
|
|
37
|
+
async protectedRoute() {
|
|
38
|
+
// ...
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Password Handling
|
|
43
|
+
|
|
44
|
+
- Never return passwords in responses
|
|
45
|
+
- Always hash passwords before storing
|
|
46
|
+
- Use bcrypt or similar for hashing
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// ❌ BAD - Plain text password
|
|
50
|
+
const user = await this.prisma.user.create({
|
|
51
|
+
data: { password: dto.password }
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// ✅ GOOD - Hashed password
|
|
55
|
+
const hashedPassword = await bcrypt.hash(dto.password, 10);
|
|
56
|
+
const user = await this.prisma.user.create({
|
|
57
|
+
data: { password: hashedPassword }
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## User Context
|
|
62
|
+
|
|
63
|
+
Access authenticated user from request:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
@UseGuards(JwtAuthGuard)
|
|
67
|
+
@Get('me')
|
|
68
|
+
async getCurrentUser(@Request() req) {
|
|
69
|
+
// req.user is populated by JWT strategy
|
|
70
|
+
const userId = req.user.userId;
|
|
71
|
+
return this.usersService.findOne(userId);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Public Endpoints
|
|
76
|
+
|
|
77
|
+
Public endpoints should NOT have `@UseGuards()`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// ✅ GOOD - Public endpoint
|
|
81
|
+
@Post('login')
|
|
82
|
+
@ApiTags('Authentication')
|
|
83
|
+
async login(@Body() dto: LoginDto) {
|
|
84
|
+
return this.authService.login(dto);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: DTO validation and Swagger documentation standards
|
|
3
|
+
globs: src/**/dto/*.ts
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# DTO Validation & Documentation
|
|
8
|
+
|
|
9
|
+
## Required Decorators
|
|
10
|
+
|
|
11
|
+
Every DTO MUST have both validation (`class-validator`) and documentation (`@nestjs/swagger`):
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// ❌ BAD - Missing decorators
|
|
15
|
+
export class CreatePostDto {
|
|
16
|
+
title: string;
|
|
17
|
+
content: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ✅ GOOD - Full validation + documentation
|
|
21
|
+
import { IsString, IsNotEmpty, MaxLength } from 'class-validator';
|
|
22
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
23
|
+
|
|
24
|
+
export class CreatePostDto {
|
|
25
|
+
@ApiProperty({
|
|
26
|
+
description: 'The title of the post',
|
|
27
|
+
example: 'My First Post',
|
|
28
|
+
maxLength: 255,
|
|
29
|
+
})
|
|
30
|
+
@IsString()
|
|
31
|
+
@IsNotEmpty()
|
|
32
|
+
@MaxLength(255)
|
|
33
|
+
title: string;
|
|
34
|
+
|
|
35
|
+
@ApiProperty({
|
|
36
|
+
description: 'The content of the post',
|
|
37
|
+
example: 'This is the content...',
|
|
38
|
+
})
|
|
39
|
+
@IsString()
|
|
40
|
+
@IsNotEmpty()
|
|
41
|
+
content: string;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Optional Fields
|
|
46
|
+
|
|
47
|
+
Use `@IsOptional()` for optional fields:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
@ApiProperty({ required: false })
|
|
51
|
+
@IsOptional()
|
|
52
|
+
@IsString()
|
|
53
|
+
name?: string;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Enums
|
|
57
|
+
|
|
58
|
+
Document enum values explicitly:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
@ApiProperty({
|
|
62
|
+
enum: ['light', 'dark', 'auto'],
|
|
63
|
+
example: 'dark',
|
|
64
|
+
})
|
|
65
|
+
@IsEnum(['light', 'dark', 'auto'])
|
|
66
|
+
theme: string;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Response DTOs
|
|
70
|
+
|
|
71
|
+
Create dedicated response DTOs without validation decorators:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
export class UserResponseDto {
|
|
75
|
+
@ApiProperty({ example: 1 })
|
|
76
|
+
id: number;
|
|
77
|
+
|
|
78
|
+
@ApiProperty({ example: 'user@example.com' })
|
|
79
|
+
email: string;
|
|
80
|
+
|
|
81
|
+
// ❌ Don't include password in responses
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Partial Updates
|
|
86
|
+
|
|
87
|
+
Use `@nestjs/swagger`'s `PartialType` for update DTOs:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { PartialType } from '@nestjs/swagger';
|
|
91
|
+
|
|
92
|
+
export class UpdatePostDto extends PartialType(CreatePostDto) {}
|
|
93
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Acá debes especificar reglas de negocios que se utilicen en la api que estás creando
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# REST API - Architecture & Standards
|
|
7
|
+
|
|
8
|
+
## Primary Goal
|
|
9
|
+
|
|
10
|
+
Describe el objetivo principal de la api que estas creando
|
|
11
|
+
|
|
12
|
+
## Core Technical Stack
|
|
13
|
+
|
|
14
|
+
### Backend Framework
|
|
15
|
+
- **NestJS 11**: Progressive Node.js framework with TypeScript-first approach
|
|
16
|
+
- **Fastify**: High-performance HTTP server optimized for speed
|
|
17
|
+
- **TypeScript**: Strict type safety throughout the application
|
|
18
|
+
|
|
19
|
+
### Data Layer
|
|
20
|
+
- **Prisma ORM**: Type-safe database access with excellent developer experience
|
|
21
|
+
- **SQL Server Database**: Use SQL Server for all environments (dev via Docker, production via hosted service)
|
|
22
|
+
- **Migration system**: Version-controlled database schema changes
|
|
23
|
+
|
|
24
|
+
### Security & Authentication
|
|
25
|
+
- **JWT Authentication**: Stateless token-based authentication
|
|
26
|
+
- **Role-Based Access Control (RBAC)**: Granular permission system
|
|
27
|
+
- **Password Security**: bcrypt hashing, secure credential storage
|
|
28
|
+
|
|
29
|
+
## Architecture Principles
|
|
30
|
+
|
|
31
|
+
### 1. Modular Design
|
|
32
|
+
- **Feature-based modules**: Each domain (auth, users, posts) in isolated modules
|
|
33
|
+
- **Clear boundaries**: Well-defined interfaces between modules
|
|
34
|
+
- **Dependency injection**: Loose coupling, easy testing
|
|
35
|
+
- **Single Responsibility**: Each module handles one domain concern
|
|
36
|
+
|
|
37
|
+
### 2. Layered Architecture
|
|
38
|
+
```
|
|
39
|
+
Controllers (HTTP Layer)
|
|
40
|
+
↓
|
|
41
|
+
Services (Business Logic)
|
|
42
|
+
↓
|
|
43
|
+
Repositories/Prisma (Data Access)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Type Safety & Validation
|
|
47
|
+
- **End-to-end TypeScript**: From request to database to response
|
|
48
|
+
- **DTOs with decorators**: class-validator for automatic validation
|
|
49
|
+
- **Prisma types**: Auto-generated, type-safe database models
|
|
50
|
+
- **No implicit any**: Strict TypeScript configuration
|
|
51
|
+
|
|
52
|
+
### 4. API Documentation
|
|
53
|
+
- **Swagger/OpenAPI**: Auto-generated, always up-to-date
|
|
54
|
+
- **Decorator-based**: Documentation as code (@ApiProperty, @ApiOperation)
|
|
55
|
+
- **Interactive UI**: Available at `/docs` endpoint
|
|
56
|
+
- **Schema validation**: DTO definitions visible in Swagger
|
|
57
|
+
|
|
58
|
+
### 5. Security by Design
|
|
59
|
+
- **Protected by default**: All endpoints require authentication unless explicitly public
|
|
60
|
+
- **JWT Guards**: Automatic token validation
|
|
61
|
+
- **CORS configuration**: Secure cross-origin policies
|
|
62
|
+
- **Input validation**: All incoming data validated against DTOs
|
|
63
|
+
- **Error sanitization**: No sensitive data in error responses
|
|
64
|
+
|
|
65
|
+
## Development Standards
|
|
66
|
+
|
|
67
|
+
### Code Quality
|
|
68
|
+
- **ESLint**: Enforced coding standards
|
|
69
|
+
- **Prettier**: Consistent code formatting
|
|
70
|
+
- **Type safety**: No `any` types without explicit justification
|
|
71
|
+
- **Error handling**: Proper try-catch blocks with typed errors
|
|
72
|
+
|
|
73
|
+
### Database Practices
|
|
74
|
+
- **Migrations**: All schema changes through Prisma migrations
|
|
75
|
+
- **Seeding**: Automated test data creation for development
|
|
76
|
+
- **Relations**: Proper foreign keys and cascade rules
|
|
77
|
+
- **Indexes**: Performance-optimized queries
|
|
78
|
+
|
|
79
|
+
### API Design
|
|
80
|
+
- **RESTful conventions**: Standard HTTP methods (GET, POST, PATCH, DELETE)
|
|
81
|
+
- **HTTP status codes**: Semantic response codes (200, 201, 400, 401, 404, etc.)
|
|
82
|
+
- **Consistent naming**: kebab-case for URLs, camelCase for JSON
|
|
83
|
+
- **Versioning ready**: API structure prepared for future versions
|
|
84
|
+
|
|
85
|
+
### Developer Experience
|
|
86
|
+
- **Hot reload**: Fast development cycle with watch mode
|
|
87
|
+
- **Auto-seeding**: Pre-populated test data on startup
|
|
88
|
+
- **Health checks**: `/health` endpoint for monitoring
|
|
89
|
+
- **Clear error messages**: Helpful validation errors
|
|
90
|
+
|
|
91
|
+
## Production Readiness
|
|
92
|
+
|
|
93
|
+
### Performance
|
|
94
|
+
- **Fastify speed**: High-throughput HTTP handling
|
|
95
|
+
- **Prisma optimization**: Efficient database queries
|
|
96
|
+
- **Connection pooling**: Managed database connections
|
|
97
|
+
- **Async operations**: Non-blocking I/O throughout
|
|
98
|
+
|
|
99
|
+
### Scalability
|
|
100
|
+
- **Stateless design**: Horizontal scaling capable
|
|
101
|
+
- **Database flexibility**: Easy migration to production databases
|
|
102
|
+
- **Modular growth**: New features as independent modules
|
|
103
|
+
- **Resource efficiency**: Optimized memory and CPU usage
|
|
104
|
+
|
|
105
|
+
### Monitoring & Debugging
|
|
106
|
+
- **Logging**: Structured application logs
|
|
107
|
+
- **Error tracking**: Proper error propagation and handling
|
|
108
|
+
- **Health endpoints**: System status monitoring
|
|
109
|
+
- **Swagger docs**: Runtime API exploration
|
|
110
|
+
|
|
111
|
+
### Testing
|
|
112
|
+
- **Jest framework**: Unit and integration tests
|
|
113
|
+
- **E2E testing**: Full request-response cycle tests
|
|
114
|
+
- **Test coverage**: Comprehensive test suite capability
|
|
115
|
+
- **Mocking support**: Easy dependency mocking
|
|
116
|
+
|
|
117
|
+
## Quality Standards
|
|
118
|
+
|
|
119
|
+
✅ **Type Safety**: 100% TypeScript coverage, no implicit any
|
|
120
|
+
✅ **Validation**: All inputs validated with class-validator
|
|
121
|
+
✅ **Documentation**: All endpoints documented in Swagger
|
|
122
|
+
✅ **Security**: Authentication, authorization, input sanitization
|
|
123
|
+
✅ **Error Handling**: Proper HTTP codes and error responses
|
|
124
|
+
✅ **Code Quality**: ESLint/Prettier compliance
|
|
125
|
+
✅ **Database Integrity**: Migrations, relations, constraints
|
|
126
|
+
✅ **Performance**: Fastify optimizations, efficient queries
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: NestJS modular architecture and dependency injection patterns
|
|
3
|
+
globs: src/**/*.ts
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# NestJS Architecture Standards
|
|
8
|
+
|
|
9
|
+
## Module Organization
|
|
10
|
+
|
|
11
|
+
Every feature MUST be organized in its own module with clear responsibilities:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// ❌ BAD - Everything in one module
|
|
15
|
+
@Module({
|
|
16
|
+
controllers: [UsersController, PostsController, AuthController],
|
|
17
|
+
providers: [UsersService, PostsService, AuthService],
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// ✅ GOOD - Separate feature modules
|
|
21
|
+
@Module({
|
|
22
|
+
imports: [UsersModule, PostsModule, AuthModule],
|
|
23
|
+
})
|
|
24
|
+
export class AppModule {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Service Layer Pattern
|
|
28
|
+
|
|
29
|
+
Services contain business logic, controllers handle HTTP concerns:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// ❌ BAD - Business logic in controller
|
|
33
|
+
@Get(':id')
|
|
34
|
+
async getPost(@Param('id') id: string) {
|
|
35
|
+
const post = await this.prisma.post.findUnique({ where: { id: +id } });
|
|
36
|
+
if (!post) throw new NotFoundException();
|
|
37
|
+
return post;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ✅ GOOD - Logic in service
|
|
41
|
+
@Injectable()
|
|
42
|
+
export class PostsService {
|
|
43
|
+
async findOne(id: number): Promise<Post> {
|
|
44
|
+
const post = await this.prisma.post.findUnique({ where: { id } });
|
|
45
|
+
if (!post) throw new NotFoundException(`Post with ID ${id} not found`);
|
|
46
|
+
return post;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Dependency Injection
|
|
52
|
+
|
|
53
|
+
- Use constructor injection for all dependencies
|
|
54
|
+
- Inject services, never import them directly
|
|
55
|
+
- Mark services with `@Injectable()` decorator
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// ✅ GOOD - Constructor injection
|
|
59
|
+
@Injectable()
|
|
60
|
+
export class UsersService {
|
|
61
|
+
constructor(private readonly prisma: PrismaService) {}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Global Modules
|
|
66
|
+
|
|
67
|
+
Use `@Global()` only for infrastructure modules (Prisma, Config, Logger):
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
@Global()
|
|
71
|
+
@Module({
|
|
72
|
+
providers: [PrismaService],
|
|
73
|
+
exports: [PrismaService],
|
|
74
|
+
})
|
|
75
|
+
export class PrismaModule {}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Validation Pipe
|
|
79
|
+
|
|
80
|
+
Global validation is configured in `main.ts`:
|
|
81
|
+
- `whitelist: true` - Strip unknown properties
|
|
82
|
+
- `forbidNonWhitelisted: true` - Throw error on unknown properties
|
|
83
|
+
- `transform: true` - Auto-transform payloads to DTO instances
|