create-huenei-template 0.2.7 → 0.2.9
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 +14 -0
- package/dist/core/file-operations.js +15 -0
- package/dist/core/prompts.js +77 -135
- package/dist/index.js +55 -11
- 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/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/dist/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/dist/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -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/dist/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
- 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/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -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
- package/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "huenei-nestjs-api-sqlserver",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"private": true,
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "prisma generate && nest build",
|
|
10
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
11
|
+
"start": "nest start",
|
|
12
|
+
"start:dev": "node scripts/check-docker.js && prisma generate && nest start --watch",
|
|
13
|
+
"start:dev:skip-check": "prisma generate && nest start --watch",
|
|
14
|
+
"start:debug": "node scripts/check-docker.js && prisma generate && nest start --debug --watch",
|
|
15
|
+
"start:prod": "node dist/main",
|
|
16
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
17
|
+
"test": "node scripts/check-docker.js && prisma generate && jest",
|
|
18
|
+
"test:watch": "jest --watch",
|
|
19
|
+
"test:cov": "node scripts/check-docker.js && prisma generate && jest --coverage",
|
|
20
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
21
|
+
"test:e2e": "node scripts/check-docker.js && prisma generate && jest --config ./test/jest-e2e.json",
|
|
22
|
+
"prisma:generate": "prisma generate",
|
|
23
|
+
"prisma:migrate": "prisma migrate dev",
|
|
24
|
+
"prisma:studio": "prisma studio",
|
|
25
|
+
"prisma:seed": "ts-node prisma/seed.ts"
|
|
26
|
+
},
|
|
27
|
+
"prisma": {
|
|
28
|
+
"seed": "ts-node prisma/seed.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@fastify/static": "^9.0.0",
|
|
32
|
+
"@fastify/view": "^11.1.1",
|
|
33
|
+
"@nestjs/common": "^11.0.1",
|
|
34
|
+
"@nestjs/core": "^11.0.1",
|
|
35
|
+
"@nestjs/jwt": "^10.2.0",
|
|
36
|
+
"@nestjs/passport": "^10.0.3",
|
|
37
|
+
"@nestjs/platform-fastify": "^11.1.12",
|
|
38
|
+
"@nestjs/swagger": "^11.2.5",
|
|
39
|
+
"@nestjs/throttler": "^6.5.0",
|
|
40
|
+
"@prisma/adapter-mssql": "^7.3.0",
|
|
41
|
+
"@prisma/client": "^7.3.0",
|
|
42
|
+
"bcrypt": "^6.0.0",
|
|
43
|
+
"class-transformer": "^0.5.1",
|
|
44
|
+
"class-validator": "^0.14.3",
|
|
45
|
+
"dotenv": "^17.2.3",
|
|
46
|
+
"fastify": "^5.7.1",
|
|
47
|
+
"passport-jwt": "^4.0.1",
|
|
48
|
+
"reflect-metadata": "^0.2.2",
|
|
49
|
+
"rxjs": "^7.8.1",
|
|
50
|
+
"zod": "^4.3.6"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
54
|
+
"@eslint/js": "^9.18.0",
|
|
55
|
+
"@nestjs/cli": "^11.0.0",
|
|
56
|
+
"@nestjs/schematics": "^11.0.0",
|
|
57
|
+
"@nestjs/testing": "^11.0.1",
|
|
58
|
+
"@types/bcrypt": "^6.0.0",
|
|
59
|
+
"@types/jest": "^30.0.0",
|
|
60
|
+
"@types/mssql": "^9.1.9",
|
|
61
|
+
"@types/node": "^22.10.7",
|
|
62
|
+
"@types/passport-jwt": "^4.0.1",
|
|
63
|
+
"@types/supertest": "^6.0.2",
|
|
64
|
+
"eslint": "^9.18.0",
|
|
65
|
+
"eslint-config-prettier": "^10.0.1",
|
|
66
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
67
|
+
"globals": "^16.0.0",
|
|
68
|
+
"jest": "^30.0.0",
|
|
69
|
+
"prettier": "^3.4.2",
|
|
70
|
+
"prisma": "^7.3.0",
|
|
71
|
+
"source-map-support": "^0.5.21",
|
|
72
|
+
"supertest": "^7.0.0",
|
|
73
|
+
"ts-jest": "^29.2.5",
|
|
74
|
+
"ts-loader": "^9.5.2",
|
|
75
|
+
"ts-node": "^10.9.2",
|
|
76
|
+
"tsconfig-paths": "^4.2.0",
|
|
77
|
+
"typescript": "^5.7.3",
|
|
78
|
+
"typescript-eslint": "^8.20.0"
|
|
79
|
+
},
|
|
80
|
+
"jest": {
|
|
81
|
+
"moduleFileExtensions": [
|
|
82
|
+
"js",
|
|
83
|
+
"json",
|
|
84
|
+
"ts"
|
|
85
|
+
],
|
|
86
|
+
"rootDir": ".",
|
|
87
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
88
|
+
"transform": {
|
|
89
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
90
|
+
},
|
|
91
|
+
"collectCoverageFrom": [
|
|
92
|
+
"src/**/*.(t|j)s",
|
|
93
|
+
"!src/main.ts",
|
|
94
|
+
"!src/**/*.module.ts",
|
|
95
|
+
"!src/**/*.dto.ts"
|
|
96
|
+
],
|
|
97
|
+
"coverageDirectory": "./coverage",
|
|
98
|
+
"testEnvironment": "node",
|
|
99
|
+
"moduleNameMapper": {
|
|
100
|
+
"^@/(.*)$": "<rootDir>/src/$1"
|
|
101
|
+
},
|
|
102
|
+
"testPathIgnorePatterns": [
|
|
103
|
+
"/node_modules/",
|
|
104
|
+
"/dist/"
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
generator client {
|
|
5
|
+
provider = "prisma-client-js"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
datasource db {
|
|
9
|
+
provider = "sqlserver"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
model User {
|
|
13
|
+
id Int @id @default(autoincrement())
|
|
14
|
+
email String @unique
|
|
15
|
+
password String
|
|
16
|
+
name String?
|
|
17
|
+
role String @default("READER")
|
|
18
|
+
createdAt DateTime @default(now())
|
|
19
|
+
updatedAt DateTime @updatedAt
|
|
20
|
+
posts Post[]
|
|
21
|
+
profile UserProfile?
|
|
22
|
+
settings UserSettings?
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
model Post {
|
|
26
|
+
id Int @id @default(autoincrement())
|
|
27
|
+
title String
|
|
28
|
+
content String
|
|
29
|
+
published Boolean @default(false)
|
|
30
|
+
createdAt DateTime @default(now())
|
|
31
|
+
authorId Int
|
|
32
|
+
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
|
33
|
+
|
|
34
|
+
@@index([authorId])
|
|
35
|
+
@@index([published])
|
|
36
|
+
@@index([authorId, published])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
model UserProfile {
|
|
40
|
+
id Int @id @default(autoincrement())
|
|
41
|
+
userId Int @unique
|
|
42
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
43
|
+
|
|
44
|
+
// Campos normalizados (consultas frecuentes, validaciones específicas)
|
|
45
|
+
avatar String?
|
|
46
|
+
bio String?
|
|
47
|
+
phone String?
|
|
48
|
+
website String?
|
|
49
|
+
publicName String?
|
|
50
|
+
|
|
51
|
+
// Metadata flexible (redes sociales, campos custom) - stored as NVARCHAR(MAX), parsed as JSON in application layer
|
|
52
|
+
metadata String?
|
|
53
|
+
|
|
54
|
+
createdAt DateTime @default(now())
|
|
55
|
+
updatedAt DateTime @updatedAt
|
|
56
|
+
|
|
57
|
+
@@index([publicName])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
model UserSettings {
|
|
61
|
+
id Int @id @default(autoincrement())
|
|
62
|
+
userId Int @unique
|
|
63
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
64
|
+
|
|
65
|
+
// JSON flexible para configuraciones (stored as NVARCHAR(MAX), parsed as JSON in application layer)
|
|
66
|
+
preferences String
|
|
67
|
+
|
|
68
|
+
createdAt DateTime @default(now())
|
|
69
|
+
updatedAt DateTime @updatedAt
|
|
70
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
import { PrismaMssql } from '@prisma/adapter-mssql';
|
|
3
|
+
import * as bcrypt from 'bcrypt';
|
|
4
|
+
import 'dotenv/config';
|
|
5
|
+
|
|
6
|
+
const adapter = new PrismaMssql(process.env.DATABASE_URL as string);
|
|
7
|
+
const prisma = new PrismaClient({ adapter });
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
console.log('🌱 Starting seed...');
|
|
11
|
+
|
|
12
|
+
// Create users with different roles
|
|
13
|
+
const admin = await prisma.user.upsert({
|
|
14
|
+
where: { email: 'admin@huenei.com' },
|
|
15
|
+
update: {
|
|
16
|
+
role: 'ADMIN',
|
|
17
|
+
password: await bcrypt.hash('Admin123!', 10),
|
|
18
|
+
},
|
|
19
|
+
create: {
|
|
20
|
+
email: 'admin@huenei.com',
|
|
21
|
+
password: await bcrypt.hash('Admin123!', 10),
|
|
22
|
+
name: 'Admin User',
|
|
23
|
+
role: 'ADMIN',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const editor = await prisma.user.upsert({
|
|
28
|
+
where: { email: 'editor@huenei.com' },
|
|
29
|
+
update: {
|
|
30
|
+
role: 'EDITOR',
|
|
31
|
+
password: await bcrypt.hash('Editor123!', 10),
|
|
32
|
+
},
|
|
33
|
+
create: {
|
|
34
|
+
email: 'editor@huenei.com',
|
|
35
|
+
password: await bcrypt.hash('Editor123!', 10),
|
|
36
|
+
name: 'Editor User',
|
|
37
|
+
role: 'EDITOR',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const reader = await prisma.user.upsert({
|
|
42
|
+
where: { email: 'reader@huenei.com' },
|
|
43
|
+
update: {
|
|
44
|
+
role: 'READER',
|
|
45
|
+
password: await bcrypt.hash('Reader123!', 10),
|
|
46
|
+
},
|
|
47
|
+
create: {
|
|
48
|
+
email: 'reader@huenei.com',
|
|
49
|
+
password: await bcrypt.hash('Reader123!', 10),
|
|
50
|
+
name: 'Reader User',
|
|
51
|
+
role: 'READER',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log('✓ Created 3 users (ADMIN, EDITOR, READER)');
|
|
56
|
+
|
|
57
|
+
// Clean existing profiles and settings
|
|
58
|
+
await prisma.userProfile.deleteMany();
|
|
59
|
+
await prisma.userSettings.deleteMany();
|
|
60
|
+
|
|
61
|
+
// Create profiles for users
|
|
62
|
+
await prisma.userProfile.createMany({
|
|
63
|
+
data: [
|
|
64
|
+
{
|
|
65
|
+
userId: admin.id,
|
|
66
|
+
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=admin',
|
|
67
|
+
bio: 'Administrador del sistema',
|
|
68
|
+
publicName: 'Admin',
|
|
69
|
+
metadata: JSON.stringify({ github: 'admin-huenei' }),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
userId: editor.id,
|
|
73
|
+
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=editor',
|
|
74
|
+
bio: 'Editor de contenidos',
|
|
75
|
+
publicName: 'Editor',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
userId: reader.id,
|
|
79
|
+
bio: 'Usuario lector',
|
|
80
|
+
publicName: 'Reader',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log('✓ Created 3 user profiles');
|
|
86
|
+
|
|
87
|
+
// Create settings with defaults
|
|
88
|
+
await prisma.userSettings.createMany({
|
|
89
|
+
data: [
|
|
90
|
+
{
|
|
91
|
+
userId: admin.id,
|
|
92
|
+
preferences: JSON.stringify({
|
|
93
|
+
language: 'es',
|
|
94
|
+
theme: 'light',
|
|
95
|
+
emailNotifications: true,
|
|
96
|
+
pushNotifications: false,
|
|
97
|
+
privacy: 'private',
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
userId: editor.id,
|
|
102
|
+
preferences: JSON.stringify({
|
|
103
|
+
language: 'es',
|
|
104
|
+
theme: 'light',
|
|
105
|
+
emailNotifications: true,
|
|
106
|
+
pushNotifications: false,
|
|
107
|
+
privacy: 'private',
|
|
108
|
+
}),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
userId: reader.id,
|
|
112
|
+
preferences: JSON.stringify({
|
|
113
|
+
language: 'es',
|
|
114
|
+
theme: 'light',
|
|
115
|
+
emailNotifications: true,
|
|
116
|
+
pushNotifications: false,
|
|
117
|
+
privacy: 'private',
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
console.log('✓ Created 3 user settings');
|
|
124
|
+
|
|
125
|
+
// Clean existing posts
|
|
126
|
+
await prisma.post.deleteMany();
|
|
127
|
+
|
|
128
|
+
// Create posts
|
|
129
|
+
await prisma.post.createMany({
|
|
130
|
+
data: [
|
|
131
|
+
{
|
|
132
|
+
title: 'Getting Started with NestJS',
|
|
133
|
+
content:
|
|
134
|
+
'NestJS is a progressive Node.js framework for building efficient and scalable server-side applications. It uses TypeScript and combines elements of OOP, FP, and FRP.',
|
|
135
|
+
published: true,
|
|
136
|
+
authorId: admin.id,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
title: 'Understanding Prisma ORM',
|
|
140
|
+
content:
|
|
141
|
+
'Prisma is a next-generation ORM that helps developers build applications faster and with fewer errors. It provides type-safe database access and auto-generated migrations.',
|
|
142
|
+
published: true,
|
|
143
|
+
authorId: admin.id,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
title: 'REST API Best Practices',
|
|
147
|
+
content:
|
|
148
|
+
'When designing RESTful APIs, follow conventions like using proper HTTP methods, meaningful resource names, and consistent error handling.',
|
|
149
|
+
published: true,
|
|
150
|
+
authorId: editor.id,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
title: 'Draft: Authentication Patterns',
|
|
154
|
+
content:
|
|
155
|
+
'Exploring different authentication patterns including JWT, session-based auth, and OAuth. This article needs more research.',
|
|
156
|
+
published: false,
|
|
157
|
+
authorId: editor.id,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
title: 'TypeScript Tips and Tricks',
|
|
161
|
+
content:
|
|
162
|
+
'Advanced TypeScript features that can improve your code quality: generics, utility types, decorators, and more.',
|
|
163
|
+
published: true,
|
|
164
|
+
authorId: editor.id,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title: 'Database Indexing Strategies',
|
|
168
|
+
content:
|
|
169
|
+
'Proper indexing can dramatically improve query performance. Learn when and how to create indexes effectively.',
|
|
170
|
+
published: true,
|
|
171
|
+
authorId: admin.id,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
title: 'Draft: Microservices Architecture',
|
|
175
|
+
content:
|
|
176
|
+
'Initial thoughts on transitioning from monolith to microservices. Still working on the diagrams.',
|
|
177
|
+
published: false,
|
|
178
|
+
authorId: admin.id,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: 'My First Blog Post',
|
|
182
|
+
content:
|
|
183
|
+
'Just getting started with blogging. Excited to share my learning journey with the community!',
|
|
184
|
+
published: true,
|
|
185
|
+
authorId: reader.id,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
title: 'Draft: Learning Prisma',
|
|
189
|
+
content:
|
|
190
|
+
'Taking notes while learning Prisma. The type safety is amazing!',
|
|
191
|
+
published: false,
|
|
192
|
+
authorId: reader.id,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
title: 'API Security Essentials',
|
|
196
|
+
content:
|
|
197
|
+
'Essential security practices for APIs: rate limiting, input validation, CORS configuration, and protecting against common vulnerabilities.',
|
|
198
|
+
published: true,
|
|
199
|
+
authorId: editor.id,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
console.log('✓ Created 10 posts');
|
|
205
|
+
console.log('🎉 Seed completed successfully!');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
main()
|
|
209
|
+
.catch((e) => {
|
|
210
|
+
console.error(e);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
})
|
|
213
|
+
.finally(async () => {
|
|
214
|
+
await prisma.$disconnect();
|
|
215
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig, env } from 'prisma/config';
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
schema: 'prisma/schema.prisma',
|
|
6
|
+
datasource: {
|
|
7
|
+
url: env('DATABASE_URL'),
|
|
8
|
+
},
|
|
9
|
+
migrations: {
|
|
10
|
+
seed: 'ts-node prisma/seed.ts',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const CONTAINER_NAME = 'nestjs-api-sqlserver';
|
|
4
|
+
|
|
5
|
+
function checkDocker() {
|
|
6
|
+
console.log('🔍 Checking Docker status...\n');
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
// Check if Docker is running
|
|
10
|
+
try {
|
|
11
|
+
execSync('docker info', { stdio: 'ignore' });
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('❌ Docker Desktop is NOT running');
|
|
14
|
+
console.error('');
|
|
15
|
+
console.error('📝 Please start Docker Desktop and try again');
|
|
16
|
+
console.error('');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Check if container exists and its status
|
|
21
|
+
try {
|
|
22
|
+
const output = execSync(`docker ps -a --filter "name=${CONTAINER_NAME}" --format "{{.Status}}"`, {
|
|
23
|
+
encoding: 'utf-8',
|
|
24
|
+
}).trim();
|
|
25
|
+
|
|
26
|
+
if (!output) {
|
|
27
|
+
console.error(`❌ Container "${CONTAINER_NAME}" does NOT exist`);
|
|
28
|
+
console.error('');
|
|
29
|
+
console.error('📝 Please create the container:');
|
|
30
|
+
console.error(' → docker-compose up -d');
|
|
31
|
+
console.error('');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!output.startsWith('Up')) {
|
|
36
|
+
console.error(`❌ Container "${CONTAINER_NAME}" exists but is NOT running`);
|
|
37
|
+
console.error(` Status: ${output}`);
|
|
38
|
+
console.error('');
|
|
39
|
+
console.error('📝 Please start the container:');
|
|
40
|
+
console.error(' → docker-compose start');
|
|
41
|
+
console.error(' or');
|
|
42
|
+
console.error(' → docker-compose up -d');
|
|
43
|
+
console.error('');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`✅ Container "${CONTAINER_NAME}" is running`);
|
|
48
|
+
console.log(` Status: ${output}`);
|
|
49
|
+
console.log('');
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('❌ Error checking container status');
|
|
52
|
+
console.error(` ${error.message}`);
|
|
53
|
+
console.error('');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('❌ Unexpected error:');
|
|
58
|
+
console.error(` ${error.message}`);
|
|
59
|
+
console.error('');
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
checkDocker();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
|
|
3
|
+
import { APP_GUARD } from '@nestjs/core';
|
|
4
|
+
import { AppService } from './app.service';
|
|
5
|
+
import { PrismaModule } from './prisma/prisma.module';
|
|
6
|
+
import { HealthModule } from './health/health.module';
|
|
7
|
+
import { AuthModule } from './auth/auth.module';
|
|
8
|
+
import { UsersModule } from './users/users.module';
|
|
9
|
+
import { PostsModule } from './posts/posts.module';
|
|
10
|
+
|
|
11
|
+
const isTestEnv = process.env.NODE_ENV === 'test';
|
|
12
|
+
|
|
13
|
+
@Module({
|
|
14
|
+
imports: [
|
|
15
|
+
ThrottlerModule.forRoot([
|
|
16
|
+
{
|
|
17
|
+
ttl: 60000, // 60 seconds
|
|
18
|
+
limit: isTestEnv ? 1000 : 100, // Higher limit for tests
|
|
19
|
+
},
|
|
20
|
+
]),
|
|
21
|
+
PrismaModule,
|
|
22
|
+
HealthModule,
|
|
23
|
+
AuthModule,
|
|
24
|
+
UsersModule,
|
|
25
|
+
PostsModule,
|
|
26
|
+
],
|
|
27
|
+
providers: [
|
|
28
|
+
AppService,
|
|
29
|
+
...(isTestEnv
|
|
30
|
+
? []
|
|
31
|
+
: [
|
|
32
|
+
{
|
|
33
|
+
provide: APP_GUARD,
|
|
34
|
+
useClass: ThrottlerGuard,
|
|
35
|
+
},
|
|
36
|
+
]),
|
|
37
|
+
],
|
|
38
|
+
})
|
|
39
|
+
export class AppModule {}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Controller, Post, Body, UnauthorizedException } from '@nestjs/common';
|
|
2
|
+
import { ApiTags, ApiOperation, ApiResponse, ApiBody } from '@nestjs/swagger';
|
|
3
|
+
import { Throttle } from '@nestjs/throttler';
|
|
4
|
+
import { AuthService } from './auth.service';
|
|
5
|
+
import { LoginDto } from './dto/login.dto';
|
|
6
|
+
import { LoginResponseDto } from './dto/login-response.dto';
|
|
7
|
+
|
|
8
|
+
@ApiTags('Authentication')
|
|
9
|
+
@Controller('auth')
|
|
10
|
+
export class AuthController {
|
|
11
|
+
constructor(private readonly authService: AuthService) {}
|
|
12
|
+
|
|
13
|
+
@Post('login')
|
|
14
|
+
@Throttle({ default: { limit: 5, ttl: 60000 } }) // 5 attempts per minute
|
|
15
|
+
@ApiOperation({ summary: 'User login' })
|
|
16
|
+
@ApiBody({ type: LoginDto })
|
|
17
|
+
@ApiResponse({
|
|
18
|
+
status: 200,
|
|
19
|
+
description: 'Login successful',
|
|
20
|
+
type: LoginResponseDto,
|
|
21
|
+
})
|
|
22
|
+
@ApiResponse({ status: 401, description: 'Invalid credentials' })
|
|
23
|
+
@ApiResponse({ status: 429, description: 'Too many requests' })
|
|
24
|
+
async login(@Body() loginDto: LoginDto): Promise<LoginResponseDto> {
|
|
25
|
+
const email: string = loginDto.email;
|
|
26
|
+
const password: string = loginDto.password;
|
|
27
|
+
|
|
28
|
+
const user = await this.authService.validateUser(email, password);
|
|
29
|
+
|
|
30
|
+
if (!user) {
|
|
31
|
+
throw new UnauthorizedException('Invalid credentials');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.authService.login(user);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { JwtModule } from '@nestjs/jwt';
|
|
3
|
+
import { PassportModule } from '@nestjs/passport';
|
|
4
|
+
import { AuthService } from './auth.service';
|
|
5
|
+
import { AuthController } from './auth.controller';
|
|
6
|
+
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [
|
|
10
|
+
PassportModule,
|
|
11
|
+
JwtModule.register({
|
|
12
|
+
secret: process.env.JWT_SECRET || (() => {
|
|
13
|
+
throw new Error('JWT_SECRET environment variable is required but not defined');
|
|
14
|
+
})(),
|
|
15
|
+
signOptions: { expiresIn: '24h' },
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
controllers: [AuthController],
|
|
19
|
+
providers: [AuthService, JwtStrategy],
|
|
20
|
+
exports: [AuthService],
|
|
21
|
+
})
|
|
22
|
+
export class AuthModule {}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
2
|
+
import { JwtService } from '@nestjs/jwt';
|
|
3
|
+
import { PrismaService } from '../prisma/prisma.service';
|
|
4
|
+
import * as bcrypt from 'bcrypt';
|
|
5
|
+
import { ValidatedUser } from './types';
|
|
6
|
+
import { Role } from './enums/role.enum';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class AuthService {
|
|
10
|
+
private readonly logger = new Logger(AuthService.name);
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
private prisma: PrismaService,
|
|
14
|
+
private jwtService: JwtService,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
async validateUser(
|
|
18
|
+
email: string,
|
|
19
|
+
password: string,
|
|
20
|
+
): Promise<ValidatedUser | null> {
|
|
21
|
+
const user = await this.prisma.user.findUnique({
|
|
22
|
+
where: { email },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!user) {
|
|
26
|
+
this.logger.warn(`Login attempt failed: user not found - ${email}`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const isPasswordValid = await bcrypt.compare(password, user.password);
|
|
31
|
+
if (!isPasswordValid) {
|
|
32
|
+
this.logger.warn(`Login attempt failed: invalid password - ${email}`);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.logger.log(`User validated successfully - ${email}`);
|
|
37
|
+
return {
|
|
38
|
+
id: user.id,
|
|
39
|
+
email: user.email,
|
|
40
|
+
name: user.name,
|
|
41
|
+
role: user.role as Role,
|
|
42
|
+
createdAt: user.createdAt,
|
|
43
|
+
updatedAt: user.updatedAt,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
login(user: ValidatedUser) {
|
|
48
|
+
const payload = { email: user.email, sub: user.id, role: user.role };
|
|
49
|
+
this.logger.log(`User logged in - ${user.email} (${user.role})`);
|
|
50
|
+
return {
|
|
51
|
+
access_token: this.jwtService.sign(payload),
|
|
52
|
+
user: {
|
|
53
|
+
id: user.id,
|
|
54
|
+
email: user.email,
|
|
55
|
+
name: user.name,
|
|
56
|
+
role: user.role,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async hashPassword(password: string): Promise<string> {
|
|
62
|
+
return bcrypt.hash(password, 10);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
|
|
3
|
+
class UserInfo {
|
|
4
|
+
@ApiProperty({ example: 1 })
|
|
5
|
+
id: number;
|
|
6
|
+
|
|
7
|
+
@ApiProperty({ example: 'user@example.com' })
|
|
8
|
+
email: string;
|
|
9
|
+
|
|
10
|
+
@ApiProperty({ example: 'John Doe', nullable: true })
|
|
11
|
+
name: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class LoginResponseDto {
|
|
15
|
+
@ApiProperty({
|
|
16
|
+
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
17
|
+
description: 'JWT access token',
|
|
18
|
+
})
|
|
19
|
+
access_token: string;
|
|
20
|
+
|
|
21
|
+
@ApiProperty({ type: UserInfo })
|
|
22
|
+
user: UserInfo;
|
|
23
|
+
}
|