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
package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.routes.integration.test.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import request from 'supertest';
|
|
2
|
+
import app from '../../../app';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Integration tests for Cart routes.
|
|
6
|
+
* Uses in-memory repositories via the cart.registry module.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
let customerToken: string;
|
|
10
|
+
let adminToken: string;
|
|
11
|
+
let productId: string;
|
|
12
|
+
let variantId: string;
|
|
13
|
+
|
|
14
|
+
const CUSTOMER_USER = {
|
|
15
|
+
name: 'Cart Customer',
|
|
16
|
+
email: 'cart.customer@ecommerce.com',
|
|
17
|
+
password: 'cartpass123',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ADMIN_USER = {
|
|
21
|
+
name: 'Cart Admin',
|
|
22
|
+
email: 'cart.admin@ecommerce.com',
|
|
23
|
+
password: 'adminpass123',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
beforeAll(async () => {
|
|
27
|
+
// Register customer
|
|
28
|
+
await request(app).post('/api/auth/register').send(CUSTOMER_USER);
|
|
29
|
+
|
|
30
|
+
// Create admin via registry
|
|
31
|
+
const { userRepository } = await import('../../auth/auth.registry');
|
|
32
|
+
const { UserEntity } = await import('../../auth/user.entity');
|
|
33
|
+
const { hash } = await import('bcryptjs');
|
|
34
|
+
const adminHash = await hash(ADMIN_USER.password, 10);
|
|
35
|
+
const adminEntity = UserEntity.create({
|
|
36
|
+
name: ADMIN_USER.name,
|
|
37
|
+
email: ADMIN_USER.email,
|
|
38
|
+
passwordHash: adminHash,
|
|
39
|
+
role: 'ADMIN',
|
|
40
|
+
});
|
|
41
|
+
await userRepository.create(adminEntity);
|
|
42
|
+
|
|
43
|
+
// Login both
|
|
44
|
+
const customerRes = await request(app).post('/api/auth/login').send({
|
|
45
|
+
email: CUSTOMER_USER.email,
|
|
46
|
+
password: CUSTOMER_USER.password,
|
|
47
|
+
});
|
|
48
|
+
customerToken = (customerRes.body as { accessToken: string }).accessToken;
|
|
49
|
+
|
|
50
|
+
const adminRes = await request(app).post('/api/auth/login').send({
|
|
51
|
+
email: ADMIN_USER.email,
|
|
52
|
+
password: ADMIN_USER.password,
|
|
53
|
+
});
|
|
54
|
+
adminToken = (adminRes.body as { accessToken: string }).accessToken;
|
|
55
|
+
|
|
56
|
+
// Create a product+variant via catalog API for cart tests
|
|
57
|
+
const { catalogRegistry } = await import('../../catalog/catalog.registry');
|
|
58
|
+
const { CategoryEntity } = await import('../../catalog/category.entity');
|
|
59
|
+
await catalogRegistry.categoryRepository.create(
|
|
60
|
+
CategoryEntity.create({ name: 'Cart Test', slug: 'cart-test', description: null, parentId: null }),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const productRes = await request(app)
|
|
64
|
+
.post('/api/products')
|
|
65
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
66
|
+
.send({
|
|
67
|
+
name: 'Produto do Carrinho',
|
|
68
|
+
price: 99.9,
|
|
69
|
+
categorySlug: 'cart-test',
|
|
70
|
+
images: [],
|
|
71
|
+
variants: [{ sku: 'CART-P', size: 'P', color: 'Azul', stock: 10 }],
|
|
72
|
+
});
|
|
73
|
+
const body = productRes.body as { id: string; variants: Array<{ id: string }> };
|
|
74
|
+
productId = body.id;
|
|
75
|
+
variantId = body.variants[0]!.id;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// ── GET /api/cart ─────────────────────────────────────────────────────────────
|
|
79
|
+
describe('GET /api/cart', () => {
|
|
80
|
+
it('200: deve retornar carrinho vazio se não existir', async () => {
|
|
81
|
+
const res = await request(app)
|
|
82
|
+
.get('/api/cart')
|
|
83
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
84
|
+
|
|
85
|
+
expect(res.status).toBe(200);
|
|
86
|
+
expect(res.body).toMatchObject({ items: [], subtotal: 0, discount: 0, total: 0 });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('401: deve exigir autenticação', async () => {
|
|
90
|
+
const res = await request(app).get('/api/cart');
|
|
91
|
+
expect(res.status).toBe(401);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// ── POST /api/cart/items ──────────────────────────────────────────────────────
|
|
96
|
+
describe('POST /api/cart/items', () => {
|
|
97
|
+
it('201: deve adicionar item ao carrinho', async () => {
|
|
98
|
+
const res = await request(app)
|
|
99
|
+
.post('/api/cart/items')
|
|
100
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
101
|
+
.send({ productId, variantId, qty: 2 });
|
|
102
|
+
|
|
103
|
+
expect(res.status).toBe(201);
|
|
104
|
+
expect(res.body.items).toHaveLength(1);
|
|
105
|
+
expect(res.body.items[0].qty).toBe(2);
|
|
106
|
+
expect(res.body.subtotal).toBeCloseTo(199.8, 1);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('400: deve rejeitar quantidade <= 0', async () => {
|
|
110
|
+
const res = await request(app)
|
|
111
|
+
.post('/api/cart/items')
|
|
112
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
113
|
+
.send({ productId, variantId, qty: 0 });
|
|
114
|
+
|
|
115
|
+
expect(res.status).toBe(400);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('409: deve retornar erro se estoque insuficiente', async () => {
|
|
119
|
+
const res = await request(app)
|
|
120
|
+
.post('/api/cart/items')
|
|
121
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
122
|
+
.send({ productId, variantId, qty: 9999 });
|
|
123
|
+
|
|
124
|
+
expect(res.status).toBe(409);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ── PATCH /api/cart/items/:variantId ──────────────────────────────────────────
|
|
129
|
+
describe('PATCH /api/cart/items/:variantId', () => {
|
|
130
|
+
it('200: deve atualizar quantidade do item', async () => {
|
|
131
|
+
const res = await request(app)
|
|
132
|
+
.patch(`/api/cart/items/${variantId}`)
|
|
133
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
134
|
+
.send({ qty: 3 });
|
|
135
|
+
|
|
136
|
+
expect(res.status).toBe(200);
|
|
137
|
+
expect(res.body.items[0].qty).toBe(3);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('deve remover item automaticamente se quantidade = 0', async () => {
|
|
141
|
+
const res = await request(app)
|
|
142
|
+
.patch(`/api/cart/items/${variantId}`)
|
|
143
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
144
|
+
.send({ qty: 0 });
|
|
145
|
+
|
|
146
|
+
expect(res.status).toBe(200);
|
|
147
|
+
expect(res.body.items).toHaveLength(0);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Re-add item for remaining tests
|
|
152
|
+
let secondVariantId: string;
|
|
153
|
+
|
|
154
|
+
beforeAll(async () => {
|
|
155
|
+
// Add item back after the update-to-zero test removes it
|
|
156
|
+
// Also grab a second variantId for DELETE test isolation
|
|
157
|
+
secondVariantId = variantId; // reuse for simplicity
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// ── DELETE /api/cart/items/:variantId ─────────────────────────────────────────
|
|
161
|
+
describe('DELETE /api/cart/items/:variantId', () => {
|
|
162
|
+
it('204: deve remover item', async () => {
|
|
163
|
+
// First add item back
|
|
164
|
+
await request(app)
|
|
165
|
+
.post('/api/cart/items')
|
|
166
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
167
|
+
.send({ productId, variantId, qty: 1 });
|
|
168
|
+
|
|
169
|
+
const res = await request(app)
|
|
170
|
+
.delete(`/api/cart/items/${variantId}`)
|
|
171
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
172
|
+
|
|
173
|
+
expect(res.status).toBe(204);
|
|
174
|
+
|
|
175
|
+
const cart = await request(app)
|
|
176
|
+
.get('/api/cart')
|
|
177
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
178
|
+
expect((cart.body as { items: unknown[] }).items).toHaveLength(0);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ── POST /api/cart/coupon ─────────────────────────────────────────────────────
|
|
183
|
+
describe('POST /api/cart/coupon', () => {
|
|
184
|
+
it('200: deve aplicar cupom válido e retornar total atualizado', async () => {
|
|
185
|
+
// Add item first
|
|
186
|
+
await request(app)
|
|
187
|
+
.post('/api/cart/items')
|
|
188
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
189
|
+
.send({ productId, variantId, qty: 1 });
|
|
190
|
+
|
|
191
|
+
const res = await request(app)
|
|
192
|
+
.post('/api/cart/coupon')
|
|
193
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
194
|
+
.send({ code: 'PROMO10' });
|
|
195
|
+
|
|
196
|
+
expect(res.status).toBe(200);
|
|
197
|
+
expect(res.body.discount).toBeGreaterThan(0);
|
|
198
|
+
expect(res.body.couponCode).toBe('PROMO10');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('404: deve rejeitar cupom inexistente', async () => {
|
|
202
|
+
const res = await request(app)
|
|
203
|
+
.post('/api/cart/coupon')
|
|
204
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
205
|
+
.send({ code: 'NAOEXISTE' });
|
|
206
|
+
|
|
207
|
+
expect(res.status).toBe(404);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('400: deve rejeitar cupom expirado', async () => {
|
|
211
|
+
const res = await request(app)
|
|
212
|
+
.post('/api/cart/coupon')
|
|
213
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
214
|
+
.send({ code: 'EXPIRED' });
|
|
215
|
+
|
|
216
|
+
expect(res.status).toBe(400);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// ── GET /api/cart/shipping ────────────────────────────────────────────────────
|
|
221
|
+
describe('GET /api/cart/shipping', () => {
|
|
222
|
+
it('200: deve retornar opções de frete calculadas para um CEP', async () => {
|
|
223
|
+
const res = await request(app)
|
|
224
|
+
.get('/api/cart/shipping?cep=01310100')
|
|
225
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
226
|
+
|
|
227
|
+
expect(res.status).toBe(200);
|
|
228
|
+
expect(Array.isArray(res.body)).toBe(true);
|
|
229
|
+
expect(res.body.length).toBeGreaterThan(0);
|
|
230
|
+
expect(res.body[0]).toHaveProperty('name');
|
|
231
|
+
expect(res.body[0]).toHaveProperty('price');
|
|
232
|
+
expect(res.body[0]).toHaveProperty('estimatedDays');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('400: deve rejeitar CEP inválido', async () => {
|
|
236
|
+
const res = await request(app)
|
|
237
|
+
.get('/api/cart/shipping?cep=123')
|
|
238
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
239
|
+
|
|
240
|
+
expect(res.status).toBe(400);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { CartService } from '../cart.service';
|
|
2
|
+
import { ICartRepository } from '../cart.repository';
|
|
3
|
+
import { ICouponRepository } from '../coupon.repository';
|
|
4
|
+
import { IShippingService, ShippingOption } from '../shipping.service';
|
|
5
|
+
import { IProductRepository } from '../../catalog/product.repository';
|
|
6
|
+
import { CartEntity } from '../cart.entity';
|
|
7
|
+
import { CouponEntity } from '../coupon.entity';
|
|
8
|
+
|
|
9
|
+
jest.mock('../cart.repository');
|
|
10
|
+
jest.mock('../coupon.repository');
|
|
11
|
+
jest.mock('../shipping.service');
|
|
12
|
+
jest.mock('../../catalog/product.repository');
|
|
13
|
+
|
|
14
|
+
function makeVariant(overrides: Record<string, unknown> = {}) {
|
|
15
|
+
return {
|
|
16
|
+
id: 'var-1',
|
|
17
|
+
sku: 'CAM-P',
|
|
18
|
+
size: 'P',
|
|
19
|
+
color: 'Branco',
|
|
20
|
+
stock: 10,
|
|
21
|
+
price: null,
|
|
22
|
+
productId: 'prod-1',
|
|
23
|
+
...overrides,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function makeProduct(overrides: Record<string, unknown> = {}) {
|
|
28
|
+
return {
|
|
29
|
+
id: 'prod-1',
|
|
30
|
+
name: 'Camiseta Básica',
|
|
31
|
+
slug: 'camiseta-basica',
|
|
32
|
+
price: 99.9,
|
|
33
|
+
images: [],
|
|
34
|
+
variants: [makeVariant()],
|
|
35
|
+
toRecord: jest.fn().mockReturnThis(),
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('CartService — Unit', () => {
|
|
41
|
+
let cartRepo: jest.Mocked<ICartRepository>;
|
|
42
|
+
let couponRepo: jest.Mocked<ICouponRepository>;
|
|
43
|
+
let shippingService: jest.Mocked<IShippingService>;
|
|
44
|
+
let productRepo: jest.Mocked<IProductRepository>;
|
|
45
|
+
let service: CartService;
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
cartRepo = {
|
|
49
|
+
findByUserId: jest.fn(),
|
|
50
|
+
findBySessionId: jest.fn(),
|
|
51
|
+
save: jest.fn(),
|
|
52
|
+
delete: jest.fn(),
|
|
53
|
+
} as jest.Mocked<ICartRepository>;
|
|
54
|
+
|
|
55
|
+
couponRepo = {
|
|
56
|
+
findByCode: jest.fn(),
|
|
57
|
+
findById: jest.fn(),
|
|
58
|
+
findAll: jest.fn(),
|
|
59
|
+
save: jest.fn(),
|
|
60
|
+
deleteById: jest.fn(),
|
|
61
|
+
incrementUsage: jest.fn(),
|
|
62
|
+
} as jest.Mocked<ICouponRepository>;
|
|
63
|
+
|
|
64
|
+
shippingService = {
|
|
65
|
+
calculate: jest.fn(),
|
|
66
|
+
} as jest.Mocked<IShippingService>;
|
|
67
|
+
|
|
68
|
+
productRepo = {
|
|
69
|
+
findById: jest.fn(),
|
|
70
|
+
findBySlug: jest.fn(),
|
|
71
|
+
findAll: jest.fn(),
|
|
72
|
+
search: jest.fn(),
|
|
73
|
+
create: jest.fn(),
|
|
74
|
+
update: jest.fn(),
|
|
75
|
+
softDelete: jest.fn(),
|
|
76
|
+
updateVariantStock: jest.fn(),
|
|
77
|
+
slugExists: jest.fn(),
|
|
78
|
+
} as jest.Mocked<IProductRepository>;
|
|
79
|
+
|
|
80
|
+
service = new CartService(cartRepo, couponRepo, shippingService, productRepo);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('deve criar carrinho vazio para novo usuário', async () => {
|
|
84
|
+
cartRepo.findByUserId.mockResolvedValue(null);
|
|
85
|
+
cartRepo.save.mockImplementation(async (cart) => cart);
|
|
86
|
+
|
|
87
|
+
const cart = await service.getCart({ userId: 'user-1' });
|
|
88
|
+
|
|
89
|
+
expect(cart.items).toHaveLength(0);
|
|
90
|
+
expect(cart.userId).toBe('user-1');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('deve persistir carrinho no "Redis" com TTL via save', async () => {
|
|
94
|
+
cartRepo.findByUserId.mockResolvedValue(null);
|
|
95
|
+
const savedCart = CartEntity.create('user-1');
|
|
96
|
+
cartRepo.save.mockResolvedValue(savedCart);
|
|
97
|
+
|
|
98
|
+
const item = { variantId: 'var-1', productId: 'prod-1', qty: 1 };
|
|
99
|
+
const product = makeProduct();
|
|
100
|
+
productRepo.findById.mockResolvedValue(product as never);
|
|
101
|
+
cartRepo.findByUserId.mockResolvedValueOnce(CartEntity.create('user-1'));
|
|
102
|
+
cartRepo.save.mockImplementation(async (c) => c);
|
|
103
|
+
|
|
104
|
+
await service.addItem({ userId: 'user-1' }, item);
|
|
105
|
+
|
|
106
|
+
expect(cartRepo.save).toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('deve mesclar carrinho anônimo com carrinho do usuário ao login', async () => {
|
|
110
|
+
const anonCart = CartEntity.create(null, 'session-abc')
|
|
111
|
+
.addItem({ variantId: 'var-1', productId: 'prod-1', name: 'Camiseta', sku: 'CAM-P', price: 99.9, qty: 2, image: null });
|
|
112
|
+
|
|
113
|
+
const userCart = CartEntity.create('user-1')
|
|
114
|
+
.addItem({ variantId: 'var-2', productId: 'prod-2', name: 'Calça', sku: 'CAL-M', price: 150, qty: 1, image: null });
|
|
115
|
+
|
|
116
|
+
cartRepo.findBySessionId.mockResolvedValue(anonCart);
|
|
117
|
+
cartRepo.findByUserId.mockResolvedValue(userCart);
|
|
118
|
+
cartRepo.save.mockImplementation(async (c) => c);
|
|
119
|
+
cartRepo.delete.mockResolvedValue();
|
|
120
|
+
|
|
121
|
+
const merged = await service.mergeAnonymousCart('user-1', 'session-abc');
|
|
122
|
+
|
|
123
|
+
expect(merged.items).toHaveLength(2);
|
|
124
|
+
expect(cartRepo.delete).toHaveBeenCalledWith({ sessionId: 'session-abc' });
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('deve validar estoque disponível ao adicionar item', async () => {
|
|
128
|
+
const product = makeProduct({ variants: [makeVariant({ stock: 0 })] });
|
|
129
|
+
productRepo.findById.mockResolvedValue(product as never);
|
|
130
|
+
cartRepo.findByUserId.mockResolvedValue(CartEntity.create('user-1'));
|
|
131
|
+
|
|
132
|
+
await expect(
|
|
133
|
+
service.addItem({ userId: 'user-1' }, { variantId: 'var-1', productId: 'prod-1', qty: 1 }),
|
|
134
|
+
).rejects.toThrow('Estoque insuficiente');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('deve calcular opções de frete via shippingService', async () => {
|
|
138
|
+
const options: ShippingOption[] = [
|
|
139
|
+
{ name: 'PAC', price: 18.5, estimatedDays: 7 },
|
|
140
|
+
{ name: 'SEDEX', price: 32, estimatedDays: 2 },
|
|
141
|
+
];
|
|
142
|
+
shippingService.calculate.mockResolvedValue(options);
|
|
143
|
+
cartRepo.findByUserId.mockResolvedValue(CartEntity.create('user-1'));
|
|
144
|
+
|
|
145
|
+
const result = await service.getShippingOptions({ userId: 'user-1' }, '01310-100');
|
|
146
|
+
|
|
147
|
+
expect(result).toHaveLength(2);
|
|
148
|
+
expect(result[0]!.name).toBe('PAC');
|
|
149
|
+
expect(shippingService.calculate).toHaveBeenCalledWith('01310-100', expect.any(Array));
|
|
150
|
+
});
|
|
151
|
+
});
|
package/templates/ecommerce/apps/api/src/modules/cart/__tests__/coupon.admin.integration.test.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Coupon Routes — Integration Tests (Phase 13)
|
|
3
|
+
* Uses in-memory repositories; runs against the full Express app.
|
|
4
|
+
*/
|
|
5
|
+
import request from 'supertest';
|
|
6
|
+
import app from '../../../app';
|
|
7
|
+
import { userRepository } from '../../auth/auth.registry';
|
|
8
|
+
import { UserEntity } from '../../auth/user.entity';
|
|
9
|
+
import bcrypt from 'bcryptjs';
|
|
10
|
+
|
|
11
|
+
let adminToken: string;
|
|
12
|
+
let customerToken: string;
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
const adminHash = await bcrypt.hash('admin13pass', 1);
|
|
16
|
+
const admin = UserEntity.create({
|
|
17
|
+
name: 'Admin13',
|
|
18
|
+
email: 'admin13@test.com',
|
|
19
|
+
passwordHash: adminHash,
|
|
20
|
+
role: 'ADMIN',
|
|
21
|
+
});
|
|
22
|
+
await userRepository.create(admin);
|
|
23
|
+
|
|
24
|
+
const adminRes = await request(app)
|
|
25
|
+
.post('/api/auth/login')
|
|
26
|
+
.send({ email: 'admin13@test.com', password: 'admin13pass' });
|
|
27
|
+
adminToken = adminRes.body.accessToken as string;
|
|
28
|
+
|
|
29
|
+
const custHash = await bcrypt.hash('cust13pass', 1);
|
|
30
|
+
const customer = UserEntity.create({
|
|
31
|
+
name: 'Customer13',
|
|
32
|
+
email: 'customer13@test.com',
|
|
33
|
+
passwordHash: custHash,
|
|
34
|
+
role: 'CUSTOMER',
|
|
35
|
+
});
|
|
36
|
+
await userRepository.create(customer);
|
|
37
|
+
|
|
38
|
+
const custRes = await request(app)
|
|
39
|
+
.post('/api/auth/login')
|
|
40
|
+
.send({ email: 'customer13@test.com', password: 'cust13pass' });
|
|
41
|
+
customerToken = custRes.body.accessToken as string;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('Admin Coupon Routes', () => {
|
|
45
|
+
const validPayload = {
|
|
46
|
+
code: 'PHASE13TEST',
|
|
47
|
+
discountType: 'percent',
|
|
48
|
+
discountValue: 15,
|
|
49
|
+
minOrderValue: 0,
|
|
50
|
+
usageLimit: 100,
|
|
51
|
+
expiresAt: null,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
it('POST /api/admin/coupons — 201: cria cupom com dados válidos', async () => {
|
|
55
|
+
const res = await request(app)
|
|
56
|
+
.post('/api/admin/coupons')
|
|
57
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
58
|
+
.send(validPayload);
|
|
59
|
+
|
|
60
|
+
expect(res.status).toBe(201);
|
|
61
|
+
expect(res.body).toMatchObject({
|
|
62
|
+
id: expect.any(String),
|
|
63
|
+
code: 'PHASE13TEST',
|
|
64
|
+
discountType: 'percent',
|
|
65
|
+
discountValue: 15,
|
|
66
|
+
usageCount: 0,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('POST /api/admin/coupons — 409: rejeita código duplicado', async () => {
|
|
71
|
+
// First creation
|
|
72
|
+
await request(app)
|
|
73
|
+
.post('/api/admin/coupons')
|
|
74
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
75
|
+
.send({ ...validPayload, code: 'DUPLICATE13' });
|
|
76
|
+
|
|
77
|
+
// Second creation with same code
|
|
78
|
+
const res = await request(app)
|
|
79
|
+
.post('/api/admin/coupons')
|
|
80
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
81
|
+
.send({ ...validPayload, code: 'DUPLICATE13' });
|
|
82
|
+
|
|
83
|
+
expect(res.status).toBe(409);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('POST /api/admin/coupons — 400: rejeita payload inválido (discountValue <= 0)', async () => {
|
|
87
|
+
const res = await request(app)
|
|
88
|
+
.post('/api/admin/coupons')
|
|
89
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
90
|
+
.send({ ...validPayload, code: 'BADVALUE13', discountValue: 0 });
|
|
91
|
+
|
|
92
|
+
expect(res.status).toBe(400);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('POST /api/admin/coupons — 403: rejeita CUSTOMER', async () => {
|
|
96
|
+
const res = await request(app)
|
|
97
|
+
.post('/api/admin/coupons')
|
|
98
|
+
.set('Authorization', `Bearer ${customerToken}`)
|
|
99
|
+
.send(validPayload);
|
|
100
|
+
|
|
101
|
+
expect(res.status).toBe(403);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('GET /api/admin/coupons — 200: retorna lista de cupons', async () => {
|
|
105
|
+
const res = await request(app)
|
|
106
|
+
.get('/api/admin/coupons')
|
|
107
|
+
.set('Authorization', `Bearer ${adminToken}`);
|
|
108
|
+
|
|
109
|
+
expect(res.status).toBe(200);
|
|
110
|
+
expect(res.body).toHaveProperty('items');
|
|
111
|
+
expect(Array.isArray(res.body.items)).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('DELETE /api/admin/coupons/:id — 204: remove cupom', async () => {
|
|
115
|
+
const createRes = await request(app)
|
|
116
|
+
.post('/api/admin/coupons')
|
|
117
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
118
|
+
.send({ ...validPayload, code: 'DELETEME13' });
|
|
119
|
+
|
|
120
|
+
const { id } = createRes.body as { id: string };
|
|
121
|
+
|
|
122
|
+
const res = await request(app)
|
|
123
|
+
.delete(`/api/admin/coupons/${id}`)
|
|
124
|
+
.set('Authorization', `Bearer ${adminToken}`);
|
|
125
|
+
|
|
126
|
+
expect(res.status).toBe(204);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('DELETE /api/admin/coupons/:id — 400: id não-UUID', async () => {
|
|
130
|
+
const res = await request(app)
|
|
131
|
+
.delete('/api/admin/coupons/not-a-uuid')
|
|
132
|
+
.set('Authorization', `Bearer ${adminToken}`);
|
|
133
|
+
|
|
134
|
+
expect(res.status).toBe(400);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { cartService } from './cart.registry';
|
|
4
|
+
import type { CartKey } from './cart.service';
|
|
5
|
+
|
|
6
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
7
|
+
function cartKey(req: Request): CartKey {
|
|
8
|
+
// req.user is attached by authenticate middleware — always present on cart routes
|
|
9
|
+
const user = req.user as { id: string } | undefined;
|
|
10
|
+
if (user) return { userId: user.id };
|
|
11
|
+
// Fallback for anonymous access (not currently used — routes all require auth)
|
|
12
|
+
const sessionId = (req.headers['x-session-id'] as string | undefined) ?? 'anon';
|
|
13
|
+
return { sessionId };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ── Zod schemas ───────────────────────────────────────────────────────────────
|
|
17
|
+
const addItemSchema = z.object({
|
|
18
|
+
productId: z.string().min(1),
|
|
19
|
+
variantId: z.string().min(1),
|
|
20
|
+
qty: z.number().int().min(1, 'Quantidade deve ser maior que zero'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const updateItemSchema = z.object({
|
|
24
|
+
qty: z.number().int().min(0, 'Quantidade não pode ser negativa'),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const applyCouponSchema = z.object({
|
|
28
|
+
code: z.string().min(1),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const shippingQuerySchema = z.object({
|
|
32
|
+
cep: z.string().regex(/^\d{8}$/, 'CEP inválido — use 8 dígitos numéricos'),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ── Controllers ───────────────────────────────────────────────────────────────
|
|
36
|
+
export async function getCart(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
37
|
+
try {
|
|
38
|
+
const cart = await cartService.getCart(cartKey(req));
|
|
39
|
+
res.status(200).json(cart.toRecord());
|
|
40
|
+
} catch (err) {
|
|
41
|
+
next(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function addItem(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
46
|
+
try {
|
|
47
|
+
const dto = addItemSchema.parse(req.body);
|
|
48
|
+
const cart = await cartService.addItem(cartKey(req), dto);
|
|
49
|
+
res.status(201).json(cart.toRecord());
|
|
50
|
+
} catch (err) {
|
|
51
|
+
next(err);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function updateItem(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
56
|
+
try {
|
|
57
|
+
const { variantId } = req.params as { variantId: string };
|
|
58
|
+
const { qty } = updateItemSchema.parse(req.body);
|
|
59
|
+
const cart = await cartService.updateItem(cartKey(req), variantId, qty);
|
|
60
|
+
res.status(200).json(cart.toRecord());
|
|
61
|
+
} catch (err) {
|
|
62
|
+
next(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function removeItem(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
67
|
+
try {
|
|
68
|
+
const { variantId } = req.params as { variantId: string };
|
|
69
|
+
await cartService.removeItem(cartKey(req), variantId);
|
|
70
|
+
res.status(204).send();
|
|
71
|
+
} catch (err) {
|
|
72
|
+
next(err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function applyCoupon(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
77
|
+
try {
|
|
78
|
+
const { code } = applyCouponSchema.parse(req.body);
|
|
79
|
+
const cart = await cartService.applyCoupon(cartKey(req), code);
|
|
80
|
+
res.status(200).json(cart.toRecord());
|
|
81
|
+
} catch (err) {
|
|
82
|
+
next(err);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function getShipping(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
87
|
+
try {
|
|
88
|
+
const { cep } = shippingQuerySchema.parse(req.query);
|
|
89
|
+
const options = await cartService.getShippingOptions(cartKey(req), cep);
|
|
90
|
+
res.status(200).json(options);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
next(err);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../domain/cart/cart.entity';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../infrastructure/config/registry/cart.registry';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { authenticate } from '../../shared/middlewares/authenticate';
|
|
3
|
+
import * as cartController from './cart.controller';
|
|
4
|
+
|
|
5
|
+
const router = Router();
|
|
6
|
+
|
|
7
|
+
// All cart routes require authentication (users must be logged in)
|
|
8
|
+
router.use(authenticate);
|
|
9
|
+
|
|
10
|
+
router.get('/', cartController.getCart);
|
|
11
|
+
router.post('/items', cartController.addItem);
|
|
12
|
+
router.patch('/items/:variantId', cartController.updateItem);
|
|
13
|
+
router.delete('/items/:variantId', cartController.removeItem);
|
|
14
|
+
router.post('/coupon', cartController.applyCoupon);
|
|
15
|
+
router.get('/shipping', cartController.getShipping);
|
|
16
|
+
|
|
17
|
+
export default router;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../application/cart/cart.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../domain/cart/coupon.entity';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../application/cart/coupon.service';
|