kybernus 3.0.1 → 3.2.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 +1 -1
- package/dist/cli/commands/ecommerce.d.ts +3 -0
- package/dist/cli/commands/ecommerce.d.ts.map +1 -0
- package/dist/cli/commands/ecommerce.js +164 -0
- package/dist/cli/commands/ecommerce.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/ecommerce/.env.example +10 -0
- package/templates/ecommerce/.github/workflows/ci.yml +102 -0
- package/templates/ecommerce/.github/workflows/deploy.yml +31 -0
- package/templates/ecommerce/.prettierrc +9 -0
- package/templates/ecommerce/Dockerfile +54 -0
- package/templates/ecommerce/README.md +295 -0
- package/templates/ecommerce/apps/api/.env.example +59 -0
- package/templates/ecommerce/apps/api/jest.config.ts +50 -0
- package/templates/ecommerce/apps/api/jest.integration.config.ts +45 -0
- package/templates/ecommerce/apps/api/package.json +59 -0
- package/templates/ecommerce/apps/api/prisma/migrations/20260306000137_init/migration.sql +184 -0
- package/templates/ecommerce/apps/api/prisma/migrations/migration_lock.toml +3 -0
- package/templates/ecommerce/apps/api/prisma/schema.prisma +181 -0
- package/templates/ecommerce/apps/api/prisma/seed.ts +159 -0
- package/templates/ecommerce/apps/api/src/__tests__/app.test.ts +39 -0
- package/templates/ecommerce/apps/api/src/__tests__/globalSetup.ts +34 -0
- package/templates/ecommerce/apps/api/src/__tests__/globalTeardown.ts +16 -0
- package/templates/ecommerce/apps/api/src/__tests__/setup.db.ts +18 -0
- package/templates/ecommerce/apps/api/src/__tests__/setup.env.ts +14 -0
- package/templates/ecommerce/apps/api/src/app.ts +133 -0
- package/templates/ecommerce/apps/api/src/application/admin/admin-user.service.ts +24 -0
- package/templates/ecommerce/apps/api/src/application/admin/dashboard.service.ts +102 -0
- package/templates/ecommerce/apps/api/src/application/auth/auth.service.ts +185 -0
- package/templates/ecommerce/apps/api/src/application/cart/cart.service.ts +151 -0
- package/templates/ecommerce/apps/api/src/application/cart/coupon.service.ts +51 -0
- package/templates/ecommerce/apps/api/src/application/catalog/catalog.service.ts +168 -0
- package/templates/ecommerce/apps/api/src/application/checkout/checkout.service.ts +114 -0
- package/templates/ecommerce/apps/api/src/application/orders/order.service.ts +93 -0
- package/templates/ecommerce/apps/api/src/application/ports/email.port.ts +3 -0
- package/templates/ecommerce/apps/api/src/application/ports/payment.port.ts +24 -0
- package/templates/ecommerce/apps/api/src/application/ports/shipping.port.ts +9 -0
- package/templates/ecommerce/apps/api/src/application/ports/storage.port.ts +3 -0
- package/templates/ecommerce/apps/api/src/application/ports/token-blacklist.port.ts +4 -0
- package/templates/ecommerce/apps/api/src/application/ports/token.port.ts +18 -0
- package/templates/ecommerce/apps/api/src/application/profile/profile.service.ts +76 -0
- package/templates/ecommerce/apps/api/src/domain/auth/user.entity.ts +109 -0
- package/templates/ecommerce/apps/api/src/domain/auth/user.repository.ts +11 -0
- package/templates/ecommerce/apps/api/src/domain/cart/cart.entity.ts +136 -0
- package/templates/ecommerce/apps/api/src/domain/cart/cart.repository.ts +8 -0
- package/templates/ecommerce/apps/api/src/domain/cart/coupon.entity.ts +58 -0
- package/templates/ecommerce/apps/api/src/domain/cart/coupon.repository.ts +10 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/category.entity.ts +51 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/category.repository.ts +10 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/product.entity.ts +130 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/product.repository.ts +28 -0
- package/templates/ecommerce/apps/api/src/domain/checkout/order.entity.ts +121 -0
- package/templates/ecommerce/apps/api/src/domain/checkout/order.repository.ts +11 -0
- package/templates/ecommerce/apps/api/src/domain/shared/AppError.ts +12 -0
- package/templates/ecommerce/apps/api/src/infrastructure/cache/redis.ts +16 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/admin.registry.ts +13 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/auth.registry.ts +34 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/cart.registry.ts +49 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/catalog.registry.ts +24 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/checkout.registry.ts +47 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/orders.registry.ts +6 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/profile.registry.ts +4 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/cart.memory.repository.ts +33 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/category.memory.repository.ts +41 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/coupon.memory.repository.ts +55 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/order.memory.repository.ts +75 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/product.memory.repository.ts +100 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/user.memory.repository.ts +54 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/auth/user.prisma.repository.ts +83 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/catalog/category.prisma.repository.ts +69 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/catalog/product.prisma.repository.ts +185 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/checkout/order.prisma.repository.ts +149 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma-client.ts +17 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/email.registry.ts +18 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/ethereal.email.service.ts +38 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/noop.email.service.ts +12 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/smtp.email.service.ts +36 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/payment/stripe-webhook.handler.ts +83 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/payment/stripe.adapter.ts +39 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/shipping/mock.shipping.service.ts +17 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/in-memory.storage.service.ts +11 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/local-disk.storage.service.ts +27 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/s3.storage.service.ts +52 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/storage.registry.ts +19 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/redis.token.blacklist.ts +23 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/token.blacklist.ts +30 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/token.service.ts +136 -0
- package/templates/ecommerce/apps/api/src/modules/admin/__tests__/admin.routes.integration.test.ts +250 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.controller.ts +116 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.routes.ts +21 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.user.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.logout.redis.test.ts +104 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.routes.integration.test.ts +211 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.service.unit.test.ts +260 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/email.service.unit.test.ts +94 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/token.blacklist.redis.test.ts +65 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/user.entity.unit.test.ts +79 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/user.prisma.repository.test.ts +138 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.controller.ts +148 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/redis.token.blacklist.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/token.blacklist.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/auth/token.service.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.entity.unit.test.ts +144 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.routes.integration.test.ts +242 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.service.unit.test.ts +151 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/coupon.admin.integration.test.ts +136 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.controller.ts +94 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/shipping.service.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/catalog.routes.integration.test.ts +275 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/catalog.service.unit.test.ts +223 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/product.image.integration.test.ts +130 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/product.prisma.repository.test.ts +174 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.controller.ts +176 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.routes.ts +38 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/checkout.routes.integration.test.ts +163 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/checkout.service.unit.test.ts +191 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/order.prisma.repository.test.ts +150 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.controller.ts +59 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.routes.ts +18 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/tax.service.ts +9 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.entity.unit.test.ts +68 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.routes.integration.test.ts +254 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.service.email.unit.test.ts +142 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.controller.ts +96 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/__tests__/stripe-webhook.unit.test.ts +330 -0
- package/templates/ecommerce/apps/api/src/modules/payment/__tests__/stripe.adapter.unit.test.ts +84 -0
- package/templates/ecommerce/apps/api/src/modules/payment/adapters/stripe.adapter.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/payment.port.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/stripe-webhook.handler.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/profile/__tests__/profile.routes.integration.test.ts +180 -0
- package/templates/ecommerce/apps/api/src/modules/profile/__tests__/profile.service.unit.test.ts +187 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.controller.ts +92 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.routes.ts +14 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/authenticate.ts +37 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/authorize.ts +23 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/errorHandler.ts +48 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/admin/admin.controller.ts +116 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/admin/admin.routes.ts +21 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/auth/auth.controller.ts +147 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/auth/auth.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/cart/cart.controller.ts +94 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/cart/cart.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/catalog/catalog.controller.ts +176 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/catalog/catalog.routes.ts +38 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/checkout/checkout.controller.ts +59 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/checkout/checkout.routes.ts +18 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/orders/order.controller.ts +96 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/orders/order.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/profile/profile.controller.ts +92 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/profile/profile.routes.ts +14 -0
- package/templates/ecommerce/apps/api/src/presentation/validators/uuidParam.ts +20 -0
- package/templates/ecommerce/apps/api/src/server.ts +47 -0
- package/templates/ecommerce/apps/api/src/shared/__tests__/uuid.validation.test.ts +111 -0
- package/templates/ecommerce/apps/api/src/shared/errors/AppError.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/EtherealEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/IEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/NoopEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/SmtpEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/__tests__/ethereal.email.integration.test.ts +32 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/email.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/prisma.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/redis.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/IStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/InMemoryStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/LocalDiskStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/S3StorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/__tests__/s3.storage.unit.test.ts +73 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/storage.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/authenticate.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/authorize.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/errorHandler.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/validators/uuidParam.ts +1 -0
- package/templates/ecommerce/apps/api/tsconfig.json +15 -0
- package/templates/ecommerce/apps/web/.env.example +8 -0
- package/templates/ecommerce/apps/web/index.html +19 -0
- package/templates/ecommerce/apps/web/jest.config.ts +45 -0
- package/templates/ecommerce/apps/web/package.json +38 -0
- package/templates/ecommerce/apps/web/src/App.tsx +133 -0
- package/templates/ecommerce/apps/web/src/__mocks__/fileMock.ts +1 -0
- package/templates/ecommerce/apps/web/src/__mocks__/styleMock.ts +1 -0
- package/templates/ecommerce/apps/web/src/index.css +159 -0
- package/templates/ecommerce/apps/web/src/main.tsx +13 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/CouponsAdminPage.test.tsx +134 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/DashboardPage.test.tsx +65 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/OrdersAdminPage.test.tsx +79 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/ProductsAdminPage.test.tsx +84 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/UsersAdminPage.test.tsx +85 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/CouponsAdminPage.tsx +179 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/DashboardPage.tsx +58 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/OrdersAdminPage.tsx +178 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/ProductsAdminPage.tsx +444 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/UsersAdminPage.tsx +87 -0
- package/templates/ecommerce/apps/web/src/modules/auth/LoginForm.tsx +91 -0
- package/templates/ecommerce/apps/web/src/modules/auth/RegisterForm.tsx +109 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/ForgotPasswordPage.test.tsx +42 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/LoginForm.test.tsx +76 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/RegisterForm.test.tsx +62 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/ResetPasswordPage.test.tsx +66 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/ForgotPasswordPage.tsx +100 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/LoginPage.tsx +39 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/RegisterPage.tsx +39 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/ResetPasswordPage.tsx +110 -0
- package/templates/ecommerce/apps/web/src/modules/auth/useAuthStore.ts +141 -0
- package/templates/ecommerce/apps/web/src/modules/cart/__tests__/CartPage.test.tsx +111 -0
- package/templates/ecommerce/apps/web/src/modules/cart/pages/CartPage.tsx +313 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/__tests__/ProductCard.test.tsx +59 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/__tests__/ProductFilters.test.tsx +56 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/components/ProductCard.tsx +78 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/components/ProductFilters.tsx +104 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/pages/ProductDetailPage.tsx +179 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/pages/ProductListPage.tsx +100 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/__tests__/CheckoutPage.test.tsx +159 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/__tests__/StripePaymentForm.test.tsx +79 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/components/StripePaymentForm.tsx +55 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/hooks/useCheckout.ts +56 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/pages/CheckoutPage.tsx +344 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/pages/CheckoutSuccessPage.tsx +12 -0
- package/templates/ecommerce/apps/web/src/modules/legal/pages/PrivacyPolicyPage.tsx +207 -0
- package/templates/ecommerce/apps/web/src/modules/legal/pages/TermsOfServicePage.tsx +175 -0
- package/templates/ecommerce/apps/web/src/modules/orders/__tests__/OrderDetailPage.test.tsx +75 -0
- package/templates/ecommerce/apps/web/src/modules/orders/__tests__/OrderHistoryPage.test.tsx +87 -0
- package/templates/ecommerce/apps/web/src/modules/orders/pages/OrderDetailPage.tsx +73 -0
- package/templates/ecommerce/apps/web/src/modules/orders/pages/OrderHistoryPage.tsx +97 -0
- package/templates/ecommerce/apps/web/src/modules/profile/__tests__/ProfilePage.test.tsx +150 -0
- package/templates/ecommerce/apps/web/src/modules/profile/pages/ProfilePage.tsx +275 -0
- package/templates/ecommerce/apps/web/src/setupTests.ts +10 -0
- package/templates/ecommerce/apps/web/src/shared/components/CookieConsent.tsx +108 -0
- package/templates/ecommerce/apps/web/src/shared/components/ErrorBoundary.tsx +112 -0
- package/templates/ecommerce/apps/web/src/shared/components/Layout.tsx +143 -0
- package/templates/ecommerce/apps/web/src/shared/components/ProtectedRoute.tsx +21 -0
- package/templates/ecommerce/apps/web/src/shared/config/siteConfig.ts +57 -0
- package/templates/ecommerce/apps/web/src/shared/hooks/usePageTitle.ts +16 -0
- package/templates/ecommerce/apps/web/src/shared/lib/apiFetch.ts +16 -0
- package/templates/ecommerce/apps/web/src/shared/pages/NotFoundPage.tsx +42 -0
- package/templates/ecommerce/apps/web/src/shared/theme/ThemeProvider.tsx +45 -0
- package/templates/ecommerce/apps/web/src/shared/theme/__tests__/ThemeProvider.test.tsx +78 -0
- package/templates/ecommerce/apps/web/src/shared/theme/createTheme.ts +58 -0
- package/templates/ecommerce/apps/web/src/shared/theme/tokens.ts +81 -0
- package/templates/ecommerce/apps/web/src/vite-env.d.ts +1 -0
- package/templates/ecommerce/apps/web/tsconfig.jest.json +12 -0
- package/templates/ecommerce/apps/web/tsconfig.json +25 -0
- package/templates/ecommerce/apps/web/tsconfig.node.json +11 -0
- package/templates/ecommerce/apps/web/vite.config.ts +30 -0
- package/templates/ecommerce/docker-compose.yml +85 -0
- package/templates/ecommerce/package-lock.json +11255 -0
- package/templates/ecommerce/package.json +27 -0
- package/templates/ecommerce/packages/shared-types/package.json +13 -0
- package/templates/ecommerce/packages/shared-types/src/index.ts +3 -0
- package/templates/ecommerce/packages/shared-types/src/theme.ts +44 -0
- package/templates/ecommerce/packages/shared-types/tsconfig.json +11 -0
- package/templates/ecommerce/scripts/customize.sh +201 -0
- package/templates/ecommerce/tsconfig.json +14 -0
- package/templates/java-spring/clean/.gitignore.hbs +72 -0
- package/templates/java-spring/clean/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/application/usecase/PaymentUseCase.java.hbs +21 -17
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/entity/UserEntity.java.hbs +52 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/repository/JpaUserRepository.java.hbs +12 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/JwtAuthenticationFilter.java.hbs +64 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/SecurityConfig.java.hbs +36 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/stripe/StripeGateway.java.hbs +63 -0
- package/templates/java-spring/clean/src/main/resources/application.properties.hbs +6 -7
- package/templates/java-spring/hexagonal/.gitignore.hbs +72 -0
- package/templates/java-spring/hexagonal/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/JwtFilter.java.hbs +71 -0
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/SecurityConfig.java.hbs +35 -0
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/core/service/PaymentService.java.hbs +3 -3
- package/templates/java-spring/hexagonal/src/main/resources/application.properties.hbs +4 -4
- package/templates/java-spring/mvc/.gitignore.hbs +72 -0
- package/templates/java-spring/mvc/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/config/SecurityConfig.java.hbs +13 -12
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/AuthController.java.hbs +9 -8
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/PaymentsController.java.hbs +5 -6
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/service/StripeService.java.hbs +3 -3
- package/templates/java-spring/mvc/src/main/resources/application.yml.hbs +29 -26
- package/templates/nestjs/clean/.gitignore.hbs +42 -0
- package/templates/nestjs/clean/Dockerfile.hbs +6 -3
- package/templates/nestjs/clean/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/clean/src/app.module.ts.hbs +2 -1
- package/templates/nestjs/clean/src/application/payment.service.ts.hbs +72 -72
- package/templates/nestjs/clean/src/domain/entities/user.entity.ts.hbs +2 -2
- package/templates/nestjs/clean/src/domain/repositories/user.repository.ts.hbs +2 -2
- package/templates/nestjs/clean/src/infrastructure/database/repositories/prisma.user.repository.ts.hbs +18 -18
- package/templates/nestjs/clean/src/infrastructure/http/health.controller.ts.hbs +9 -0
- package/templates/nestjs/clean/src/main.ts.hbs +1 -4
- package/templates/nestjs/clean/src/payment.module.ts.hbs +12 -12
- package/templates/nestjs/hexagonal/.gitignore.hbs +42 -0
- package/templates/nestjs/hexagonal/Dockerfile.hbs +6 -3
- package/templates/nestjs/hexagonal/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/hexagonal/src/adapters/inbound/health.controller.ts.hbs +9 -0
- package/templates/nestjs/hexagonal/src/app.module.ts.hbs +2 -1
- package/templates/nestjs/hexagonal/src/core/domain/user.entity.ts.hbs +6 -6
- package/templates/nestjs/hexagonal/src/core/ports/ports.ts.hbs +4 -4
- package/templates/nestjs/hexagonal/src/main.ts.hbs +1 -4
- package/templates/nestjs/mvc/.gitignore.hbs +42 -0
- package/templates/nestjs/mvc/Dockerfile.hbs +6 -3
- package/templates/nestjs/mvc/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/mvc/src/auth/auth.controller.ts.hbs +11 -1
- package/templates/nestjs/mvc/src/auth/auth.service.ts.hbs +3 -1
- package/templates/nestjs/mvc/src/controllers/health.controller.ts.hbs +6 -6
- package/templates/nestjs/mvc/src/main.ts.hbs +1 -4
- package/templates/nestjs/mvc/src/models/create-item.dto.ts.hbs +5 -2
- package/templates/nestjs/mvc/src/prisma/prisma.service.ts.hbs +1 -0
- package/templates/nextjs/mvc/.gitignore.hbs +42 -0
- package/templates/nextjs/mvc/Dockerfile.hbs +23 -8
- package/templates/nextjs/mvc/docker-compose.yml.hbs +1 -1
- package/templates/nodejs-express/clean/.gitignore.hbs +42 -0
- package/templates/nodejs-express/clean/Dockerfile.hbs +6 -1
- package/templates/nodejs-express/clean/docker-compose.yml.hbs +2 -2
- package/templates/nodejs-express/clean/package.json.hbs +69 -69
- package/templates/nodejs-express/clean/src/config.ts.hbs +11 -0
- package/templates/nodejs-express/clean/src/domain/entities/User.ts.hbs +46 -8
- package/templates/nodejs-express/hexagonal/.gitignore.hbs +42 -0
- package/templates/nodejs-express/hexagonal/Dockerfile.hbs +1 -1
- package/templates/nodejs-express/hexagonal/docker-compose.yml.hbs +2 -2
- package/templates/nodejs-express/hexagonal/package.json.hbs +69 -69
- package/templates/nodejs-express/hexagonal/src/adapters/inbound/http/PaymentController.ts.hbs +21 -38
- package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts.hbs +2 -0
- package/templates/nodejs-express/hexagonal/src/config.ts.hbs +9 -0
- package/templates/nodejs-express/hexagonal/src/core/AuthService.ts.hbs +5 -5
- package/templates/nodejs-express/hexagonal/src/core/PaymentService.ts.hbs +7 -22
- package/templates/nodejs-express/hexagonal/src/core/domain/entities/User.ts.hbs +24 -4
- package/templates/nodejs-express/mvc/.gitignore.hbs +42 -0
- package/templates/nodejs-express/mvc/package.json.hbs +67 -67
- package/templates/python-fastapi/clean/.gitignore.hbs +76 -0
- package/templates/python-fastapi/clean/app/application/services/payment_service.py.hbs +3 -3
- package/templates/python-fastapi/clean/app/config.py.hbs +6 -7
- package/templates/python-fastapi/clean/app/domain/usecases/login_user.py.hbs +15 -0
- package/templates/python-fastapi/clean/app/infrastructure/http/auth_controller.py.hbs +40 -6
- package/templates/python-fastapi/clean/app/infrastructure/http/payment_controller.py.hbs +5 -4
- package/templates/python-fastapi/clean/app/infrastructure/security/jwt.py.hbs +23 -0
- package/templates/python-fastapi/clean/app/main.py.hbs +3 -0
- package/templates/python-fastapi/clean/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/clean/requirements.txt.hbs +3 -0
- package/templates/python-fastapi/hexagonal/.gitignore.hbs +76 -0
- package/templates/python-fastapi/hexagonal/app/adapters/inbound/http_adapter.py.hbs +6 -9
- package/templates/python-fastapi/hexagonal/app/adapters/inbound/payment_http_adapter.py.hbs +4 -3
- package/templates/python-fastapi/hexagonal/app/adapters/outbound/stripe_adapter.py.hbs +30 -19
- package/templates/python-fastapi/hexagonal/app/config.py.hbs +14 -4
- package/templates/python-fastapi/hexagonal/app/core/domain/user.py.hbs +3 -1
- package/templates/python-fastapi/hexagonal/app/core/payment_service.py.hbs +28 -18
- package/templates/python-fastapi/hexagonal/app/core/ports/__init__.py.hbs +3 -0
- package/templates/python-fastapi/hexagonal/app/core/ports/user_repository.py.hbs +15 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/database/session.py.hbs +7 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/database/user_repository.py.hbs +53 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/__init__.py.hbs +0 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/adapters.py.hbs +23 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/jwt.py.hbs +23 -0
- package/templates/python-fastapi/hexagonal/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/hexagonal/requirements.txt.hbs +4 -0
- package/templates/python-fastapi/mvc/.gitignore.hbs +76 -0
- package/templates/python-fastapi/mvc/app/controllers/payments.py.hbs +3 -17
- package/templates/python-fastapi/mvc/app/middleware/security.py.hbs +24 -3
- package/templates/python-fastapi/mvc/app/schemas/item.py.hbs +3 -1
- package/templates/python-fastapi/mvc/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/mvc/requirements.txt.hbs +3 -1
- package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts +0 -5
|
@@ -1,71 +1,71 @@
|
|
|
1
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/**/*.ts",
|
|
11
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
-
"test": "jest",
|
|
13
|
-
"migrate:dev": "prisma migrate dev",
|
|
14
|
-
"migrate:deploy": "prisma migrate deploy",
|
|
15
|
-
"generate": "prisma generate"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"express",
|
|
19
|
-
"api",
|
|
20
|
-
"typescript",
|
|
21
|
-
"hexagonal-architecture",
|
|
22
|
-
"prisma",
|
|
23
|
-
"zod"
|
|
24
|
-
],
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"express": "^4.18.2",
|
|
29
|
-
"dotenv": "^16.4.5",
|
|
30
|
-
"cors": "^2.8.5",
|
|
31
|
-
"helmet": "^7.1.0",
|
|
32
|
-
"morgan": "^1.10.0",
|
|
33
|
-
"jsonwebtoken": "^9.0.2",
|
|
34
|
-
"bcryptjs": "^2.4.3",
|
|
35
|
-
"stripe": "^14.14.0",
|
|
36
|
-
"zod": "^3.22.4",
|
|
37
|
-
"express-async-errors": "^3.1.1",
|
|
38
|
-
"@prisma/client": "^5.10.2"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/express": "^4.17.21",
|
|
42
|
-
"@types/node": "^20.11.19",
|
|
43
|
-
"@types/cors": "^2.8.17",
|
|
44
|
-
"@types/morgan": "^1.9.9",
|
|
45
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
46
|
-
"@types/bcryptjs": "^2.4.6",
|
|
47
|
-
"typescript": "^5.3.3",
|
|
48
|
-
"tsx": "^4.7.1",
|
|
49
|
-
"rimraf": "^
|
|
50
|
-
"eslint": "^9.
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
52
|
-
"@typescript-eslint/parser": "^8.0.0",
|
|
53
|
-
"prettier": "^3.2.5",
|
|
54
|
-
"jest": "^29.7.0",
|
|
55
|
-
"@types/jest": "^29.5.12",
|
|
56
|
-
"prisma": "^5.10.2"
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=18.0.0"
|
|
60
|
-
},
|
|
61
|
-
"overrides": {
|
|
62
|
-
"rimraf": "^6.1.2",
|
|
63
|
-
"glob": "^11.0.0",
|
|
64
|
-
"inflight": "^1.0.6",
|
|
65
|
-
"@humanwhocodes/config-array": "^0.13.0",
|
|
66
|
-
"@humanwhocodes/object-schema": "^2.0.3",
|
|
67
|
-
"eslint": "^9.16.0",
|
|
68
|
-
"cookie": "^0.7.2",
|
|
69
|
-
"minimatch": "^9.0.8"
|
|
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/**/*.ts",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"migrate:dev": "prisma migrate dev",
|
|
14
|
+
"migrate:deploy": "prisma migrate deploy",
|
|
15
|
+
"generate": "prisma generate"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"express",
|
|
19
|
+
"api",
|
|
20
|
+
"typescript",
|
|
21
|
+
"hexagonal-architecture",
|
|
22
|
+
"prisma",
|
|
23
|
+
"zod"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"dotenv": "^16.4.5",
|
|
30
|
+
"cors": "^2.8.5",
|
|
31
|
+
"helmet": "^7.1.0",
|
|
32
|
+
"morgan": "^1.10.0",
|
|
33
|
+
"jsonwebtoken": "^9.0.2",
|
|
34
|
+
"bcryptjs": "^2.4.3",
|
|
35
|
+
"stripe": "^14.14.0",
|
|
36
|
+
"zod": "^3.22.4",
|
|
37
|
+
"express-async-errors": "^3.1.1",
|
|
38
|
+
"@prisma/client": "^5.10.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/express": "^4.17.21",
|
|
42
|
+
"@types/node": "^20.11.19",
|
|
43
|
+
"@types/cors": "^2.8.17",
|
|
44
|
+
"@types/morgan": "^1.9.9",
|
|
45
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
46
|
+
"@types/bcryptjs": "^2.4.6",
|
|
47
|
+
"typescript": "^5.3.3",
|
|
48
|
+
"tsx": "^4.7.1",
|
|
49
|
+
"rimraf": "^6.1.2",
|
|
50
|
+
"eslint": "^9.16.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
53
|
+
"prettier": "^3.2.5",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"@types/jest": "^29.5.12",
|
|
56
|
+
"prisma": "^5.10.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.0.0"
|
|
60
|
+
},
|
|
61
|
+
"overrides": {
|
|
62
|
+
"rimraf": "^6.1.2",
|
|
63
|
+
"glob": "^11.0.0",
|
|
64
|
+
"inflight": "^1.0.6",
|
|
65
|
+
"@humanwhocodes/config-array": "^0.13.0",
|
|
66
|
+
"@humanwhocodes/object-schema": "^2.0.3",
|
|
67
|
+
"eslint": "^9.16.0",
|
|
68
|
+
"cookie": "^0.7.2",
|
|
69
|
+
"minimatch": "^9.0.8"
|
|
70
|
+
}
|
|
70
71
|
}
|
|
71
|
-
}
|
package/templates/nodejs-express/hexagonal/src/adapters/inbound/http/PaymentController.ts.hbs
CHANGED
|
@@ -1,57 +1,40 @@
|
|
|
1
|
-
import { Request, Response
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
2
|
import { PaymentService } from '../../../core/PaymentService';
|
|
3
3
|
|
|
4
4
|
export class PaymentController {
|
|
5
5
|
constructor(private readonly paymentService: PaymentService) {}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
createCheckout = async (req: Request, res: Response, next: NextFunction) => {
|
|
12
|
-
try {
|
|
13
|
-
const userId = (req as any).userId as string;
|
|
14
|
-
const { priceId } = req.body;
|
|
15
|
-
|
|
16
|
-
if (!priceId) {
|
|
17
|
-
return res.status(400).json({ error: 'priceId is required' });
|
|
18
|
-
}
|
|
7
|
+
async createCheckoutSession(req: Request, res: Response) {
|
|
8
|
+
const { priceId } = req.body;
|
|
9
|
+
const userId = (req as any).user?.id as string;
|
|
19
10
|
|
|
11
|
+
try {
|
|
20
12
|
const session = await this.paymentService.createCheckoutSession(userId, priceId);
|
|
21
13
|
res.json({ url: session.url });
|
|
22
|
-
} catch (
|
|
23
|
-
|
|
14
|
+
} catch (error: any) {
|
|
15
|
+
res.status(400).json({ error: error.message });
|
|
24
16
|
}
|
|
25
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async createPortalSession(req: Request, res: Response) {
|
|
20
|
+
const userId = (req as any).user?.id as string;
|
|
26
21
|
|
|
27
|
-
/**
|
|
28
|
-
* POST /api/payments/portal
|
|
29
|
-
* Requires authentication.
|
|
30
|
-
*/
|
|
31
|
-
createPortal = async (req: Request, res: Response, next: NextFunction) => {
|
|
32
22
|
try {
|
|
33
|
-
const userId = (req as any).userId as string;
|
|
34
23
|
const session = await this.paymentService.createPortalSession(userId);
|
|
35
24
|
res.json({ url: session.url });
|
|
36
|
-
} catch (
|
|
37
|
-
|
|
25
|
+
} catch (error: any) {
|
|
26
|
+
res.status(400).json({ error: error.message });
|
|
38
27
|
}
|
|
39
|
-
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async handleWebhook(req: Request, res: Response) {
|
|
31
|
+
const sig = req.headers['stripe-signature'] as string;
|
|
40
32
|
|
|
41
|
-
/**
|
|
42
|
-
* POST /api/payments/webhook
|
|
43
|
-
* No authentication – Stripe sends the raw body here.
|
|
44
|
-
*/
|
|
45
|
-
handleWebhook = async (req: Request, res: Response, next: NextFunction) => {
|
|
46
33
|
try {
|
|
47
|
-
const
|
|
48
|
-
if (!signature) {
|
|
49
|
-
return res.status(400).json({ error: 'Missing stripe-signature header' });
|
|
50
|
-
}
|
|
51
|
-
const result = await this.paymentService.handleWebhook(req.body, signature);
|
|
34
|
+
const result = await this.paymentService.handleWebhook(req.body, sig);
|
|
52
35
|
res.json(result);
|
|
53
|
-
} catch (
|
|
54
|
-
|
|
36
|
+
} catch (error: any) {
|
|
37
|
+
res.status(400).send(`Webhook Error: ${error.message}`);
|
|
55
38
|
}
|
|
56
|
-
}
|
|
39
|
+
}
|
|
57
40
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
export const config = {
|
|
5
|
+
port: process.env.PORT || 3000,
|
|
6
|
+
env: process.env.NODE_ENV || 'development',
|
|
7
|
+
jwtSecret: process.env.JWT_SECRET || 'secret',
|
|
8
|
+
frontendUrl: process.env.FRONTEND_URL || 'http://localhost:3001',
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { User } from '
|
|
2
|
-
import { IAuthPort } from '
|
|
3
|
-
import { IUserRepositoryPort } from '
|
|
4
|
-
import { IPasswordHasherPort, ITokenGeneratorPort } from '
|
|
1
|
+
import { User } from './domain/entities/User';
|
|
2
|
+
import { IAuthPort } from './ports/inbound/IAuthPort';
|
|
3
|
+
import { IUserRepositoryPort } from './ports/outbound/IUserRepositoryPort';
|
|
4
|
+
import { IPasswordHasherPort, ITokenGeneratorPort } from './ports/outbound/ISecurityPorts';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Auth Service - Application Core
|
|
@@ -48,4 +48,4 @@ export class AuthService implements IAuthPort {
|
|
|
48
48
|
if (!decoded) return null;
|
|
49
49
|
return this.userRepository.findById(decoded.id);
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IUserRepositoryPort } from './ports/outbound/IUserRepositoryPort';
|
|
2
2
|
import { StripeAdapter } from '../adapters/outbound/StripeAdapter';
|
|
3
3
|
|
|
4
4
|
export class PaymentService {
|
|
5
5
|
constructor(
|
|
6
|
-
private readonly userRepository:
|
|
6
|
+
private readonly userRepository: IUserRepositoryPort,
|
|
7
7
|
private readonly stripeAdapter: StripeAdapter,
|
|
8
8
|
) {}
|
|
9
9
|
|
|
@@ -17,11 +17,11 @@ export class PaymentService {
|
|
|
17
17
|
const customer = await this.stripeAdapter.createCustomer(
|
|
18
18
|
user.email,
|
|
19
19
|
user.name,
|
|
20
|
-
user.id
|
|
20
|
+
user.id!,
|
|
21
21
|
);
|
|
22
22
|
customerId = customer.id;
|
|
23
|
-
|
|
24
|
-
await this.userRepository.save(
|
|
23
|
+
const updatedUser = user.withStripeCustomerId(customerId);
|
|
24
|
+
await this.userRepository.save(updatedUser);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return this.stripeAdapter.createCheckoutSession(
|
|
@@ -58,28 +58,13 @@ export class PaymentService {
|
|
|
58
58
|
if (userId && session.customer) {
|
|
59
59
|
const user = await this.userRepository.findById(userId);
|
|
60
60
|
if (user) {
|
|
61
|
-
|
|
62
|
-
await this.userRepository.save(
|
|
61
|
+
const updatedUser = user.withStripeCustomerId(session.customer as string);
|
|
62
|
+
await this.userRepository.save(updatedUser);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
console.log('Checkout completed for user:', userId);
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
|
-
case 'customer.subscription.updated': {
|
|
69
|
-
const sub = event.data.object as any;
|
|
70
|
-
console.log('Subscription updated:', sub.id, '| Status:', sub.status);
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case 'customer.subscription.deleted': {
|
|
74
|
-
const sub = event.data.object as any;
|
|
75
|
-
console.log('Subscription deleted:', sub.id);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case 'invoice.payment_failed': {
|
|
79
|
-
const invoice = event.data.object as any;
|
|
80
|
-
console.log('Payment failed for invoice:', invoice.id);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
68
|
default:
|
|
84
69
|
console.log('Unhandled Stripe event:', event.type);
|
|
85
70
|
}
|
|
@@ -22,7 +22,27 @@ export class User {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
private validatePassword(password: string): void {
|
|
25
|
-
if (!password || password.length < 8) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (!password || password.length < 8) {
|
|
26
|
+
throw new Error('Password must be at least 8 characters');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static restore(data: any): User {
|
|
31
|
+
return new User(
|
|
32
|
+
data.id,
|
|
33
|
+
data.email,
|
|
34
|
+
data.name,
|
|
35
|
+
data.password,
|
|
36
|
+
data.stripeCustomerId,
|
|
37
|
+
data.createdAt
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
withId(id: string): User {
|
|
42
|
+
return new User(id, this.email, this.name, this.password, this.stripeCustomerId, this.createdAt);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
withStripeCustomerId(customerId: string): User {
|
|
46
|
+
return new User(this.id, this.email, this.name, this.password, customerId, this.createdAt);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
|
|
6
|
+
# Build outputs
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
|
|
10
|
+
# Environment variables
|
|
11
|
+
.env
|
|
12
|
+
.env.local
|
|
13
|
+
.env.development.local
|
|
14
|
+
.env.test.local
|
|
15
|
+
.env.production.local
|
|
16
|
+
!.env.example
|
|
17
|
+
|
|
18
|
+
# Logs
|
|
19
|
+
logs/
|
|
20
|
+
*.log
|
|
21
|
+
npm-debug.log*
|
|
22
|
+
yarn-debug.log*
|
|
23
|
+
yarn-error.log*
|
|
24
|
+
pnpm-debug.log*
|
|
25
|
+
lerna-debug.log*
|
|
26
|
+
|
|
27
|
+
# Coverage
|
|
28
|
+
coverage/
|
|
29
|
+
.nyc_output
|
|
30
|
+
|
|
31
|
+
# TypeScript
|
|
32
|
+
*.tsbuildinfo
|
|
33
|
+
|
|
34
|
+
# OS
|
|
35
|
+
.DS_Store
|
|
36
|
+
Thumbs.db
|
|
37
|
+
|
|
38
|
+
# Editor
|
|
39
|
+
.vscode/
|
|
40
|
+
.idea/
|
|
41
|
+
*.swp
|
|
42
|
+
*.swo
|
|
@@ -1,69 +1,69 @@
|
|
|
1
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/**/*.ts",
|
|
11
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
-
"test": "jest",
|
|
13
|
-
"db:generate": "prisma generate",
|
|
14
|
-
"db:push": "prisma db push"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"express",
|
|
18
|
-
"api",
|
|
19
|
-
"typescript",
|
|
20
|
-
"mvc",
|
|
21
|
-
"saas",
|
|
22
|
-
"stripe",
|
|
23
|
-
"auth"
|
|
24
|
-
],
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"express": "^4.18.2",
|
|
29
|
-
"dotenv": "^16.4.5",
|
|
30
|
-
"cors": "^2.8.5",
|
|
31
|
-
"helmet": "^7.1.0",
|
|
32
|
-
"morgan": "^1.10.0",
|
|
33
|
-
"jsonwebtoken": "^9.0.2",
|
|
34
|
-
"bcryptjs": "^2.4.3",
|
|
35
|
-
"stripe": "^14.14.0",
|
|
36
|
-
"@prisma/client": "^5.10.2"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/express": "^4.17.21",
|
|
40
|
-
"@types/node": "^20.11.19",
|
|
41
|
-
"@types/cors": "^2.8.17",
|
|
42
|
-
"@types/morgan": "^1.9.9",
|
|
43
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
44
|
-
"@types/bcryptjs": "^2.4.6",
|
|
45
|
-
"typescript": "^5.3.3",
|
|
46
|
-
"tsx": "^4.7.1",
|
|
47
|
-
"rimraf": "^
|
|
48
|
-
"eslint": "^9.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
50
|
-
"@typescript-eslint/parser": "^8.0.0",
|
|
51
|
-
"prettier": "^3.2.5",
|
|
52
|
-
"jest": "^29.7.0",
|
|
53
|
-
"@types/jest": "^29.5.12",
|
|
54
|
-
"prisma": "^5.10.2"
|
|
55
|
-
},
|
|
56
|
-
"engines": {
|
|
57
|
-
"node": ">=18.0.0"
|
|
58
|
-
},
|
|
59
|
-
"overrides": {
|
|
60
|
-
"rimraf": "^6.1.2",
|
|
61
|
-
"glob": "^11.0.0",
|
|
62
|
-
"inflight": "^1.0.6",
|
|
63
|
-
"@humanwhocodes/config-array": "^0.13.0",
|
|
64
|
-
"@humanwhocodes/object-schema": "^2.0.3",
|
|
65
|
-
"eslint": "^9.16.0",
|
|
66
|
-
"cookie": "^0.7.2",
|
|
67
|
-
"minimatch": "^9.0.8"
|
|
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/**/*.ts",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"db:generate": "prisma generate",
|
|
14
|
+
"db:push": "prisma db push"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"express",
|
|
18
|
+
"api",
|
|
19
|
+
"typescript",
|
|
20
|
+
"mvc",
|
|
21
|
+
"saas",
|
|
22
|
+
"stripe",
|
|
23
|
+
"auth"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"dotenv": "^16.4.5",
|
|
30
|
+
"cors": "^2.8.5",
|
|
31
|
+
"helmet": "^7.1.0",
|
|
32
|
+
"morgan": "^1.10.0",
|
|
33
|
+
"jsonwebtoken": "^9.0.2",
|
|
34
|
+
"bcryptjs": "^2.4.3",
|
|
35
|
+
"stripe": "^14.14.0",
|
|
36
|
+
"@prisma/client": "^5.10.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/express": "^4.17.21",
|
|
40
|
+
"@types/node": "^20.11.19",
|
|
41
|
+
"@types/cors": "^2.8.17",
|
|
42
|
+
"@types/morgan": "^1.9.9",
|
|
43
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
44
|
+
"@types/bcryptjs": "^2.4.6",
|
|
45
|
+
"typescript": "^5.3.3",
|
|
46
|
+
"tsx": "^4.7.1",
|
|
47
|
+
"rimraf": "^6.1.2",
|
|
48
|
+
"eslint": "^9.16.0",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
51
|
+
"prettier": "^3.2.5",
|
|
52
|
+
"jest": "^29.7.0",
|
|
53
|
+
"@types/jest": "^29.5.12",
|
|
54
|
+
"prisma": "^5.10.2"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
},
|
|
59
|
+
"overrides": {
|
|
60
|
+
"rimraf": "^6.1.2",
|
|
61
|
+
"glob": "^11.0.0",
|
|
62
|
+
"inflight": "^1.0.6",
|
|
63
|
+
"@humanwhocodes/config-array": "^0.13.0",
|
|
64
|
+
"@humanwhocodes/object-schema": "^2.0.3",
|
|
65
|
+
"eslint": "^9.16.0",
|
|
66
|
+
"cookie": "^0.7.2",
|
|
67
|
+
"minimatch": "^9.0.8"
|
|
68
|
+
}
|
|
68
69
|
}
|
|
69
|
-
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.pyo
|
|
7
|
+
|
|
8
|
+
# Distribution / packaging
|
|
9
|
+
build/
|
|
10
|
+
develop-eggs/
|
|
11
|
+
dist/
|
|
12
|
+
downloads/
|
|
13
|
+
eggs/
|
|
14
|
+
.eggs/
|
|
15
|
+
lib/
|
|
16
|
+
lib64/
|
|
17
|
+
parts/
|
|
18
|
+
sdist/
|
|
19
|
+
var/
|
|
20
|
+
wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
# Virtual environments
|
|
27
|
+
.venv/
|
|
28
|
+
venv/
|
|
29
|
+
env/
|
|
30
|
+
ENV/
|
|
31
|
+
env.bak/
|
|
32
|
+
venv.bak/
|
|
33
|
+
.python-version
|
|
34
|
+
|
|
35
|
+
# Environment variables
|
|
36
|
+
.env
|
|
37
|
+
.env.local
|
|
38
|
+
.env.*.local
|
|
39
|
+
!.env.example
|
|
40
|
+
|
|
41
|
+
# Pytest
|
|
42
|
+
.pytest_cache/
|
|
43
|
+
pytest-cache/
|
|
44
|
+
.cache/
|
|
45
|
+
|
|
46
|
+
# Coverage
|
|
47
|
+
htmlcov/
|
|
48
|
+
.tox/
|
|
49
|
+
.coverage
|
|
50
|
+
.coverage.*
|
|
51
|
+
coverage.xml
|
|
52
|
+
*.cover
|
|
53
|
+
*.py,cover
|
|
54
|
+
|
|
55
|
+
# MyPy / Pyright
|
|
56
|
+
.mypy_cache/
|
|
57
|
+
.dmypy.json
|
|
58
|
+
dmypy.json
|
|
59
|
+
.pyright/
|
|
60
|
+
pyrightconfig.json
|
|
61
|
+
|
|
62
|
+
# Alembic — keep migrations, ignore autogenerated caches
|
|
63
|
+
# alembic/versions/ is intentionally tracked
|
|
64
|
+
|
|
65
|
+
# Jupyter
|
|
66
|
+
.ipynb_checkpoints
|
|
67
|
+
|
|
68
|
+
# OS
|
|
69
|
+
.DS_Store
|
|
70
|
+
Thumbs.db
|
|
71
|
+
|
|
72
|
+
# Editor
|
|
73
|
+
.vscode/
|
|
74
|
+
.idea/
|
|
75
|
+
*.swp
|
|
76
|
+
*.swo
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from app.domain.repositories.user_repository import
|
|
2
|
+
from app.domain.repositories.user_repository import IUserRepository
|
|
3
3
|
from app.infrastructure.stripe_provider import StripeProvider
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class PaymentService:
|
|
7
|
-
def __init__(self, user_repository:
|
|
7
|
+
def __init__(self, user_repository: IUserRepository, stripe_provider: StripeProvider):
|
|
8
8
|
self.user_repository = user_repository
|
|
9
9
|
self.stripe_provider = stripe_provider
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ class PaymentService:
|
|
|
30
30
|
customer_id=customer_id,
|
|
31
31
|
price_id=price_id,
|
|
32
32
|
user_id=str(user_id),
|
|
33
|
-
success_url=f"{os.getenv('FRONTEND_URL')}/success?session_id={{CHECKOUT_SESSION_ID}}",
|
|
33
|
+
success_url=f"{os.getenv('FRONTEND_URL')}/success?session_id={'{CHECKOUT_SESSION_ID}'}",
|
|
34
34
|
cancel_url=f"{os.getenv('FRONTEND_URL')}/cancel",
|
|
35
35
|
)
|
|
36
36
|
return session.url
|
|
@@ -4,20 +4,19 @@ from functools import lru_cache
|
|
|
4
4
|
class Settings(BaseSettings):
|
|
5
5
|
PROJECT_NAME: str = "{{projectName}}"
|
|
6
6
|
API_V1_STR: str = "/api/v1"
|
|
7
|
-
|
|
8
|
-
# Database
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
|
|
8
|
+
# Database — use asyncpg for async SQLAlchemy
|
|
9
|
+
DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/{{projectName}}"
|
|
10
|
+
|
|
12
11
|
# Security
|
|
13
12
|
SECRET_KEY: str = "change_this_to_a_secure_random_key"
|
|
14
13
|
ALGORITHM: str = "HS256"
|
|
15
14
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
# Stripe
|
|
18
17
|
STRIPE_API_KEY: str | None = None
|
|
19
18
|
|
|
20
|
-
model_config = SettingsConfigDict(env_file=".env", case_sensitive=True)
|
|
19
|
+
model_config = SettingsConfigDict(env_file=".env", case_sensitive=True, extra="ignore")
|
|
21
20
|
|
|
22
21
|
@lru_cache
|
|
23
22
|
def get_settings():
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from app.domain.repositories.user_repository import IUserRepository
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LoginUserUseCase:
|
|
5
|
+
def __init__(self, repo: IUserRepository, hasher, token_gen):
|
|
6
|
+
self.repo = repo
|
|
7
|
+
self.hasher = hasher
|
|
8
|
+
self.token_gen = token_gen
|
|
9
|
+
|
|
10
|
+
async def execute(self, email: str, password: str) -> dict:
|
|
11
|
+
user = await self.repo.find_by_email(email)
|
|
12
|
+
if not user or not self.hasher.verify(password, user.password):
|
|
13
|
+
raise ValueError("Invalid email or password")
|
|
14
|
+
token = self.token_gen.generate(user.id, user.email)
|
|
15
|
+
return {"user": user, "token": token}
|