kybernus 1.0.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/README.md +321 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +71 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/login.d.ts +6 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +42 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/logout.d.ts +2 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +22 -0
- package/dist/cli/commands/logout.js.map +1 -0
- package/dist/cli/commands/register.d.ts +2 -0
- package/dist/cli/commands/register.d.ts.map +1 -0
- package/dist/cli/commands/register.js +69 -0
- package/dist/cli/commands/register.js.map +1 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +46 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/upgrade.d.ts +2 -0
- package/dist/cli/commands/upgrade.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.js +62 -0
- package/dist/cli/commands/upgrade.js.map +1 -0
- package/dist/cli/prompts/wizard.d.ts +3 -0
- package/dist/cli/prompts/wizard.d.ts.map +1 -0
- package/dist/cli/prompts/wizard.js +121 -0
- package/dist/cli/prompts/wizard.js.map +1 -0
- package/dist/cli/services/AnalyticsClient.d.ts +11 -0
- package/dist/cli/services/AnalyticsClient.d.ts.map +1 -0
- package/dist/cli/services/AnalyticsClient.js +32 -0
- package/dist/cli/services/AnalyticsClient.js.map +1 -0
- package/dist/core/ai/documentation-generator.d.ts +36 -0
- package/dist/core/ai/documentation-generator.d.ts.map +1 -0
- package/dist/core/ai/documentation-generator.js +111 -0
- package/dist/core/ai/documentation-generator.js.map +1 -0
- package/dist/core/ai/gemini-service.d.ts +17 -0
- package/dist/core/ai/gemini-service.d.ts.map +1 -0
- package/dist/core/ai/gemini-service.js +68 -0
- package/dist/core/ai/gemini-service.js.map +1 -0
- package/dist/core/ai/prompts/documentation-prompts.d.ts +17 -0
- package/dist/core/ai/prompts/documentation-prompts.d.ts.map +1 -0
- package/dist/core/ai/prompts/documentation-prompts.js +195 -0
- package/dist/core/ai/prompts/documentation-prompts.js.map +1 -0
- package/dist/core/auth/license-validator.d.ts +33 -0
- package/dist/core/auth/license-validator.d.ts.map +1 -0
- package/dist/core/auth/license-validator.js +81 -0
- package/dist/core/auth/license-validator.js.map +1 -0
- package/dist/core/config/config-manager.d.ts +24 -0
- package/dist/core/config/config-manager.d.ts.map +1 -0
- package/dist/core/config/config-manager.js +56 -0
- package/dist/core/config/config-manager.js.map +1 -0
- package/dist/core/generator/context-builder.d.ts +10 -0
- package/dist/core/generator/context-builder.d.ts.map +1 -0
- package/dist/core/generator/context-builder.js +43 -0
- package/dist/core/generator/context-builder.js.map +1 -0
- package/dist/core/generator/project.d.ts +42 -0
- package/dist/core/generator/project.d.ts.map +1 -0
- package/dist/core/generator/project.js +278 -0
- package/dist/core/generator/project.js.map +1 -0
- package/dist/core/templates/engine.d.ts +25 -0
- package/dist/core/templates/engine.d.ts.map +1 -0
- package/dist/core/templates/engine.js +78 -0
- package/dist/core/templates/engine.js.map +1 -0
- package/dist/core/templates/helpers.d.ts +6 -0
- package/dist/core/templates/helpers.d.ts.map +1 -0
- package/dist/core/templates/helpers.js +63 -0
- package/dist/core/templates/helpers.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/models/config.d.ts +38 -0
- package/dist/models/config.d.ts.map +1 -0
- package/dist/models/config.js +2 -0
- package/dist/models/config.js.map +1 -0
- package/package.json +66 -0
- package/templates/java-spring/free/mvc/.gitignore.hbs +39 -0
- package/templates/java-spring/free/mvc/README.md.hbs +116 -0
- package/templates/java-spring/free/mvc/docker-compose.yml.hbs +18 -0
- package/templates/java-spring/free/mvc/pom.xml.hbs +92 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/config/GlobalExceptionHandler.java.hbs +39 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/config/WebConfig.java.hbs +30 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/controller/HealthController.java.hbs +30 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/model/.gitkeep +0 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/repository/.gitkeep +0 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/service/.gitkeep +0 -0
- package/templates/java-spring/free/mvc/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +13 -0
- package/templates/java-spring/free/mvc/src/main/resources/application.yml.hbs +32 -0
- package/templates/java-spring/free/mvc/src/test/java/{{packagePath}}/{{projectNamePascalCase}}ApplicationTests.java.hbs +13 -0
- package/templates/java-spring/free/mvc/src/test/resources/application.yml.hbs +10 -0
- package/templates/java-spring/free/mvc/template.json +14 -0
- package/templates/java-spring/pro/clean/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/java-spring/pro/clean/Dockerfile.hbs +45 -0
- package/templates/java-spring/pro/clean/README.md.hbs +31 -0
- package/templates/java-spring/pro/clean/docker-compose.yml.hbs +18 -0
- package/templates/java-spring/pro/clean/infra/main.tf.hbs +83 -0
- package/templates/java-spring/pro/clean/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/java-spring/pro/clean/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/java-spring/pro/clean/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/java-spring/pro/clean/pom.xml.hbs +130 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/application/service/AuthService.java.hbs +36 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/entity/User.java.hbs +77 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/repository/UserRepository.java.hbs +15 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/usecase/LoginUserUseCase.java.hbs +36 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/domain/usecase/RegisterUserUseCase.java.hbs +46 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/persistence/InMemoryUserRepository.java.hbs +41 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/security/SecurityAdapters.java.hbs +53 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/infrastructure/web/controller/AuthController.java.hbs +41 -0
- package/templates/java-spring/pro/clean/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +14 -0
- package/templates/java-spring/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/java-spring/pro/hexagonal/Dockerfile.hbs +45 -0
- package/templates/java-spring/pro/hexagonal/README.md.hbs +38 -0
- package/templates/java-spring/pro/hexagonal/docker-compose.yml.hbs +18 -0
- package/templates/java-spring/pro/hexagonal/infra/main.tf.hbs +83 -0
- package/templates/java-spring/pro/hexagonal/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/java-spring/pro/hexagonal/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/java-spring/pro/hexagonal/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/java-spring/pro/hexagonal/pom.xml.hbs +130 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/application/service/AuthService.java.hbs +36 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/entity/User.java.hbs +77 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/repository/UserRepository.java.hbs +15 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/usecase/LoginUserUseCase.java.hbs +36 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/domain/usecase/RegisterUserUseCase.java.hbs +46 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/persistence/InMemoryUserRepository.java.hbs +41 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/security/SecurityAdapters.java.hbs +53 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/infrastructure/web/controller/AuthController.java.hbs +41 -0
- package/templates/java-spring/pro/hexagonal/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +14 -0
- package/templates/java-spring/pro/mvc/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/java-spring/pro/mvc/Dockerfile.hbs +45 -0
- package/templates/java-spring/pro/mvc/README.md.hbs +116 -0
- package/templates/java-spring/pro/mvc/docker-compose.yml.hbs +18 -0
- package/templates/java-spring/pro/mvc/infra/main.tf.hbs +83 -0
- package/templates/java-spring/pro/mvc/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/java-spring/pro/mvc/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/java-spring/pro/mvc/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/java-spring/pro/mvc/pom.xml.hbs +130 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/GlobalExceptionHandler.java.hbs +39 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/SecurityConfig.java.hbs +44 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/config/WebConfig.java.hbs +30 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/AuthController.java.hbs +69 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/HealthController.java.hbs +30 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/controller/PaymentsController.java.hbs +49 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/dto/AuthRequest.java.hbs +3 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/dto/AuthResponse.java.hbs +3 -0
- 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 +56 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/security/JwtTokenProvider.java.hbs +59 -0
- 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 +67 -0
- package/templates/java-spring/pro/mvc/src/main/java/{{packagePath}}/{{projectNamePascalCase}}Application.java.hbs +13 -0
- package/templates/java-spring/pro/mvc/src/main/resources/application.yml.hbs +32 -0
- package/templates/java-spring/pro/mvc/src/test/java/{{packagePath}}/{{projectNamePascalCase}}ApplicationTests.java.hbs +13 -0
- package/templates/java-spring/pro/mvc/src/test/resources/application.yml.hbs +10 -0
- package/templates/java-spring/pro/mvc/template.json +14 -0
- package/templates/nestjs/free/mvc/README.md.hbs +28 -0
- package/templates/nestjs/free/mvc/package.json.hbs +29 -0
- package/templates/nestjs/free/mvc/src/app.module.ts.hbs +13 -0
- package/templates/nestjs/free/mvc/src/controllers/health.controller.ts.hbs +9 -0
- package/templates/nestjs/free/mvc/src/controllers/items.controller.ts.hbs +32 -0
- package/templates/nestjs/free/mvc/src/main.ts.hbs +17 -0
- package/templates/nestjs/free/mvc/src/models/create-item.dto.ts.hbs +10 -0
- package/templates/nestjs/free/mvc/src/models/item.model.ts.hbs +6 -0
- package/templates/nestjs/free/mvc/src/modules/items.module.ts.hbs +9 -0
- package/templates/nestjs/free/mvc/src/services/items.service.ts.hbs +32 -0
- package/templates/nestjs/free/mvc/tsconfig.json.hbs +21 -0
- package/templates/nestjs/pro/clean/.env.example.hbs +19 -0
- package/templates/nestjs/pro/clean/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nestjs/pro/clean/Dockerfile.hbs +45 -0
- package/templates/nestjs/pro/clean/infra/main.tf.hbs +83 -0
- package/templates/nestjs/pro/clean/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nestjs/pro/clean/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nestjs/pro/clean/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nestjs/pro/clean/package.json.hbs +37 -0
- package/templates/nestjs/pro/clean/src/auth.module.ts.hbs +17 -0
- package/templates/nestjs/pro/clean/src/domain/entities/user.entity.ts.hbs +12 -0
- package/templates/nestjs/pro/clean/src/domain/repositories/user.repository.ts.hbs +6 -0
- package/templates/nestjs/pro/clean/src/domain/use-cases/register.use-case.ts.hbs +18 -0
- package/templates/nestjs/pro/clean/src/infrastructure/database/in-memory.repository.ts.hbs +17 -0
- package/templates/nestjs/pro/clean/src/infrastructure/http/auth.controller.ts.hbs +16 -0
- package/templates/nestjs/pro/clean/tsconfig.json.hbs +21 -0
- package/templates/nestjs/pro/hexagonal/.env.example.hbs +19 -0
- package/templates/nestjs/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nestjs/pro/hexagonal/Dockerfile.hbs +45 -0
- package/templates/nestjs/pro/hexagonal/infra/main.tf.hbs +83 -0
- package/templates/nestjs/pro/hexagonal/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nestjs/pro/hexagonal/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nestjs/pro/hexagonal/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nestjs/pro/hexagonal/package.json.hbs +37 -0
- package/templates/nestjs/pro/hexagonal/src/adapters/inbound/http.adapter.ts.hbs +12 -0
- package/templates/nestjs/pro/hexagonal/src/adapters/outbound/persistence.adapter.ts.hbs +13 -0
- package/templates/nestjs/pro/hexagonal/src/auth.module.ts.hbs +19 -0
- package/templates/nestjs/pro/hexagonal/src/core/auth.service.ts.hbs +16 -0
- package/templates/nestjs/pro/hexagonal/src/core/domain/user.entity.ts.hbs +8 -0
- package/templates/nestjs/pro/hexagonal/src/core/ports/ports.ts.hbs +9 -0
- package/templates/nestjs/pro/hexagonal/tsconfig.json.hbs +21 -0
- package/templates/nestjs/pro/mvc/.env.example.hbs +19 -0
- package/templates/nestjs/pro/mvc/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nestjs/pro/mvc/Dockerfile.hbs +45 -0
- package/templates/nestjs/pro/mvc/README.md.hbs +28 -0
- package/templates/nestjs/pro/mvc/infra/main.tf.hbs +83 -0
- package/templates/nestjs/pro/mvc/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nestjs/pro/mvc/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nestjs/pro/mvc/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nestjs/pro/mvc/package.json.hbs +37 -0
- package/templates/nestjs/pro/mvc/src/app.module.ts.hbs +17 -0
- package/templates/nestjs/pro/mvc/src/auth/auth.controller.ts.hbs +35 -0
- package/templates/nestjs/pro/mvc/src/auth/auth.module.ts.hbs +25 -0
- package/templates/nestjs/pro/mvc/src/auth/auth.service.ts.hbs +55 -0
- package/templates/nestjs/pro/mvc/src/auth/jwt.strategy.ts.hbs +19 -0
- package/templates/nestjs/pro/mvc/src/controllers/health.controller.ts.hbs +9 -0
- package/templates/nestjs/pro/mvc/src/controllers/items.controller.ts.hbs +32 -0
- package/templates/nestjs/pro/mvc/src/main.ts.hbs +17 -0
- package/templates/nestjs/pro/mvc/src/models/create-item.dto.ts.hbs +10 -0
- package/templates/nestjs/pro/mvc/src/models/item.model.ts.hbs +6 -0
- package/templates/nestjs/pro/mvc/src/modules/items.module.ts.hbs +9 -0
- package/templates/nestjs/pro/mvc/src/payments/payments.controller.ts.hbs +26 -0
- package/templates/nestjs/pro/mvc/src/payments/payments.module.ts.hbs +11 -0
- package/templates/nestjs/pro/mvc/src/payments/payments.service.ts.hbs +43 -0
- package/templates/nestjs/pro/mvc/src/services/items.service.ts.hbs +32 -0
- package/templates/nestjs/pro/mvc/tsconfig.json.hbs +21 -0
- package/templates/nextjs/free/default/.env.example.hbs +1 -0
- package/templates/nextjs/free/default/.gitignore.hbs +8 -0
- package/templates/nextjs/free/default/README.md.hbs +96 -0
- package/templates/nextjs/free/default/docker-compose.yml.hbs +18 -0
- package/templates/nextjs/free/default/next.config.js.hbs +4 -0
- package/templates/nextjs/free/default/package.json.hbs +32 -0
- package/templates/nextjs/free/default/postcss.config.js.hbs +6 -0
- package/templates/nextjs/free/default/prisma/schema.prisma.hbs +18 -0
- package/templates/nextjs/free/default/public/.gitkeep +0 -0
- package/templates/nextjs/free/default/src/app/api/health/route.ts.hbs +9 -0
- package/templates/nextjs/free/default/src/app/globals.css.hbs +3 -0
- package/templates/nextjs/free/default/src/app/layout.tsx.hbs +22 -0
- package/templates/nextjs/free/default/src/app/page.tsx.hbs +38 -0
- package/templates/nextjs/free/default/src/components/.gitkeep +0 -0
- package/templates/nextjs/free/default/src/lib/prisma.ts.hbs +13 -0
- package/templates/nextjs/free/default/src/proxy.ts.hbs +22 -0
- package/templates/nextjs/free/default/tailwind.config.ts.hbs +15 -0
- package/templates/nextjs/free/default/template.json +18 -0
- package/templates/nextjs/free/default/tsconfig.json.hbs +23 -0
- package/templates/nextjs/pro/default/.env.example.hbs +20 -0
- package/templates/nextjs/pro/default/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nextjs/pro/default/Dockerfile.hbs +45 -0
- package/templates/nextjs/pro/default/README.md.hbs +96 -0
- package/templates/nextjs/pro/default/docker-compose.yml.hbs +18 -0
- package/templates/nextjs/pro/default/infra/main.tf.hbs +83 -0
- package/templates/nextjs/pro/default/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nextjs/pro/default/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nextjs/pro/default/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nextjs/pro/default/next.config.js.hbs +4 -0
- package/templates/nextjs/pro/default/package.json.hbs +34 -0
- package/templates/nextjs/pro/default/postcss.config.js.hbs +6 -0
- package/templates/nextjs/pro/default/prisma/schema.prisma.hbs +18 -0
- package/templates/nextjs/pro/default/public/.gitkeep +0 -0
- package/templates/nextjs/pro/default/src/app/api/auth/[...nextauth]/route.ts.hbs +61 -0
- package/templates/nextjs/pro/default/src/app/api/checkout/route.ts.hbs +30 -0
- package/templates/nextjs/pro/default/src/app/api/health/route.ts.hbs +9 -0
- package/templates/nextjs/pro/default/src/app/api/webhook/route.ts.hbs +51 -0
- package/templates/nextjs/pro/default/src/app/dashboard/page.tsx.hbs +52 -0
- package/templates/nextjs/pro/default/src/app/globals.css.hbs +3 -0
- package/templates/nextjs/pro/default/src/app/layout.tsx.hbs +22 -0
- package/templates/nextjs/pro/default/src/app/page.tsx.hbs +38 -0
- package/templates/nextjs/pro/default/src/components/.gitkeep +0 -0
- package/templates/nextjs/pro/default/src/components/AuthButton.tsx.hbs +34 -0
- package/templates/nextjs/pro/default/src/components/Providers.tsx.hbs +7 -0
- package/templates/nextjs/pro/default/src/lib/prisma.ts.hbs +13 -0
- package/templates/nextjs/pro/default/src/proxy.ts.hbs +22 -0
- package/templates/nextjs/pro/default/tailwind.config.ts.hbs +15 -0
- package/templates/nextjs/pro/default/template.json +18 -0
- package/templates/nextjs/pro/default/tsconfig.json.hbs +40 -0
- package/templates/nodejs-express/free/mvc/.env.example.hbs +3 -0
- package/templates/nodejs-express/free/mvc/.gitignore.hbs +6 -0
- package/templates/nodejs-express/free/mvc/README.md.hbs +128 -0
- package/templates/nodejs-express/free/mvc/docker-compose.yml.hbs +18 -0
- package/templates/nodejs-express/free/mvc/package.json.hbs +39 -0
- package/templates/nodejs-express/free/mvc/src/app.ts.hbs +29 -0
- package/templates/nodejs-express/free/mvc/src/config/database.ts.hbs +10 -0
- package/templates/nodejs-express/free/mvc/src/controllers/healthController.ts.hbs +20 -0
- package/templates/nodejs-express/free/mvc/src/index.ts.hbs +12 -0
- package/templates/nodejs-express/free/mvc/src/middleware/errorHandler.ts.hbs +22 -0
- package/templates/nodejs-express/free/mvc/src/models/.gitkeep +0 -0
- package/templates/nodejs-express/free/mvc/src/routes/index.ts.hbs +14 -0
- package/templates/nodejs-express/free/mvc/src/services/.gitkeep +0 -0
- package/templates/nodejs-express/free/mvc/template.json +18 -0
- package/templates/nodejs-express/free/mvc/tsconfig.json.hbs +18 -0
- package/templates/nodejs-express/pro/clean/.env.example.hbs +19 -0
- package/templates/nodejs-express/pro/clean/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nodejs-express/pro/clean/Dockerfile.hbs +45 -0
- package/templates/nodejs-express/pro/clean/README.md.hbs +41 -0
- package/templates/nodejs-express/pro/clean/docker-compose.yml.hbs +18 -0
- package/templates/nodejs-express/pro/clean/infra/main.tf.hbs +83 -0
- package/templates/nodejs-express/pro/clean/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nodejs-express/pro/clean/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nodejs-express/pro/clean/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nodejs-express/pro/clean/package.json.hbs +55 -0
- package/templates/nodejs-express/pro/clean/src/application/services/AuthService.ts.hbs +66 -0
- package/templates/nodejs-express/pro/clean/src/domain/entities/User.ts.hbs +38 -0
- package/templates/nodejs-express/pro/clean/src/domain/repositories/IUserRepository.ts.hbs +13 -0
- package/templates/nodejs-express/pro/clean/src/domain/usecases/LoginUserUseCase.ts.hbs +39 -0
- package/templates/nodejs-express/pro/clean/src/domain/usecases/RegisterUserUseCase.ts.hbs +51 -0
- package/templates/nodejs-express/pro/clean/src/index.ts.hbs +40 -0
- package/templates/nodejs-express/pro/clean/src/infrastructure/database/InMemoryUserRepository.ts.hbs +46 -0
- package/templates/nodejs-express/pro/clean/src/infrastructure/http/controllers/AuthController.ts.hbs +45 -0
- package/templates/nodejs-express/pro/clean/src/infrastructure/http/middlewares/AuthMiddleware.ts.hbs +27 -0
- package/templates/nodejs-express/pro/clean/src/infrastructure/providers/PasswordHasher.ts.hbs +14 -0
- package/templates/nodejs-express/pro/clean/src/infrastructure/providers/TokenGenerator.ts.hbs +25 -0
- package/templates/nodejs-express/pro/clean/tsconfig.json.hbs +27 -0
- package/templates/nodejs-express/pro/hexagonal/.env.example.hbs +19 -0
- package/templates/nodejs-express/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nodejs-express/pro/hexagonal/Dockerfile.hbs +45 -0
- package/templates/nodejs-express/pro/hexagonal/README.md.hbs +42 -0
- package/templates/nodejs-express/pro/hexagonal/docker-compose.yml.hbs +18 -0
- package/templates/nodejs-express/pro/hexagonal/infra/main.tf.hbs +83 -0
- package/templates/nodejs-express/pro/hexagonal/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nodejs-express/pro/hexagonal/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nodejs-express/pro/hexagonal/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nodejs-express/pro/hexagonal/package.json.hbs +55 -0
- package/templates/nodejs-express/pro/hexagonal/src/adapters/inbound/http/AuthController.ts.hbs +48 -0
- package/templates/nodejs-express/pro/hexagonal/src/adapters/outbound/SecurityAdapters.ts.hbs +31 -0
- package/templates/nodejs-express/pro/hexagonal/src/adapters/outbound/persistence/InMemoryUserAdapter.ts.hbs +38 -0
- package/templates/nodejs-express/pro/hexagonal/src/core/AuthService.ts.hbs +51 -0
- package/templates/nodejs-express/pro/hexagonal/src/core/domain/entities/User.ts.hbs +28 -0
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/inbound/IAuthPort.ts.hbs +11 -0
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/outbound/ISecurityPorts.ts.hbs +15 -0
- package/templates/nodejs-express/pro/hexagonal/src/core/ports/outbound/IUserRepositoryPort.ts.hbs +13 -0
- package/templates/nodejs-express/pro/hexagonal/src/index.ts.hbs +41 -0
- package/templates/nodejs-express/pro/hexagonal/tsconfig.json.hbs +27 -0
- package/templates/nodejs-express/pro/mvc/.env.example.hbs +19 -0
- package/templates/nodejs-express/pro/mvc/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/nodejs-express/pro/mvc/Dockerfile.hbs +45 -0
- package/templates/nodejs-express/pro/mvc/README.md.hbs +85 -0
- package/templates/nodejs-express/pro/mvc/docker-compose.yml.hbs +18 -0
- package/templates/nodejs-express/pro/mvc/infra/main.tf.hbs +83 -0
- package/templates/nodejs-express/pro/mvc/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/nodejs-express/pro/mvc/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/nodejs-express/pro/mvc/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/nodejs-express/pro/mvc/package.json.hbs +55 -0
- package/templates/nodejs-express/pro/mvc/src/app.ts.hbs +34 -0
- package/templates/nodejs-express/pro/mvc/src/config/database.ts.hbs +10 -0
- package/templates/nodejs-express/pro/mvc/src/controllers/auth.controller.ts.hbs +91 -0
- package/templates/nodejs-express/pro/mvc/src/controllers/healthController.ts.hbs +20 -0
- package/templates/nodejs-express/pro/mvc/src/controllers/payments.controller.ts.hbs +72 -0
- package/templates/nodejs-express/pro/mvc/src/index.ts.hbs +12 -0
- package/templates/nodejs-express/pro/mvc/src/middleware/errorHandler.ts.hbs +22 -0
- package/templates/nodejs-express/pro/mvc/src/middlewares/auth.middleware.ts.hbs +31 -0
- package/templates/nodejs-express/pro/mvc/src/models/.gitkeep +0 -0
- package/templates/nodejs-express/pro/mvc/src/routes/index.ts.hbs +14 -0
- package/templates/nodejs-express/pro/mvc/src/services/.gitkeep +0 -0
- package/templates/nodejs-express/pro/mvc/src/services/stripe.service.ts.hbs +102 -0
- package/templates/nodejs-express/pro/mvc/template.json +18 -0
- package/templates/nodejs-express/pro/mvc/tsconfig.json.hbs +27 -0
- package/templates/python-fastapi/free/mvc/README.md.hbs +41 -0
- package/templates/python-fastapi/free/mvc/app/controllers/health.py.hbs +7 -0
- package/templates/python-fastapi/free/mvc/app/controllers/items.py.hbs +27 -0
- package/templates/python-fastapi/free/mvc/app/main.py.hbs +26 -0
- package/templates/python-fastapi/free/mvc/app/models/item.py.hbs +11 -0
- package/templates/python-fastapi/free/mvc/app/schemas/item.py.hbs +17 -0
- package/templates/python-fastapi/free/mvc/app/services/item_service.py.hbs +33 -0
- package/templates/python-fastapi/free/mvc/requirements.txt.hbs +4 -0
- package/templates/python-fastapi/pro/clean/.env.example.hbs +17 -0
- package/templates/python-fastapi/pro/clean/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/python-fastapi/pro/clean/Dockerfile.hbs +20 -0
- package/templates/python-fastapi/pro/clean/app/domain/entities/user.py.hbs +23 -0
- package/templates/python-fastapi/pro/clean/app/domain/repositories/user_repository.py.hbs +22 -0
- package/templates/python-fastapi/pro/clean/app/domain/usecases/register_user.py.hbs +30 -0
- package/templates/python-fastapi/pro/clean/app/infrastructure/database/in_memory_repository.py.hbs +26 -0
- package/templates/python-fastapi/pro/clean/app/infrastructure/http/auth_controller.py.hbs +26 -0
- package/templates/python-fastapi/pro/clean/app/infrastructure/security/adapters.py.hbs +23 -0
- package/templates/python-fastapi/pro/clean/app/main.py.hbs +10 -0
- package/templates/python-fastapi/pro/clean/infra/main.tf.hbs +83 -0
- package/templates/python-fastapi/pro/clean/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/python-fastapi/pro/clean/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/python-fastapi/pro/clean/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/python-fastapi/pro/clean/requirements.txt.hbs +12 -0
- package/templates/python-fastapi/pro/hexagonal/.env.example.hbs +17 -0
- package/templates/python-fastapi/pro/hexagonal/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/python-fastapi/pro/hexagonal/Dockerfile.hbs +20 -0
- package/templates/python-fastapi/pro/hexagonal/app/adapters/inbound/http_adapter.py.hbs +29 -0
- package/templates/python-fastapi/pro/hexagonal/app/core/domain/user.py.hbs +15 -0
- package/templates/python-fastapi/pro/hexagonal/app/core/ports.py.hbs +25 -0
- package/templates/python-fastapi/pro/hexagonal/app/core/service.py.hbs +28 -0
- package/templates/python-fastapi/pro/hexagonal/app/main.py.hbs +22 -0
- package/templates/python-fastapi/pro/hexagonal/infra/main.tf.hbs +83 -0
- package/templates/python-fastapi/pro/hexagonal/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/python-fastapi/pro/hexagonal/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/python-fastapi/pro/hexagonal/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/python-fastapi/pro/hexagonal/requirements.txt.hbs +12 -0
- package/templates/python-fastapi/pro/mvc/.env.example.hbs +17 -0
- package/templates/python-fastapi/pro/mvc/.github/workflows/ci-cd.yml.hbs +88 -0
- package/templates/python-fastapi/pro/mvc/Dockerfile.hbs +20 -0
- package/templates/python-fastapi/pro/mvc/README.md.hbs +41 -0
- package/templates/python-fastapi/pro/mvc/app/controllers/auth.py.hbs +46 -0
- package/templates/python-fastapi/pro/mvc/app/controllers/health.py.hbs +7 -0
- package/templates/python-fastapi/pro/mvc/app/controllers/items.py.hbs +21 -0
- package/templates/python-fastapi/pro/mvc/app/controllers/payments.py.hbs +32 -0
- package/templates/python-fastapi/pro/mvc/app/main.py.hbs +20 -0
- package/templates/python-fastapi/pro/mvc/app/middleware/security.py.hbs +39 -0
- package/templates/python-fastapi/pro/mvc/app/models/item.py.hbs +11 -0
- package/templates/python-fastapi/pro/mvc/app/schemas/item.py.hbs +16 -0
- package/templates/python-fastapi/pro/mvc/app/services/item_service.py.hbs +24 -0
- package/templates/python-fastapi/pro/mvc/infra/main.tf.hbs +83 -0
- package/templates/python-fastapi/pro/mvc/infra/modules/ecs/main.tf.hbs +54 -0
- package/templates/python-fastapi/pro/mvc/infra/modules/rds/main.tf.hbs +88 -0
- package/templates/python-fastapi/pro/mvc/infra/modules/vpc/main.tf.hbs +107 -0
- package/templates/python-fastapi/pro/mvc/requirements.txt.hbs +12 -0
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import cors from 'cors';
|
|
3
|
+
import helmet from 'helmet';
|
|
4
|
+
import morgan from 'morgan';
|
|
5
|
+
import routes from './routes';
|
|
6
|
+
import authRoutes from './controllers/auth.controller';
|
|
7
|
+
import paymentsRoutes from './controllers/payments.controller';
|
|
8
|
+
import { errorHandler } from './middleware/errorHandler';
|
|
9
|
+
|
|
10
|
+
const app = express();
|
|
11
|
+
|
|
12
|
+
// Security middleware
|
|
13
|
+
app.use(helmet());
|
|
14
|
+
|
|
15
|
+
// CORS
|
|
16
|
+
app.use(cors());
|
|
17
|
+
|
|
18
|
+
// Logging
|
|
19
|
+
app.use(morgan('dev'));
|
|
20
|
+
|
|
21
|
+
// Body parsing (raw for Stripe webhooks)
|
|
22
|
+
app.use('/api/payments/webhook', express.raw({ type: 'application/json' }));
|
|
23
|
+
app.use(express.json());
|
|
24
|
+
app.use(express.urlencoded({ extended: true }));
|
|
25
|
+
|
|
26
|
+
// Routes
|
|
27
|
+
app.use('/api', routes);
|
|
28
|
+
app.use('/api/auth', authRoutes);
|
|
29
|
+
app.use('/api/payments', paymentsRoutes);
|
|
30
|
+
|
|
31
|
+
// Error handling (must be last)
|
|
32
|
+
app.use(errorHandler);
|
|
33
|
+
|
|
34
|
+
export default app;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database configuration
|
|
3
|
+
*
|
|
4
|
+
* Add your database connection logic here
|
|
5
|
+
* Example with PostgreSQL / Prisma / TypeORM
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const databaseConfig = {
|
|
9
|
+
url: process.env.DATABASE_URL || 'postgresql://localhost:5432/{{snakeCase projectName}}',
|
|
10
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Router, Request, Response } from 'express';
|
|
2
|
+
import jwt from 'jsonwebtoken';
|
|
3
|
+
import bcrypt from 'bcryptjs';
|
|
4
|
+
import { authMiddleware, AuthRequest } from '../middlewares/auth.middleware';
|
|
5
|
+
|
|
6
|
+
const router = Router();
|
|
7
|
+
|
|
8
|
+
// In-memory users store (replace with database in production)
|
|
9
|
+
const users: { id: string; email: string; password: string }[] = [];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @route POST /api/auth/register
|
|
13
|
+
* @desc Register a new user
|
|
14
|
+
*/
|
|
15
|
+
router.post('/register', async (req: Request, res: Response) => {
|
|
16
|
+
try {
|
|
17
|
+
const { email, password } = req.body;
|
|
18
|
+
|
|
19
|
+
if (!email || !password) {
|
|
20
|
+
return res.status(400).json({ error: 'Email and password are required' });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const existingUser = users.find(u => u.email === email);
|
|
24
|
+
if (existingUser) {
|
|
25
|
+
return res.status(400).json({ error: 'User already exists' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const hashedPassword = await bcrypt.hash(password, 10);
|
|
29
|
+
const user = {
|
|
30
|
+
id: Date.now().toString(),
|
|
31
|
+
email,
|
|
32
|
+
password: hashedPassword,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
users.push(user);
|
|
36
|
+
|
|
37
|
+
const token = jwt.sign(
|
|
38
|
+
{ id: user.id, email: user.email },
|
|
39
|
+
process.env.JWT_SECRET || 'your-secret-key',
|
|
40
|
+
{ expiresIn: '7d' }
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
res.status(201).json({ token, user: { id: user.id, email: user.email } });
|
|
44
|
+
} catch (error) {
|
|
45
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @route POST /api/auth/login
|
|
51
|
+
* @desc Authenticate user and return token
|
|
52
|
+
*/
|
|
53
|
+
router.post('/login', async (req: Request, res: Response) => {
|
|
54
|
+
try {
|
|
55
|
+
const { email, password } = req.body;
|
|
56
|
+
|
|
57
|
+
if (!email || !password) {
|
|
58
|
+
return res.status(400).json({ error: 'Email and password are required' });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const user = users.find(u => u.email === email);
|
|
62
|
+
if (!user) {
|
|
63
|
+
return res.status(401).json({ error: 'Invalid credentials' });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isValidPassword = await bcrypt.compare(password, user.password);
|
|
67
|
+
if (!isValidPassword) {
|
|
68
|
+
return res.status(401).json({ error: 'Invalid credentials' });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const token = jwt.sign(
|
|
72
|
+
{ id: user.id, email: user.email },
|
|
73
|
+
process.env.JWT_SECRET || 'your-secret-key',
|
|
74
|
+
{ expiresIn: '7d' }
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
res.json({ token, user: { id: user.id, email: user.email } });
|
|
78
|
+
} catch (error) {
|
|
79
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @route GET /api/auth/me
|
|
85
|
+
* @desc Get current user info
|
|
86
|
+
*/
|
|
87
|
+
router.get('/me', authMiddleware, (req: AuthRequest, res: Response) => {
|
|
88
|
+
res.json({ user: req.user });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export default router;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Health check controller
|
|
5
|
+
*/
|
|
6
|
+
class HealthController {
|
|
7
|
+
/**
|
|
8
|
+
* Check server health
|
|
9
|
+
*/
|
|
10
|
+
check(req: Request, res: Response) {
|
|
11
|
+
res.status(200).json({
|
|
12
|
+
status: 'ok',
|
|
13
|
+
message: '{{pascalCase projectName}} API is running',
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
uptime: process.uptime(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default new HealthController();
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Router, Request, Response } from 'express';
|
|
2
|
+
import { stripeService } from '../services/stripe.service';
|
|
3
|
+
import { authMiddleware, AuthRequest } from '../middlewares/auth.middleware';
|
|
4
|
+
|
|
5
|
+
const router = Router();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @route POST /api/payments/checkout
|
|
9
|
+
* @desc Create a Stripe checkout session
|
|
10
|
+
*/
|
|
11
|
+
router.post('/checkout', authMiddleware, async (req: AuthRequest, res: Response) => {
|
|
12
|
+
try {
|
|
13
|
+
const { priceId } = req.body;
|
|
14
|
+
|
|
15
|
+
if (!priceId) {
|
|
16
|
+
return res.status(400).json({ error: 'Price ID is required' });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const session = await stripeService.createCheckoutSession({
|
|
20
|
+
priceId,
|
|
21
|
+
successUrl: `${process.env.FRONTEND_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
|
|
22
|
+
cancelUrl: `${process.env.FRONTEND_URL}/cancel`,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
res.json({ url: session.url });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Checkout error:', error);
|
|
28
|
+
res.status(500).json({ error: 'Failed to create checkout session' });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @route POST /api/payments/portal
|
|
34
|
+
* @desc Create a Stripe customer portal session
|
|
35
|
+
*/
|
|
36
|
+
router.post('/portal', authMiddleware, async (req: AuthRequest, res: Response) => {
|
|
37
|
+
try {
|
|
38
|
+
const { customerId } = req.body;
|
|
39
|
+
|
|
40
|
+
if (!customerId) {
|
|
41
|
+
return res.status(400).json({ error: 'Customer ID is required' });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const session = await stripeService.createPortalSession(
|
|
45
|
+
customerId,
|
|
46
|
+
`${process.env.FRONTEND_URL}/dashboard`
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
res.json({ url: session.url });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Portal error:', error);
|
|
52
|
+
res.status(500).json({ error: 'Failed to create portal session' });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @route POST /api/payments/webhook
|
|
58
|
+
* @desc Handle Stripe webhook events
|
|
59
|
+
*/
|
|
60
|
+
router.post('/webhook', async (req: Request, res: Response) => {
|
|
61
|
+
const signature = req.headers['stripe-signature'] as string;
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const result = await stripeService.handleWebhook(req.body, signature);
|
|
65
|
+
res.json(result);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Webhook error:', error);
|
|
68
|
+
res.status(400).json({ error: 'Webhook handling failed' });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default router;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import app from './app';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
|
|
4
|
+
dotenv.config();
|
|
5
|
+
|
|
6
|
+
const PORT = process.env.PORT || 3000;
|
|
7
|
+
|
|
8
|
+
app.listen(PORT, () => {
|
|
9
|
+
console.log(`🚀 {{pascalCase projectName}} server running on port ${PORT}`);
|
|
10
|
+
console.log(`📝 Environment: ${process.env.NODE_ENV || 'development'}`);
|
|
11
|
+
console.log(`🔗 Health check: http://localhost:${PORT}/api/health`);
|
|
12
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Global error handling middleware
|
|
5
|
+
*/
|
|
6
|
+
export function errorHandler(
|
|
7
|
+
err: Error,
|
|
8
|
+
req: Request,
|
|
9
|
+
res: Response,
|
|
10
|
+
next: NextFunction
|
|
11
|
+
) {
|
|
12
|
+
console.error('❌ Error:', err);
|
|
13
|
+
|
|
14
|
+
const statusCode = res.statusCode !== 200 ? res.statusCode : 500;
|
|
15
|
+
|
|
16
|
+
res.status(statusCode).json({
|
|
17
|
+
error: {
|
|
18
|
+
message: err.message,
|
|
19
|
+
...(process.env.NODE_ENV === 'development' && { stack: err.stack }),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import jwt from 'jsonwebtoken';
|
|
2
|
+
import { Request, Response, NextFunction } from 'express';
|
|
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
|
+
|
|
20
|
+
try {
|
|
21
|
+
const decoded = jwt.verify(token, process.env.JWT_SECRET || 'your-secret-key') as {
|
|
22
|
+
id: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
req.user = decoded;
|
|
27
|
+
next();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import healthController from '../controllers/healthController';
|
|
3
|
+
|
|
4
|
+
const router = Router();
|
|
5
|
+
|
|
6
|
+
// Health check endpoint
|
|
7
|
+
router.get('/health', healthController.check);
|
|
8
|
+
|
|
9
|
+
// Add your routes here
|
|
10
|
+
// Example:
|
|
11
|
+
// import userRoutes from './userRoutes';
|
|
12
|
+
// router.use('/users', userRoutes);
|
|
13
|
+
|
|
14
|
+
export default router;
|
|
File without changes
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
|
|
3
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || '', {
|
|
4
|
+
apiVersion: '2024-12-18.acacia',
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export interface CreateCheckoutSessionParams {
|
|
8
|
+
priceId: string;
|
|
9
|
+
customerId?: string;
|
|
10
|
+
successUrl: string;
|
|
11
|
+
cancelUrl: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class StripeService {
|
|
15
|
+
/**
|
|
16
|
+
* Create a checkout session for subscription
|
|
17
|
+
*/
|
|
18
|
+
async createCheckoutSession(params: CreateCheckoutSessionParams) {
|
|
19
|
+
const session = await stripe.checkout.sessions.create({
|
|
20
|
+
mode: 'subscription',
|
|
21
|
+
payment_method_types: ['card'],
|
|
22
|
+
line_items: [
|
|
23
|
+
{
|
|
24
|
+
price: params.priceId,
|
|
25
|
+
quantity: 1,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
customer: params.customerId,
|
|
29
|
+
success_url: params.successUrl,
|
|
30
|
+
cancel_url: params.cancelUrl,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return session;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create a customer portal session
|
|
38
|
+
*/
|
|
39
|
+
async createPortalSession(customerId: string, returnUrl: string) {
|
|
40
|
+
const session = await stripe.billingPortal.sessions.create({
|
|
41
|
+
customer: customerId,
|
|
42
|
+
return_url: returnUrl,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return session;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Handle webhook event
|
|
50
|
+
*/
|
|
51
|
+
async handleWebhook(rawBody: Buffer, signature: string) {
|
|
52
|
+
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET || '';
|
|
53
|
+
|
|
54
|
+
const event = stripe.webhooks.constructEvent(
|
|
55
|
+
rawBody,
|
|
56
|
+
signature,
|
|
57
|
+
webhookSecret
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
switch (event.type) {
|
|
61
|
+
case 'checkout.session.completed':
|
|
62
|
+
const session = event.data.object;
|
|
63
|
+
// Handle successful subscription
|
|
64
|
+
console.log('Checkout completed:', session.id);
|
|
65
|
+
break;
|
|
66
|
+
|
|
67
|
+
case 'customer.subscription.updated':
|
|
68
|
+
const subscription = event.data.object;
|
|
69
|
+
// Handle subscription update
|
|
70
|
+
console.log('Subscription updated:', subscription.id);
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'customer.subscription.deleted':
|
|
74
|
+
const deletedSubscription = event.data.object;
|
|
75
|
+
// Handle subscription cancellation
|
|
76
|
+
console.log('Subscription deleted:', deletedSubscription.id);
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case 'invoice.payment_failed':
|
|
80
|
+
const invoice = event.data.object;
|
|
81
|
+
// Handle failed payment
|
|
82
|
+
console.log('Payment failed:', invoice.id);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return { received: true };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create a Stripe customer
|
|
91
|
+
*/
|
|
92
|
+
async createCustomer(email: string, name?: string) {
|
|
93
|
+
const customer = await stripe.customers.create({
|
|
94
|
+
email,
|
|
95
|
+
name,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return customer;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const stripeService = new StripeService();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Node.js Express MVC",
|
|
3
|
+
"tier": "free",
|
|
4
|
+
"stack": "nodejs-express",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "Express.js REST API with TypeScript and MVC architecture",
|
|
7
|
+
"targetVersions": {
|
|
8
|
+
"node": ">=18.0.0",
|
|
9
|
+
"express": "^4.18.0",
|
|
10
|
+
"typescript": "^5.0.0"
|
|
11
|
+
},
|
|
12
|
+
"requiredConfig": [
|
|
13
|
+
"projectName"
|
|
14
|
+
],
|
|
15
|
+
"optionalConfig": [
|
|
16
|
+
"useAI"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
> Generated by [Kybernus CLI](https://kybernus.dev) 🚀 (Free)
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- **Framework**: FastAPI
|
|
8
|
+
- **Python**: 3.11+
|
|
9
|
+
- **Validation**: Pydantic v2
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Create virtual environment
|
|
15
|
+
python -m venv venv
|
|
16
|
+
source venv/bin/activate # Linux/Mac
|
|
17
|
+
# or: venv\Scripts\activate # Windows
|
|
18
|
+
|
|
19
|
+
# Install dependencies
|
|
20
|
+
pip install -r requirements.txt
|
|
21
|
+
|
|
22
|
+
# Run development server
|
|
23
|
+
uvicorn app.main:app --reload
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Endpoints
|
|
27
|
+
|
|
28
|
+
- `GET /api/health` - Health check
|
|
29
|
+
- `GET /api/items` - List items
|
|
30
|
+
- `POST /api/items` - Create item
|
|
31
|
+
- `GET /api/items/{id}` - Get item
|
|
32
|
+
- `DELETE /api/items/{id}` - Delete item
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
- Swagger UI: http://localhost:8000/docs
|
|
37
|
+
- ReDoc: http://localhost:8000/redoc
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
Made with ❤️ using [Kybernus](https://kybernus.dev)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from fastapi import APIRouter, HTTPException
|
|
2
|
+
from typing import List
|
|
3
|
+
from app.schemas.item import ItemCreate, ItemResponse
|
|
4
|
+
from app.services.item_service import ItemService
|
|
5
|
+
|
|
6
|
+
router = APIRouter()
|
|
7
|
+
item_service = ItemService()
|
|
8
|
+
|
|
9
|
+
@router.get("/", response_model=List[ItemResponse])
|
|
10
|
+
async def get_items():
|
|
11
|
+
return item_service.get_all()
|
|
12
|
+
|
|
13
|
+
@router.get("/{item_id}", response_model=ItemResponse)
|
|
14
|
+
async def get_item(item_id: str):
|
|
15
|
+
item = item_service.get_by_id(item_id)
|
|
16
|
+
if not item:
|
|
17
|
+
raise HTTPException(status_code=404, detail="Item not found")
|
|
18
|
+
return item
|
|
19
|
+
|
|
20
|
+
@router.post("/", response_model=ItemResponse, status_code=201)
|
|
21
|
+
async def create_item(item: ItemCreate):
|
|
22
|
+
return item_service.create(item)
|
|
23
|
+
|
|
24
|
+
@router.delete("/{item_id}", status_code=204)
|
|
25
|
+
async def delete_item(item_id: str):
|
|
26
|
+
if not item_service.delete(item_id):
|
|
27
|
+
raise HTTPException(status_code=404, detail="Item not found")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from fastapi import FastAPI
|
|
2
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
3
|
+
from app.controllers import health, items
|
|
4
|
+
|
|
5
|
+
app = FastAPI(
|
|
6
|
+
title="{{projectNamePascalCase}}",
|
|
7
|
+
description="Generated by Kybernus CLI",
|
|
8
|
+
version="1.0.0"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
# CORS
|
|
12
|
+
app.add_middleware(
|
|
13
|
+
CORSMiddleware,
|
|
14
|
+
allow_origins=["*"],
|
|
15
|
+
allow_credentials=True,
|
|
16
|
+
allow_methods=["*"],
|
|
17
|
+
allow_headers=["*"],
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Routes
|
|
21
|
+
app.include_router(health.router, prefix="/api", tags=["Health"])
|
|
22
|
+
app.include_router(items.router, prefix="/api/items", tags=["Items"])
|
|
23
|
+
|
|
24
|
+
@app.get("/")
|
|
25
|
+
async def root():
|
|
26
|
+
return {"message": "Welcome to {{projectNamePascalCase}} API"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Optional
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class Item:
|
|
8
|
+
id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
9
|
+
name: str = ""
|
|
10
|
+
description: Optional[str] = None
|
|
11
|
+
created_at: datetime = field(default_factory=datetime.now)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
class ItemBase(BaseModel):
|
|
6
|
+
name: str
|
|
7
|
+
description: Optional[str] = None
|
|
8
|
+
|
|
9
|
+
class ItemCreate(ItemBase):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
class ItemResponse(ItemBase):
|
|
13
|
+
id: str
|
|
14
|
+
created_at: datetime
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
from_attributes = True
|