kybernus 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +49 -263
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/prompts/wizard.d.ts +14 -1
- package/dist/cli/prompts/wizard.d.ts.map +1 -1
- package/dist/cli/prompts/wizard.js +45 -9
- package/dist/cli/prompts/wizard.js.map +1 -1
- package/dist/core/generator/project.d.ts +8 -0
- package/dist/core/generator/project.d.ts.map +1 -1
- package/dist/core/generator/project.js +41 -2
- package/dist/core/generator/project.js.map +1 -1
- package/dist/core/templates/downloader.d.ts +32 -0
- package/dist/core/templates/downloader.d.ts.map +1 -0
- package/dist/core/templates/downloader.js +95 -0
- package/dist/core/templates/downloader.js.map +1 -0
- package/dist/models/config.d.ts +1 -0
- package/dist/models/config.d.ts.map +1 -1
- package/package.json +6 -2
- package/templates/java-spring/pro/clean/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/java-spring/pro/clean/Dockerfile.hbs +0 -45
- package/templates/java-spring/pro/clean/README.md.hbs +0 -31
- package/templates/java-spring/pro/clean/docker-compose.yml.hbs +0 -18
- package/templates/java-spring/pro/clean/infra/main.tf.hbs +0 -83
- package/templates/java-spring/pro/clean/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/java-spring/pro/clean/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/java-spring/pro/clean/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/java-spring/pro/clean/pom.xml.hbs +0 -130
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/application/service/AuthService.java.hbs +0 -36
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/entity/User.java.hbs +0 -77
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/repository/UserRepository.java.hbs +0 -15
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/usecase/LoginUserUseCase.java.hbs +0 -36
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/usecase/RegisterUserUseCase.java.hbs +0 -46
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/persistence/InMemoryUserRepository.java.hbs +0 -41
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/security/SecurityAdapters.java.hbs +0 -53
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/web/controller/AuthController.java.hbs +0 -41
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +0 -14
- package/templates/java-spring/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/java-spring/pro/hexagonal/Dockerfile.hbs +0 -45
- package/templates/java-spring/pro/hexagonal/README.md.hbs +0 -38
- package/templates/java-spring/pro/hexagonal/docker-compose.yml.hbs +0 -18
- package/templates/java-spring/pro/hexagonal/infra/main.tf.hbs +0 -83
- package/templates/java-spring/pro/hexagonal/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/java-spring/pro/hexagonal/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/java-spring/pro/hexagonal/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/java-spring/pro/hexagonal/pom.xml.hbs +0 -130
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/application/service/AuthService.java.hbs +0 -36
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/entity/User.java.hbs +0 -77
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/repository/UserRepository.java.hbs +0 -15
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/usecase/LoginUserUseCase.java.hbs +0 -36
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/usecase/RegisterUserUseCase.java.hbs +0 -46
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/persistence/InMemoryUserRepository.java.hbs +0 -41
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/security/SecurityAdapters.java.hbs +0 -53
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/web/controller/AuthController.java.hbs +0 -41
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +0 -14
- package/templates/java-spring/pro/mvc/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/java-spring/pro/mvc/Dockerfile.hbs +0 -45
- package/templates/java-spring/pro/mvc/README.md.hbs +0 -116
- package/templates/java-spring/pro/mvc/docker-compose.yml.hbs +0 -18
- package/templates/java-spring/pro/mvc/infra/main.tf.hbs +0 -83
- package/templates/java-spring/pro/mvc/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/java-spring/pro/mvc/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/java-spring/pro/mvc/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/java-spring/pro/mvc/pom.xml.hbs +0 -130
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/GlobalExceptionHandler.java.hbs +0 -39
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/SecurityConfig.java.hbs +0 -44
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/WebConfig.java.hbs +0 -30
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/AuthController.java.hbs +0 -69
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/HealthController.java.hbs +0 -30
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/PaymentsController.java.hbs +0 -49
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/dto/AuthRequest.java.hbs +0 -3
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/dto/AuthResponse.java.hbs +0 -3
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/model/.gitkeep +0 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/repository/.gitkeep +0 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/security/JwtAuthenticationFilter.java.hbs +0 -56
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/security/JwtTokenProvider.java.hbs +0 -59
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/service/.gitkeep +0 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/service/StripeService.java.hbs +0 -67
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +0 -13
- package/templates/java-spring/pro/mvc/src/main/resources/application.yml.hbs +0 -32
- package/templates/java-spring/pro/mvc/src/test/java/{{packagePath}}/{{projectNamePascalCase}}ApplicationTests.java.hbs +0 -13
- package/templates/java-spring/pro/mvc/src/test/resources/application.yml.hbs +0 -10
- package/templates/java-spring/pro/mvc/template.json +0 -14
- package/templates/nestjs/pro/clean/.env.example.hbs +0 -19
- package/templates/nestjs/pro/clean/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nestjs/pro/clean/Dockerfile.hbs +0 -45
- package/templates/nestjs/pro/clean/infra/main.tf.hbs +0 -83
- package/templates/nestjs/pro/clean/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nestjs/pro/clean/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nestjs/pro/clean/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nestjs/pro/clean/package.json.hbs +0 -37
- package/templates/nestjs/pro/clean/src/auth.module.ts.hbs +0 -17
- package/templates/nestjs/pro/clean/src/domain/entities/user.entity.ts.hbs +0 -12
- package/templates/nestjs/pro/clean/src/domain/repositories/user.repository.ts.hbs +0 -6
- package/templates/nestjs/pro/clean/src/domain/use-cases/register.use-case.ts.hbs +0 -18
- package/templates/nestjs/pro/clean/src/infrastructure/database/in-memory.repository.ts.hbs +0 -17
- package/templates/nestjs/pro/clean/src/infrastructure/http/auth.controller.ts.hbs +0 -16
- package/templates/nestjs/pro/clean/tsconfig.json.hbs +0 -21
- package/templates/nestjs/pro/hexagonal/.env.example.hbs +0 -19
- package/templates/nestjs/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nestjs/pro/hexagonal/Dockerfile.hbs +0 -45
- package/templates/nestjs/pro/hexagonal/infra/main.tf.hbs +0 -83
- package/templates/nestjs/pro/hexagonal/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nestjs/pro/hexagonal/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nestjs/pro/hexagonal/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nestjs/pro/hexagonal/package.json.hbs +0 -37
- package/templates/nestjs/pro/hexagonal/src/adapters/inbound/http.adapter.ts.hbs +0 -12
- package/templates/nestjs/pro/hexagonal/src/adapters/outbound/persistence.adapter.ts.hbs +0 -13
- package/templates/nestjs/pro/hexagonal/src/auth.module.ts.hbs +0 -19
- package/templates/nestjs/pro/hexagonal/src/core/auth.service.ts.hbs +0 -16
- package/templates/nestjs/pro/hexagonal/src/core/domain/user.entity.ts.hbs +0 -8
- package/templates/nestjs/pro/hexagonal/src/core/ports/ports.ts.hbs +0 -9
- package/templates/nestjs/pro/hexagonal/tsconfig.json.hbs +0 -21
- package/templates/nestjs/pro/mvc/.env.example.hbs +0 -19
- package/templates/nestjs/pro/mvc/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nestjs/pro/mvc/Dockerfile.hbs +0 -45
- package/templates/nestjs/pro/mvc/README.md.hbs +0 -28
- package/templates/nestjs/pro/mvc/infra/main.tf.hbs +0 -83
- package/templates/nestjs/pro/mvc/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nestjs/pro/mvc/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nestjs/pro/mvc/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nestjs/pro/mvc/package.json.hbs +0 -37
- package/templates/nestjs/pro/mvc/src/app.module.ts.hbs +0 -17
- package/templates/nestjs/pro/mvc/src/auth/auth.controller.ts.hbs +0 -35
- package/templates/nestjs/pro/mvc/src/auth/auth.module.ts.hbs +0 -25
- package/templates/nestjs/pro/mvc/src/auth/auth.service.ts.hbs +0 -55
- package/templates/nestjs/pro/mvc/src/auth/jwt.strategy.ts.hbs +0 -19
- package/templates/nestjs/pro/mvc/src/controllers/health.controller.ts.hbs +0 -9
- package/templates/nestjs/pro/mvc/src/controllers/items.controller.ts.hbs +0 -32
- package/templates/nestjs/pro/mvc/src/main.ts.hbs +0 -17
- package/templates/nestjs/pro/mvc/src/models/create-item.dto.ts.hbs +0 -10
- package/templates/nestjs/pro/mvc/src/models/item.model.ts.hbs +0 -6
- package/templates/nestjs/pro/mvc/src/modules/items.module.ts.hbs +0 -9
- package/templates/nestjs/pro/mvc/src/payments/payments.controller.ts.hbs +0 -26
- package/templates/nestjs/pro/mvc/src/payments/payments.module.ts.hbs +0 -11
- package/templates/nestjs/pro/mvc/src/payments/payments.service.ts.hbs +0 -43
- package/templates/nestjs/pro/mvc/src/services/items.service.ts.hbs +0 -32
- package/templates/nestjs/pro/mvc/tsconfig.json.hbs +0 -21
- package/templates/nextjs/pro/default/.env.example.hbs +0 -20
- package/templates/nextjs/pro/default/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nextjs/pro/default/Dockerfile.hbs +0 -45
- package/templates/nextjs/pro/default/README.md.hbs +0 -96
- package/templates/nextjs/pro/default/docker-compose.yml.hbs +0 -18
- package/templates/nextjs/pro/default/infra/main.tf.hbs +0 -83
- package/templates/nextjs/pro/default/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nextjs/pro/default/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nextjs/pro/default/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nextjs/pro/default/next.config.js.hbs +0 -4
- package/templates/nextjs/pro/default/package.json.hbs +0 -34
- package/templates/nextjs/pro/default/postcss.config.js.hbs +0 -6
- package/templates/nextjs/pro/default/prisma/schema.prisma.hbs +0 -18
- package/templates/nextjs/pro/default/public/.gitkeep +0 -0
- package/templates/nextjs/pro/default/src/app/api/auth/[...nextauth]/route.ts.hbs +0 -61
- package/templates/nextjs/pro/default/src/app/api/checkout/route.ts.hbs +0 -30
- package/templates/nextjs/pro/default/src/app/api/health/route.ts.hbs +0 -9
- package/templates/nextjs/pro/default/src/app/api/webhook/route.ts.hbs +0 -51
- package/templates/nextjs/pro/default/src/app/dashboard/page.tsx.hbs +0 -52
- package/templates/nextjs/pro/default/src/app/globals.css.hbs +0 -3
- package/templates/nextjs/pro/default/src/app/layout.tsx.hbs +0 -22
- package/templates/nextjs/pro/default/src/app/page.tsx.hbs +0 -38
- package/templates/nextjs/pro/default/src/components/.gitkeep +0 -0
- package/templates/nextjs/pro/default/src/components/AuthButton.tsx.hbs +0 -34
- package/templates/nextjs/pro/default/src/components/Providers.tsx.hbs +0 -7
- package/templates/nextjs/pro/default/src/lib/prisma.ts.hbs +0 -13
- package/templates/nextjs/pro/default/src/proxy.ts.hbs +0 -22
- package/templates/nextjs/pro/default/tailwind.config.ts.hbs +0 -15
- package/templates/nextjs/pro/default/template.json +0 -18
- package/templates/nextjs/pro/default/tsconfig.json.hbs +0 -40
- package/templates/nodejs-express/pro/clean/.env.example.hbs +0 -19
- package/templates/nodejs-express/pro/clean/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nodejs-express/pro/clean/Dockerfile.hbs +0 -45
- package/templates/nodejs-express/pro/clean/README.md.hbs +0 -41
- package/templates/nodejs-express/pro/clean/docker-compose.yml.hbs +0 -18
- package/templates/nodejs-express/pro/clean/infra/main.tf.hbs +0 -83
- package/templates/nodejs-express/pro/clean/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nodejs-express/pro/clean/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nodejs-express/pro/clean/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nodejs-express/pro/clean/package.json.hbs +0 -55
- package/templates/nodejs-express/pro/clean/src/application/services/AuthService.ts.hbs +0 -66
- package/templates/nodejs-express/pro/clean/src/domain/entities/User.ts.hbs +0 -38
- package/templates/nodejs-express/pro/clean/src/domain/repositories/IUserRepository.ts.hbs +0 -13
- package/templates/nodejs-express/pro/clean/src/domain/usecases/LoginUserUseCase.ts.hbs +0 -39
- package/templates/nodejs-express/pro/clean/src/domain/usecases/RegisterUserUseCase.ts.hbs +0 -51
- package/templates/nodejs-express/pro/clean/src/index.ts.hbs +0 -40
- package/templates/nodejs-express/pro/clean/src/infrastructure/database/InMemoryUserRepository.ts.hbs +0 -46
- package/templates/nodejs-express/pro/clean/src/infrastructure/http/controllers/AuthController.ts.hbs +0 -45
- package/templates/nodejs-express/pro/clean/src/infrastructure/http/middlewares/AuthMiddleware.ts.hbs +0 -27
- package/templates/nodejs-express/pro/clean/src/infrastructure/providers/PasswordHasher.ts.hbs +0 -14
- package/templates/nodejs-express/pro/clean/src/infrastructure/providers/TokenGenerator.ts.hbs +0 -25
- package/templates/nodejs-express/pro/clean/tsconfig.json.hbs +0 -27
- package/templates/nodejs-express/pro/hexagonal/.env.example.hbs +0 -19
- package/templates/nodejs-express/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nodejs-express/pro/hexagonal/Dockerfile.hbs +0 -45
- package/templates/nodejs-express/pro/hexagonal/README.md.hbs +0 -42
- package/templates/nodejs-express/pro/hexagonal/docker-compose.yml.hbs +0 -18
- package/templates/nodejs-express/pro/hexagonal/infra/main.tf.hbs +0 -83
- package/templates/nodejs-express/pro/hexagonal/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nodejs-express/pro/hexagonal/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nodejs-express/pro/hexagonal/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nodejs-express/pro/hexagonal/package.json.hbs +0 -55
- package/templates/nodejs-express/pro/hexagonal/src/adapters/inbound/http/AuthController.ts.hbs +0 -48
- package/templates/nodejs-express/pro/hexagonal/src/adapters/outbound/SecurityAdapters.ts.hbs +0 -31
- package/templates/nodejs-express/pro/hexagonal/src/adapters/outbound/persistence/InMemoryUserAdapter.ts.hbs +0 -38
- package/templates/nodejs-express/pro/hexagonal/src/core/AuthService.ts.hbs +0 -51
- package/templates/nodejs-express/pro/hexagonal/src/core/domain/entities/User.ts.hbs +0 -28
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/inbound/IAuthPort.ts.hbs +0 -11
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/outbound/ISecurityPorts.ts.hbs +0 -15
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/outbound/IUserRepositoryPort.ts.hbs +0 -13
- package/templates/nodejs-express/pro/hexagonal/src/index.ts.hbs +0 -41
- package/templates/nodejs-express/pro/hexagonal/tsconfig.json.hbs +0 -27
- package/templates/nodejs-express/pro/mvc/.env.example.hbs +0 -19
- package/templates/nodejs-express/pro/mvc/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/nodejs-express/pro/mvc/Dockerfile.hbs +0 -45
- package/templates/nodejs-express/pro/mvc/README.md.hbs +0 -85
- package/templates/nodejs-express/pro/mvc/docker-compose.yml.hbs +0 -18
- package/templates/nodejs-express/pro/mvc/infra/main.tf.hbs +0 -83
- package/templates/nodejs-express/pro/mvc/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/nodejs-express/pro/mvc/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/nodejs-express/pro/mvc/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/nodejs-express/pro/mvc/package.json.hbs +0 -55
- package/templates/nodejs-express/pro/mvc/src/app.ts.hbs +0 -34
- package/templates/nodejs-express/pro/mvc/src/config/database.ts.hbs +0 -10
- package/templates/nodejs-express/pro/mvc/src/controllers/auth.controller.ts.hbs +0 -91
- package/templates/nodejs-express/pro/mvc/src/controllers/healthController.ts.hbs +0 -20
- package/templates/nodejs-express/pro/mvc/src/controllers/payments.controller.ts.hbs +0 -72
- package/templates/nodejs-express/pro/mvc/src/index.ts.hbs +0 -12
- package/templates/nodejs-express/pro/mvc/src/middleware/errorHandler.ts.hbs +0 -22
- package/templates/nodejs-express/pro/mvc/src/middlewares/auth.middleware.ts.hbs +0 -31
- package/templates/nodejs-express/pro/mvc/src/models/.gitkeep +0 -0
- package/templates/nodejs-express/pro/mvc/src/routes/index.ts.hbs +0 -14
- package/templates/nodejs-express/pro/mvc/src/services/.gitkeep +0 -0
- package/templates/nodejs-express/pro/mvc/src/services/stripe.service.ts.hbs +0 -102
- package/templates/nodejs-express/pro/mvc/template.json +0 -18
- package/templates/nodejs-express/pro/mvc/tsconfig.json.hbs +0 -27
- package/templates/python-fastapi/pro/clean/.env.example.hbs +0 -17
- package/templates/python-fastapi/pro/clean/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/python-fastapi/pro/clean/Dockerfile.hbs +0 -20
- package/templates/python-fastapi/pro/clean/app/domain/entities/user.py.hbs +0 -23
- package/templates/python-fastapi/pro/clean/app/domain/repositories/user_repository.py.hbs +0 -22
- package/templates/python-fastapi/pro/clean/app/domain/usecases/register_user.py.hbs +0 -30
- package/templates/python-fastapi/pro/clean/app/infrastructure/database/in_memory_repository.py.hbs +0 -26
- package/templates/python-fastapi/pro/clean/app/infrastructure/http/auth_controller.py.hbs +0 -26
- package/templates/python-fastapi/pro/clean/app/infrastructure/security/adapters.py.hbs +0 -23
- package/templates/python-fastapi/pro/clean/app/main.py.hbs +0 -10
- package/templates/python-fastapi/pro/clean/infra/main.tf.hbs +0 -83
- package/templates/python-fastapi/pro/clean/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/python-fastapi/pro/clean/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/python-fastapi/pro/clean/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/python-fastapi/pro/clean/requirements.txt.hbs +0 -12
- package/templates/python-fastapi/pro/hexagonal/.env.example.hbs +0 -17
- package/templates/python-fastapi/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/python-fastapi/pro/hexagonal/Dockerfile.hbs +0 -20
- package/templates/python-fastapi/pro/hexagonal/app/adapters/inbound/http_adapter.py.hbs +0 -29
- package/templates/python-fastapi/pro/hexagonal/app/core/domain/user.py.hbs +0 -15
- package/templates/python-fastapi/pro/hexagonal/app/core/ports.py.hbs +0 -25
- package/templates/python-fastapi/pro/hexagonal/app/core/service.py.hbs +0 -28
- package/templates/python-fastapi/pro/hexagonal/app/main.py.hbs +0 -22
- package/templates/python-fastapi/pro/hexagonal/infra/main.tf.hbs +0 -83
- package/templates/python-fastapi/pro/hexagonal/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/python-fastapi/pro/hexagonal/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/python-fastapi/pro/hexagonal/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/python-fastapi/pro/hexagonal/requirements.txt.hbs +0 -12
- package/templates/python-fastapi/pro/mvc/.env.example.hbs +0 -17
- package/templates/python-fastapi/pro/mvc/.github/workflows/ci-cd.yml.hbs +0 -88
- package/templates/python-fastapi/pro/mvc/Dockerfile.hbs +0 -20
- package/templates/python-fastapi/pro/mvc/README.md.hbs +0 -41
- package/templates/python-fastapi/pro/mvc/app/controllers/auth.py.hbs +0 -46
- package/templates/python-fastapi/pro/mvc/app/controllers/health.py.hbs +0 -7
- package/templates/python-fastapi/pro/mvc/app/controllers/items.py.hbs +0 -21
- package/templates/python-fastapi/pro/mvc/app/controllers/payments.py.hbs +0 -32
- package/templates/python-fastapi/pro/mvc/app/main.py.hbs +0 -20
- package/templates/python-fastapi/pro/mvc/app/middleware/security.py.hbs +0 -39
- package/templates/python-fastapi/pro/mvc/app/models/item.py.hbs +0 -11
- package/templates/python-fastapi/pro/mvc/app/schemas/item.py.hbs +0 -16
- package/templates/python-fastapi/pro/mvc/app/services/item_service.py.hbs +0 -24
- package/templates/python-fastapi/pro/mvc/infra/main.tf.hbs +0 -83
- package/templates/python-fastapi/pro/mvc/infra/modules/ecs/main.tf.hbs +0 -54
- package/templates/python-fastapi/pro/mvc/infra/modules/rds/main.tf.hbs +0 -88
- package/templates/python-fastapi/pro/mvc/infra/modules/vpc/main.tf.hbs +0 -107
- package/templates/python-fastapi/pro/mvc/requirements.txt.hbs +0 -12
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# RDS Module
|
|
2
|
-
|
|
3
|
-
variable "app_name" {
|
|
4
|
-
type = string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
variable "environment" {
|
|
8
|
-
type = string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
variable "vpc_id" {
|
|
12
|
-
type = string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
variable "subnet_ids" {
|
|
16
|
-
type = list(string)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
variable "security_group_id" {
|
|
20
|
-
type = string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
# DB Subnet Group
|
|
24
|
-
resource "aws_db_subnet_group" "main" {
|
|
25
|
-
name = "${var.app_name}-${var.environment}"
|
|
26
|
-
subnet_ids = var.subnet_ids
|
|
27
|
-
|
|
28
|
-
tags = {
|
|
29
|
-
Name = "${var.app_name}-${var.environment}"
|
|
30
|
-
Environment = var.environment
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
# RDS PostgreSQL Instance
|
|
35
|
-
resource "aws_db_instance" "main" {
|
|
36
|
-
identifier = "${var.app_name}-${var.environment}"
|
|
37
|
-
|
|
38
|
-
engine = "postgres"
|
|
39
|
-
engine_version = "16"
|
|
40
|
-
instance_class = "db.t3.micro"
|
|
41
|
-
|
|
42
|
-
allocated_storage = 20
|
|
43
|
-
max_allocated_storage = 100
|
|
44
|
-
storage_type = "gp3"
|
|
45
|
-
storage_encrypted = true
|
|
46
|
-
|
|
47
|
-
db_name = replace(var.app_name, "-", "_")
|
|
48
|
-
username = "postgres"
|
|
49
|
-
password = random_password.db_password.result
|
|
50
|
-
|
|
51
|
-
db_subnet_group_name = aws_db_subnet_group.main.name
|
|
52
|
-
vpc_security_group_ids = [var.security_group_id]
|
|
53
|
-
|
|
54
|
-
backup_retention_period = 7
|
|
55
|
-
skip_final_snapshot = var.environment != "prod"
|
|
56
|
-
|
|
57
|
-
tags = {
|
|
58
|
-
Name = "${var.app_name}-${var.environment}"
|
|
59
|
-
Environment = var.environment
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
# Random password for DB
|
|
64
|
-
resource "random_password" "db_password" {
|
|
65
|
-
length = 32
|
|
66
|
-
special = false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
# Store password in SSM
|
|
70
|
-
resource "aws_ssm_parameter" "db_password" {
|
|
71
|
-
name = "/${var.app_name}/${var.environment}/db-password"
|
|
72
|
-
description = "Database password for ${var.app_name}"
|
|
73
|
-
type = "SecureString"
|
|
74
|
-
value = random_password.db_password.result
|
|
75
|
-
|
|
76
|
-
tags = {
|
|
77
|
-
Environment = var.environment
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# Outputs
|
|
82
|
-
output "endpoint" {
|
|
83
|
-
value = aws_db_instance.main.endpoint
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
output "db_name" {
|
|
87
|
-
value = aws_db_instance.main.db_name
|
|
88
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# VPC Module
|
|
2
|
-
|
|
3
|
-
variable "app_name" {
|
|
4
|
-
type = string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
variable "environment" {
|
|
8
|
-
type = string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
# VPC
|
|
12
|
-
resource "aws_vpc" "main" {
|
|
13
|
-
cidr_block = "10.0.0.0/16"
|
|
14
|
-
enable_dns_hostnames = true
|
|
15
|
-
enable_dns_support = true
|
|
16
|
-
|
|
17
|
-
tags = {
|
|
18
|
-
Name = "${var.app_name}-${var.environment}-vpc"
|
|
19
|
-
Environment = var.environment
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
# Public Subnets
|
|
24
|
-
resource "aws_subnet" "public" {
|
|
25
|
-
count = 2
|
|
26
|
-
vpc_id = aws_vpc.main.id
|
|
27
|
-
cidr_block = "10.0.${count.index + 1}.0/24"
|
|
28
|
-
availability_zone = data.aws_availability_zones.available.names[count.index]
|
|
29
|
-
|
|
30
|
-
map_public_ip_on_launch = true
|
|
31
|
-
|
|
32
|
-
tags = {
|
|
33
|
-
Name = "${var.app_name}-${var.environment}-public-${count.index + 1}"
|
|
34
|
-
Environment = var.environment
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# Private Subnets
|
|
39
|
-
resource "aws_subnet" "private" {
|
|
40
|
-
count = 2
|
|
41
|
-
vpc_id = aws_vpc.main.id
|
|
42
|
-
cidr_block = "10.0.${count.index + 10}.0/24"
|
|
43
|
-
availability_zone = data.aws_availability_zones.available.names[count.index]
|
|
44
|
-
|
|
45
|
-
tags = {
|
|
46
|
-
Name = "${var.app_name}-${var.environment}-private-${count.index + 1}"
|
|
47
|
-
Environment = var.environment
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
# Internet Gateway
|
|
52
|
-
resource "aws_internet_gateway" "main" {
|
|
53
|
-
vpc_id = aws_vpc.main.id
|
|
54
|
-
|
|
55
|
-
tags = {
|
|
56
|
-
Name = "${var.app_name}-${var.environment}-igw"
|
|
57
|
-
Environment = var.environment
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Data source for AZs
|
|
62
|
-
data "aws_availability_zones" "available" {
|
|
63
|
-
state = "available"
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
# Security Group for DB
|
|
67
|
-
resource "aws_security_group" "db" {
|
|
68
|
-
name = "${var.app_name}-${var.environment}-db-sg"
|
|
69
|
-
description = "Security group for database"
|
|
70
|
-
vpc_id = aws_vpc.main.id
|
|
71
|
-
|
|
72
|
-
ingress {
|
|
73
|
-
from_port = 5432
|
|
74
|
-
to_port = 5432
|
|
75
|
-
protocol = "tcp"
|
|
76
|
-
cidr_blocks = ["10.0.0.0/16"]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
egress {
|
|
80
|
-
from_port = 0
|
|
81
|
-
to_port = 0
|
|
82
|
-
protocol = "-1"
|
|
83
|
-
cidr_blocks = ["0.0.0.0/0"]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
tags = {
|
|
87
|
-
Name = "${var.app_name}-${var.environment}-db-sg"
|
|
88
|
-
Environment = var.environment
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# Outputs
|
|
93
|
-
output "vpc_id" {
|
|
94
|
-
value = aws_vpc.main.id
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
output "public_subnet_ids" {
|
|
98
|
-
value = aws_subnet.public[*].id
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
output "private_subnet_ids" {
|
|
102
|
-
value = aws_subnet.private[*].id
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
output "db_security_group_id" {
|
|
106
|
-
value = aws_security_group.db.id
|
|
107
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{kebabCase projectName}}",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Generated by Kybernus CLI (Pro)",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "tsx watch src/index.ts",
|
|
8
|
-
"build": "rimraf dist && tsc",
|
|
9
|
-
"start": "node dist/index.js",
|
|
10
|
-
"lint": "eslint src --ext .ts",
|
|
11
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
-
"test": "jest"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"express",
|
|
16
|
-
"api",
|
|
17
|
-
"typescript",
|
|
18
|
-
"mvc",
|
|
19
|
-
"saas",
|
|
20
|
-
"stripe",
|
|
21
|
-
"auth"
|
|
22
|
-
],
|
|
23
|
-
"author": "",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"express": "^4.18.2",
|
|
27
|
-
"dotenv": "^16.4.5",
|
|
28
|
-
"cors": "^2.8.5",
|
|
29
|
-
"helmet": "^7.1.0",
|
|
30
|
-
"morgan": "^1.10.0",
|
|
31
|
-
"jsonwebtoken": "^9.0.2",
|
|
32
|
-
"bcryptjs": "^2.4.3",
|
|
33
|
-
"stripe": "^14.14.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/express": "^4.17.21",
|
|
37
|
-
"@types/node": "^20.11.19",
|
|
38
|
-
"@types/cors": "^2.8.17",
|
|
39
|
-
"@types/morgan": "^1.9.9",
|
|
40
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
41
|
-
"@types/bcryptjs": "^2.4.6",
|
|
42
|
-
"typescript": "^5.3.3",
|
|
43
|
-
"tsx": "^4.7.1",
|
|
44
|
-
"rimraf": "^5.0.5",
|
|
45
|
-
"eslint": "^8.56.0",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
47
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
48
|
-
"prettier": "^3.2.5",
|
|
49
|
-
"jest": "^29.7.0",
|
|
50
|
-
"@types/jest": "^29.5.12"
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=18.0.0"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { IUserRepository } from '../../domain/repositories/IUserRepository';
|
|
2
|
-
import { RegisterUserUseCase } from '../../domain/usecases/RegisterUserUseCase';
|
|
3
|
-
import { LoginUserUseCase } from '../../domain/usecases/LoginUserUseCase';
|
|
4
|
-
|
|
5
|
-
export interface RegisterDTO {
|
|
6
|
-
email: string;
|
|
7
|
-
name: string;
|
|
8
|
-
password: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface LoginDTO {
|
|
12
|
-
email: string;
|
|
13
|
-
password: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface AuthResponseDTO {
|
|
17
|
-
token: string;
|
|
18
|
-
user: {
|
|
19
|
-
id: string;
|
|
20
|
-
email: string;
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Auth Service - Application Layer
|
|
27
|
-
* Orchestrates use cases and handles DTOs
|
|
28
|
-
*/
|
|
29
|
-
export class AuthService {
|
|
30
|
-
private registerUseCase: RegisterUserUseCase;
|
|
31
|
-
private loginUseCase: LoginUserUseCase;
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
userRepository: IUserRepository,
|
|
35
|
-
passwordHasher: { hash: (password: string) => Promise<string>; compare: (password: string, hash: string) => Promise
|
|
36
|
-
<boolean> },
|
|
37
|
-
tokenGenerator: { generate: (userId: string, email: string) => string }
|
|
38
|
-
) {
|
|
39
|
-
this.registerUseCase = new RegisterUserUseCase(userRepository, passwordHasher, tokenGenerator);
|
|
40
|
-
this.loginUseCase = new LoginUserUseCase(userRepository, passwordHasher, tokenGenerator);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async register(dto: RegisterDTO): Promise<AuthResponseDTO> {
|
|
44
|
-
const result = await this.registerUseCase.execute(dto);
|
|
45
|
-
return {
|
|
46
|
-
token: result.token,
|
|
47
|
-
user: {
|
|
48
|
-
id: result.user.id!,
|
|
49
|
-
email: result.user.email,
|
|
50
|
-
name: result.user.name,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async login(dto: LoginDTO): Promise<AuthResponseDTO> {
|
|
56
|
-
const result = await this.loginUseCase.execute(dto);
|
|
57
|
-
return {
|
|
58
|
-
token: result.token,
|
|
59
|
-
user: {
|
|
60
|
-
id: result.user.id!,
|
|
61
|
-
email: result.user.email,
|
|
62
|
-
name: result.user.name,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User Entity - Domain Layer
|
|
3
|
-
* Pure business logic, no framework dependencies
|
|
4
|
-
*/
|
|
5
|
-
export interface UserProps {
|
|
6
|
-
id?: string;
|
|
7
|
-
email: string;
|
|
8
|
-
name: string;
|
|
9
|
-
password: string;
|
|
10
|
-
stripeCustomerId?: string;
|
|
11
|
-
createdAt?: Date;
|
|
12
|
-
updatedAt?: Date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class User {
|
|
16
|
-
private props: UserProps;
|
|
17
|
-
|
|
18
|
-
private constructor(props: UserProps) {
|
|
19
|
-
this.props = {
|
|
20
|
-
...props,
|
|
21
|
-
createdAt: props.createdAt || new Date(),
|
|
22
|
-
updatedAt: props.updatedAt || new Date(),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static create(props: UserProps): User {
|
|
27
|
-
// Domain validation
|
|
28
|
-
if (!props.email || !props.email.includes('@')) {
|
|
29
|
-
throw new Error('Invalid email format');
|
|
30
|
-
}
|
|
31
|
-
if (!props.password || props.password.length < 8) { throw new Error('Password must be at least 8 characters'); } return
|
|
32
|
-
new User(props); } static restore(props: UserProps): User { return new User(props); } get id(): string | undefined {
|
|
33
|
-
return this.props.id; } get email(): string { return this.props.email; } get name(): string { return
|
|
34
|
-
this.props.name; } get password(): string { return this.props.password; } get stripeCustomerId(): string | undefined
|
|
35
|
-
{ return this.props.stripeCustomerId; } setStripeCustomerId(customerId: string): void {
|
|
36
|
-
this.props.stripeCustomerId=customerId; this.props.updatedAt=new Date(); } toJSON() { return { id: this.props.id,
|
|
37
|
-
email: this.props.email, name: this.props.name, stripeCustomerId: this.props.stripeCustomerId, createdAt:
|
|
38
|
-
this.props.createdAt, updatedAt: this.props.updatedAt, }; } }
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { User } from '../entities/User';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* User Repository Interface - Domain Layer
|
|
5
|
-
* Defines the contract for user persistence
|
|
6
|
-
*/
|
|
7
|
-
export interface IUserRepository {
|
|
8
|
-
findById(id: string): Promise<User | null>;
|
|
9
|
-
findByEmail(email: string): Promise<User | null>;
|
|
10
|
-
save(user: User): Promise<User>;
|
|
11
|
-
update(user: User): Promise<User>;
|
|
12
|
-
delete(id: string): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { User } from '../entities/User';
|
|
2
|
-
import { IUserRepository } from '../repositories/IUserRepository';
|
|
3
|
-
|
|
4
|
-
export interface LoginUserInput {
|
|
5
|
-
email: string;
|
|
6
|
-
password: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface LoginUserOutput {
|
|
10
|
-
user: User;
|
|
11
|
-
token: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Login User Use Case - Domain Layer
|
|
16
|
-
*/
|
|
17
|
-
export class LoginUserUseCase {
|
|
18
|
-
constructor(
|
|
19
|
-
private userRepository: IUserRepository,
|
|
20
|
-
private passwordHasher: { compare: (password: string, hash: string) => Promise<boolean> },
|
|
21
|
-
private tokenGenerator: { generate: (userId: string, email: string) => string }
|
|
22
|
-
) {}
|
|
23
|
-
|
|
24
|
-
async execute(input: LoginUserInput): Promise<LoginUserOutput> {
|
|
25
|
-
const user = await this.userRepository.findByEmail(input.email);
|
|
26
|
-
if (!user) {
|
|
27
|
-
throw new Error('Invalid credentials');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const isValidPassword = await this.passwordHasher.compare(input.password, user.password);
|
|
31
|
-
if (!isValidPassword) {
|
|
32
|
-
throw new Error('Invalid credentials');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const token = this.tokenGenerator.generate(user.id!, user.email);
|
|
36
|
-
|
|
37
|
-
return { user, token };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { User } from '../entities/User';
|
|
2
|
-
import { IUserRepository } from '../repositories/IUserRepository';
|
|
3
|
-
|
|
4
|
-
export interface RegisterUserInput {
|
|
5
|
-
email: string;
|
|
6
|
-
name: string;
|
|
7
|
-
password: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface RegisterUserOutput {
|
|
11
|
-
user: User;
|
|
12
|
-
token: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Register User Use Case - Domain Layer
|
|
17
|
-
* Pure business logic for user registration
|
|
18
|
-
*/
|
|
19
|
-
export class RegisterUserUseCase {
|
|
20
|
-
constructor(
|
|
21
|
-
private userRepository: IUserRepository,
|
|
22
|
-
private passwordHasher: { hash: (password: string) => Promise<string> },
|
|
23
|
-
private tokenGenerator: { generate: (userId: string, email: string) => string }
|
|
24
|
-
) {}
|
|
25
|
-
|
|
26
|
-
async execute(input: RegisterUserInput): Promise<RegisterUserOutput> {
|
|
27
|
-
// Check if user already exists
|
|
28
|
-
const existingUser = await this.userRepository.findByEmail(input.email);
|
|
29
|
-
if (existingUser) {
|
|
30
|
-
throw new Error('User already exists');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Hash password
|
|
34
|
-
const hashedPassword = await this.passwordHasher.hash(input.password);
|
|
35
|
-
|
|
36
|
-
// Create user entity
|
|
37
|
-
const user = User.create({
|
|
38
|
-
email: input.email,
|
|
39
|
-
name: input.name,
|
|
40
|
-
password: hashedPassword,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Persist user
|
|
44
|
-
const savedUser = await this.userRepository.save(user);
|
|
45
|
-
|
|
46
|
-
// Generate token
|
|
47
|
-
const token = this.tokenGenerator.generate(savedUser.id!, savedUser.email);
|
|
48
|
-
|
|
49
|
-
return { user: savedUser, token };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import cors from 'cors';
|
|
3
|
-
import helmet from 'helmet';
|
|
4
|
-
import morgan from 'morgan';
|
|
5
|
-
import dotenv from 'dotenv';
|
|
6
|
-
|
|
7
|
-
import authRoutes from './infrastructure/http/controllers/AuthController';
|
|
8
|
-
|
|
9
|
-
dotenv.config();
|
|
10
|
-
|
|
11
|
-
const app = express();
|
|
12
|
-
|
|
13
|
-
// Security
|
|
14
|
-
app.use(helmet());
|
|
15
|
-
app.use(cors());
|
|
16
|
-
app.use(morgan('dev'));
|
|
17
|
-
|
|
18
|
-
// Body parsing
|
|
19
|
-
app.use(express.json());
|
|
20
|
-
app.use(express.urlencoded({ extended: true }));
|
|
21
|
-
|
|
22
|
-
// Health check
|
|
23
|
-
app.get('/health', (_, res) => res.json({ status: 'ok' }));
|
|
24
|
-
|
|
25
|
-
// Routes
|
|
26
|
-
app.use('/api/auth', authRoutes);
|
|
27
|
-
|
|
28
|
-
// Error handling
|
|
29
|
-
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
30
|
-
console.error(err.stack);
|
|
31
|
-
res.status(500).json({ error: 'Internal server error' });
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const PORT = process.env.PORT || 3000;
|
|
35
|
-
|
|
36
|
-
app.listen(PORT, () => {
|
|
37
|
-
console.log(`🚀 {{pascalCase projectName}} running on port ${PORT}`);
|
|
38
|
-
console.log(`📐 Architecture: Clean Architecture`);
|
|
39
|
-
console.log(`🔗 Health check: http://localhost:${PORT}/health`);
|
|
40
|
-
});
|
package/templates/nodejs-express/pro/clean/src/infrastructure/database/InMemoryUserRepository.ts.hbs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { User } from '../../domain/entities/User';
|
|
2
|
-
import { IUserRepository } from '../../domain/repositories/IUserRepository';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* In-Memory User Repository - Infrastructure Layer
|
|
6
|
-
* Replace with actual database implementation (Prisma, TypeORM, etc.)
|
|
7
|
-
*/
|
|
8
|
-
export class InMemoryUserRepository implements IUserRepository {
|
|
9
|
-
private users: Map<string, User> = new Map();
|
|
10
|
-
|
|
11
|
-
async findById(id: string): Promise<User | null> {
|
|
12
|
-
return this.users.get(id) || null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async findByEmail(email: string): Promise<User | null> {
|
|
16
|
-
for (const user of this.users.values()) {
|
|
17
|
-
if (user.email === email) {
|
|
18
|
-
return user;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async save(user: User): Promise<User> {
|
|
25
|
-
const id = Date.now().toString();
|
|
26
|
-
const savedUser = User.restore({
|
|
27
|
-
id,
|
|
28
|
-
email: user.email,
|
|
29
|
-
name: user.name,
|
|
30
|
-
password: user.password,
|
|
31
|
-
stripeCustomerId: user.stripeCustomerId,
|
|
32
|
-
});
|
|
33
|
-
this.users.set(id, savedUser);
|
|
34
|
-
return savedUser;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async update(user: User): Promise<User> {
|
|
38
|
-
if (!user.id) throw new Error('User must have an ID to update');
|
|
39
|
-
this.users.set(user.id, user);
|
|
40
|
-
return user;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async delete(id: string): Promise<void> {
|
|
44
|
-
this.users.delete(id);
|
|
45
|
-
}
|
|
46
|
-
}
|
package/templates/nodejs-express/pro/clean/src/infrastructure/http/controllers/AuthController.ts.hbs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Router, Request, Response } from 'express';
|
|
2
|
-
import { AuthService } from '../../../application/services/AuthService';
|
|
3
|
-
import { InMemoryUserRepository } from '../../database/InMemoryUserRepository';
|
|
4
|
-
import { bcryptPasswordHasher } from '../../providers/PasswordHasher';
|
|
5
|
-
import { jwtTokenGenerator } from '../../providers/TokenGenerator';
|
|
6
|
-
import { authMiddleware, AuthRequest } from '../middlewares/AuthMiddleware';
|
|
7
|
-
|
|
8
|
-
const router = Router();
|
|
9
|
-
|
|
10
|
-
// Dependency Injection
|
|
11
|
-
const userRepository = new InMemoryUserRepository();
|
|
12
|
-
const authService = new AuthService(userRepository, bcryptPasswordHasher, jwtTokenGenerator);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @route POST /api/auth/register
|
|
16
|
-
*/
|
|
17
|
-
router.post('/register', async (req: Request, res: Response) => {
|
|
18
|
-
try {
|
|
19
|
-
const result = await authService.register(req.body);
|
|
20
|
-
res.status(201).json(result);
|
|
21
|
-
} catch (error: any) {
|
|
22
|
-
res.status(400).json({ error: error.message });
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @route POST /api/auth/login
|
|
28
|
-
*/
|
|
29
|
-
router.post('/login', async (req: Request, res: Response) => {
|
|
30
|
-
try {
|
|
31
|
-
const result = await authService.login(req.body);
|
|
32
|
-
res.json(result);
|
|
33
|
-
} catch (error: any) {
|
|
34
|
-
res.status(401).json({ error: error.message });
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @route GET /api/auth/me
|
|
40
|
-
*/
|
|
41
|
-
router.get('/me', authMiddleware, (req: AuthRequest, res: Response) => {
|
|
42
|
-
res.json({ user: req.user });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default router;
|
package/templates/nodejs-express/pro/clean/src/infrastructure/http/middlewares/AuthMiddleware.ts.hbs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
import { jwtTokenGenerator } from '../../providers/TokenGenerator';
|
|
3
|
-
|
|
4
|
-
export interface AuthRequest extends Request {
|
|
5
|
-
user?: {
|
|
6
|
-
id: string;
|
|
7
|
-
email: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function authMiddleware(req: AuthRequest, res: Response, next: NextFunction) {
|
|
12
|
-
const authHeader = req.headers.authorization;
|
|
13
|
-
|
|
14
|
-
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
15
|
-
return res.status(401).json({ error: 'Token not provided' });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const token = authHeader.split(' ')[1];
|
|
19
|
-
const decoded = jwtTokenGenerator.verify(token);
|
|
20
|
-
|
|
21
|
-
if (!decoded) {
|
|
22
|
-
return res.status(401).json({ error: 'Invalid token' });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
req.user = decoded;
|
|
26
|
-
next();
|
|
27
|
-
}
|
package/templates/nodejs-express/pro/clean/src/infrastructure/providers/PasswordHasher.ts.hbs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import bcrypt from 'bcryptjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Bcrypt Password Hasher - Infrastructure Provider
|
|
5
|
-
*/
|
|
6
|
-
export const bcryptPasswordHasher = {
|
|
7
|
-
async hash(password: string): Promise<string> {
|
|
8
|
-
return bcrypt.hash(password, 10);
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
async compare(password: string, hash: string): Promise<boolean> {
|
|
12
|
-
return bcrypt.compare(password, hash);
|
|
13
|
-
},
|
|
14
|
-
};
|
package/templates/nodejs-express/pro/clean/src/infrastructure/providers/TokenGenerator.ts.hbs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import jwt from 'jsonwebtoken';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* JWT Token Generator - Infrastructure Provider
|
|
5
|
-
*/
|
|
6
|
-
export const jwtTokenGenerator = {
|
|
7
|
-
generate(userId: string, email: string): string {
|
|
8
|
-
return jwt.sign(
|
|
9
|
-
{ id: userId, email },
|
|
10
|
-
process.env.JWT_SECRET || 'your-secret-key',
|
|
11
|
-
{ expiresIn: '7d' }
|
|
12
|
-
);
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
verify(token: string): { id: string; email: string } | null {
|
|
16
|
-
try {
|
|
17
|
-
return jwt.verify(token, process.env.JWT_SECRET || 'your-secret-key') as {
|
|
18
|
-
id: string;
|
|
19
|
-
email: string;
|
|
20
|
-
};
|
|
21
|
-
} catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": [
|
|
6
|
-
"ES2022"
|
|
7
|
-
],
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": "./src",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"types": [
|
|
17
|
-
"node"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"include": [
|
|
21
|
-
"src/**/*"
|
|
22
|
-
],
|
|
23
|
-
"exclude": [
|
|
24
|
-
"node_modules",
|
|
25
|
-
"dist"
|
|
26
|
-
]
|
|
27
|
-
}
|