kybernus 3.1.0 → 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/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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { profileService } from '../../../infrastructure/config/registry/profile.registry';
|
|
4
|
+
import { tokenService } from '../../../infrastructure/config/registry/auth.registry';
|
|
5
|
+
|
|
6
|
+
const REFRESH_COOKIE = 'refreshToken';
|
|
7
|
+
|
|
8
|
+
export async function getProfile(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
const profile = await profileService.getProfile(req.user!.id);
|
|
11
|
+
res.status(200).json(profile);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
next(err);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function updateProfile(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
18
|
+
const parsed = z
|
|
19
|
+
.object({
|
|
20
|
+
name: z.string().min(2, 'Nome deve ter pelo menos 2 caracteres').optional(),
|
|
21
|
+
email: z.string().email('Email inválido').optional(),
|
|
22
|
+
})
|
|
23
|
+
.refine((d) => d.name !== undefined || d.email !== undefined, {
|
|
24
|
+
message: 'Ao menos um campo (name ou email) deve ser informado',
|
|
25
|
+
})
|
|
26
|
+
.safeParse(req.body);
|
|
27
|
+
|
|
28
|
+
if (!parsed.success) {
|
|
29
|
+
res.status(400).json({ errors: parsed.error.flatten().fieldErrors, message: parsed.error.errors[0]?.message });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const profile = await profileService.updateProfile(req.user!.id, parsed.data);
|
|
35
|
+
res.status(200).json(profile);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
next(err);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function changePassword(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
42
|
+
const parsed = z
|
|
43
|
+
.object({
|
|
44
|
+
currentPassword: z.string().min(1, 'Senha atual é obrigatória'),
|
|
45
|
+
newPassword: z.string().min(8, 'Nova senha deve ter pelo menos 8 caracteres'),
|
|
46
|
+
})
|
|
47
|
+
.safeParse(req.body);
|
|
48
|
+
|
|
49
|
+
if (!parsed.success) {
|
|
50
|
+
res.status(400).json({ errors: parsed.error.flatten().fieldErrors });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
await profileService.changePassword(req.user!.id, parsed.data);
|
|
56
|
+
res.status(204).send();
|
|
57
|
+
} catch (err) {
|
|
58
|
+
next(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function deleteAccount(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
63
|
+
const parsed = z
|
|
64
|
+
.object({
|
|
65
|
+
password: z.string().min(1, 'Senha é obrigatória para confirmar exclusão'),
|
|
66
|
+
})
|
|
67
|
+
.safeParse(req.body);
|
|
68
|
+
|
|
69
|
+
if (!parsed.success) {
|
|
70
|
+
res.status(400).json({ errors: parsed.error.flatten().fieldErrors });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await profileService.deleteAccount(req.user!.id, parsed.data.password);
|
|
76
|
+
|
|
77
|
+
// Best-effort: invalidate the refresh token cookie if present
|
|
78
|
+
const refreshToken = (req.cookies as Record<string, string | undefined>)[REFRESH_COOKIE];
|
|
79
|
+
if (refreshToken) {
|
|
80
|
+
try {
|
|
81
|
+
await tokenService.invalidateRefreshToken(refreshToken);
|
|
82
|
+
} catch {
|
|
83
|
+
// ignore — token may already be expired
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
res.clearCookie(REFRESH_COOKIE);
|
|
88
|
+
res.status(204).send();
|
|
89
|
+
} catch (err) {
|
|
90
|
+
next(err);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { authenticate } from '../../middlewares/authenticate';
|
|
3
|
+
import * as profileController from './profile.controller';
|
|
4
|
+
|
|
5
|
+
const router = Router();
|
|
6
|
+
|
|
7
|
+
router.use(authenticate);
|
|
8
|
+
|
|
9
|
+
router.get('/', profileController.getProfile);
|
|
10
|
+
router.patch('/', profileController.updateProfile);
|
|
11
|
+
router.patch('/password', profileController.changePassword);
|
|
12
|
+
router.delete('/', profileController.deleteAccount);
|
|
13
|
+
|
|
14
|
+
export default router;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Request, Response, NextFunction } from 'express';
|
|
3
|
+
|
|
4
|
+
export const uuidSchema = z.string().uuid('ID inválido — formato UUID esperado');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Express middleware that validates req.params[paramName] is a valid UUID v4.
|
|
8
|
+
* Returns 400 immediately for malformed IDs, preventing unnecessary DB queries
|
|
9
|
+
* and path traversal attempts.
|
|
10
|
+
*/
|
|
11
|
+
export function validateUuidParam(paramName = 'id') {
|
|
12
|
+
return (req: Request, res: Response, next: NextFunction): void => {
|
|
13
|
+
const result = uuidSchema.safeParse(req.params[paramName]);
|
|
14
|
+
if (!result.success) {
|
|
15
|
+
res.status(400).json({ error: 'ID inválido — formato UUID esperado' });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
next();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import app from './app';
|
|
3
|
+
import { prisma } from './shared/infra/prisma';
|
|
4
|
+
|
|
5
|
+
// ── Startup env validation ────────────────────────────────────────────────────
|
|
6
|
+
const REQUIRED_ENV_VARS = [
|
|
7
|
+
'DATABASE_URL',
|
|
8
|
+
'REDIS_URL',
|
|
9
|
+
'JWT_SECRET',
|
|
10
|
+
'JWT_REFRESH_SECRET',
|
|
11
|
+
'JWT_RESET_SECRET',
|
|
12
|
+
'STRIPE_SECRET_KEY',
|
|
13
|
+
];
|
|
14
|
+
const missing = REQUIRED_ENV_VARS.filter((v) => !process.env[v]);
|
|
15
|
+
if (missing.length > 0) {
|
|
16
|
+
console.error(`[FATAL] Missing required environment variables: ${missing.join(', ')}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PORT = process.env['PORT'] ? parseInt(process.env['PORT'], 10) : 3000;
|
|
21
|
+
|
|
22
|
+
const server = app.listen(PORT, () => {
|
|
23
|
+
console.log(`API running at http://localhost:${PORT}`);
|
|
24
|
+
console.log(`Environment: ${process.env['NODE_ENV'] ?? 'development'}`);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// ── Graceful shutdown ─────────────────────────────────────────────────────────
|
|
28
|
+
async function shutdown(signal: string): Promise<void> {
|
|
29
|
+
console.log(`[${signal}] Shutting down gracefully…`);
|
|
30
|
+
server.close(async () => {
|
|
31
|
+
try {
|
|
32
|
+
await prisma.$disconnect();
|
|
33
|
+
} catch {
|
|
34
|
+
// ignore disconnect errors during shutdown
|
|
35
|
+
}
|
|
36
|
+
console.log('Server closed.');
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
// Force exit if graceful shutdown takes too long
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
console.error('Forced shutdown after timeout.');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}, 30_000).unref();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
process.on('SIGTERM', () => void shutdown('SIGTERM'));
|
|
47
|
+
process.on('SIGINT', () => void shutdown('SIGINT'));
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 12 — UUID param validation
|
|
3
|
+
*
|
|
4
|
+
* Ensures endpoints that receive :id return 400 immediately for
|
|
5
|
+
* non-UUID values without hitting the database.
|
|
6
|
+
*/
|
|
7
|
+
import request from 'supertest';
|
|
8
|
+
import app from '../../app';
|
|
9
|
+
|
|
10
|
+
let adminToken: string;
|
|
11
|
+
let customerToken: string;
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
const { userRepository } = await import('../../modules/auth/auth.registry');
|
|
15
|
+
const { UserEntity } = await import('../../modules/auth/user.entity');
|
|
16
|
+
const { hash } = await import('bcryptjs');
|
|
17
|
+
|
|
18
|
+
const adminEntity = UserEntity.create({
|
|
19
|
+
name: 'UUID Admin',
|
|
20
|
+
email: 'uuid.admin@test.com',
|
|
21
|
+
passwordHash: await hash('pass1234', 10),
|
|
22
|
+
role: 'ADMIN',
|
|
23
|
+
});
|
|
24
|
+
await userRepository.create(adminEntity);
|
|
25
|
+
|
|
26
|
+
const [aRes, cRes] = await Promise.all([
|
|
27
|
+
request(app)
|
|
28
|
+
.post('/api/auth/login')
|
|
29
|
+
.send({ email: 'uuid.admin@test.com', password: 'pass1234' }),
|
|
30
|
+
request(app)
|
|
31
|
+
.post('/api/auth/register')
|
|
32
|
+
.send({ name: 'UUID Customer', email: 'uuid.customer@test.com', password: 'pass1234' }),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
adminToken = (aRes.body as { accessToken: string }).accessToken;
|
|
36
|
+
customerToken = (cRes.body as { accessToken: string }).accessToken;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const INVALID_IDS = ['not-a-uuid', '123', 'abc-def', 'totally-wrong-format'];
|
|
40
|
+
const VALID_UUID = '00000000-0000-4000-8000-000000000001';
|
|
41
|
+
|
|
42
|
+
describe('UUID param validation — GET /api/orders/:id', () => {
|
|
43
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
44
|
+
const res = await request(app)
|
|
45
|
+
.get(`/api/orders/${id}`)
|
|
46
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
47
|
+
expect(res.status).toBe(400);
|
|
48
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('404 normal para UUID válido mas inexistente', async () => {
|
|
52
|
+
const res = await request(app)
|
|
53
|
+
.get(`/api/orders/${VALID_UUID}`)
|
|
54
|
+
.set('Authorization', `Bearer ${customerToken}`);
|
|
55
|
+
expect(res.status).toBe(404);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('UUID param validation — PATCH /api/admin/orders/:id/status', () => {
|
|
60
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
61
|
+
const res = await request(app)
|
|
62
|
+
.patch(`/api/admin/orders/${id}/status`)
|
|
63
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
64
|
+
.send({ status: 'SHIPPED' });
|
|
65
|
+
expect(res.status).toBe(400);
|
|
66
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('UUID param validation — PATCH /api/admin/users/:id', () => {
|
|
71
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
72
|
+
const res = await request(app)
|
|
73
|
+
.patch(`/api/admin/users/${id}`)
|
|
74
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
75
|
+
.send({ role: 'ADMIN' });
|
|
76
|
+
expect(res.status).toBe(400);
|
|
77
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('UUID param validation — PUT /api/products/:id', () => {
|
|
82
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
83
|
+
const res = await request(app)
|
|
84
|
+
.put(`/api/products/${id}`)
|
|
85
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
86
|
+
.send({ name: 'Updated' });
|
|
87
|
+
expect(res.status).toBe(400);
|
|
88
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('UUID param validation — DELETE /api/products/:id', () => {
|
|
93
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
94
|
+
const res = await request(app)
|
|
95
|
+
.delete(`/api/products/${id}`)
|
|
96
|
+
.set('Authorization', `Bearer ${adminToken}`);
|
|
97
|
+
expect(res.status).toBe(400);
|
|
98
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('UUID param validation — PATCH /api/products/:id/stock', () => {
|
|
103
|
+
it.each(INVALID_IDS)('400 para id "%s"', async (id) => {
|
|
104
|
+
const res = await request(app)
|
|
105
|
+
.patch(`/api/products/${id}/stock`)
|
|
106
|
+
.set('Authorization', `Bearer ${adminToken}`)
|
|
107
|
+
.send({ variantId: 'v1', delta: 5 });
|
|
108
|
+
expect(res.status).toBe(400);
|
|
109
|
+
expect((res.body as { error: string }).error).toMatch(/uuid|id inválido/i);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AppError } from '../../domain/shared/AppError';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/email/ethereal.email.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../application/ports/email.port';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/email/noop.email.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/email/smtp.email.service';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration test for EtherealEmailService.
|
|
3
|
+
* Hits the real Ethereal SMTP endpoint (no real delivery — Ethereal captures it).
|
|
4
|
+
* Run with: npm test (jest picks up all *.test.ts)
|
|
5
|
+
*/
|
|
6
|
+
import { EtherealEmailService } from '../EtherealEmailService';
|
|
7
|
+
|
|
8
|
+
describe('EtherealEmailService', () => {
|
|
9
|
+
let service: EtherealEmailService;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
service = new EtherealEmailService();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('deve enviar email sem lançar erro', async () => {
|
|
16
|
+
await expect(
|
|
17
|
+
service.send('dest@example.com', 'Teste', '<p>Hello</p>'),
|
|
18
|
+
).resolves.not.toThrow();
|
|
19
|
+
}, 15_000); // network timeout — ethereal can be slow
|
|
20
|
+
|
|
21
|
+
it('deve registrar preview URL após envio', async () => {
|
|
22
|
+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
23
|
+
|
|
24
|
+
await service.send('dest@example.com', 'Preview URL test', '<p>Test</p>');
|
|
25
|
+
|
|
26
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
27
|
+
expect.stringContaining('Ethereal'),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
consoleSpy.mockRestore();
|
|
31
|
+
}, 15_000);
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/email/email.registry';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../infrastructure/persistence/prisma-client';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../infrastructure/cache/redis';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../application/ports/storage.port';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/storage/in-memory.storage.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/storage/local-disk.storage.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/storage/s3.storage.service';
|
package/templates/ecommerce/apps/api/src/shared/infra/storage/__tests__/s3.storage.unit.test.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for S3StorageService.
|
|
3
|
+
* Mocks the AWS SDK so no real S3/MinIO is needed.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const mockSend = jest.fn();
|
|
7
|
+
|
|
8
|
+
jest.mock('@aws-sdk/client-s3', () => ({
|
|
9
|
+
S3Client: jest.fn().mockImplementation(() => ({ send: mockSend })),
|
|
10
|
+
PutObjectCommand: jest.fn().mockImplementation((params) => params),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
import { S3StorageService } from '../S3StorageService';
|
|
14
|
+
|
|
15
|
+
describe('S3StorageService', () => {
|
|
16
|
+
const OLD_ENV = process.env;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
process.env = {
|
|
20
|
+
...OLD_ENV,
|
|
21
|
+
S3_BUCKET: 'test-bucket',
|
|
22
|
+
S3_REGION: 'us-east-1',
|
|
23
|
+
S3_ENDPOINT: 'http://localhost:9000',
|
|
24
|
+
AWS_ACCESS_KEY_ID: 'minioadmin',
|
|
25
|
+
AWS_SECRET_ACCESS_KEY: 'minioadmin',
|
|
26
|
+
};
|
|
27
|
+
mockSend.mockClear();
|
|
28
|
+
mockSend.mockResolvedValue({});
|
|
29
|
+
jest.resetModules();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
process.env = OLD_ENV;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('deve chamar PutObjectCommand com bucket, key e body corretos', async () => {
|
|
37
|
+
const { S3StorageService: FreshService } = await import('../S3StorageService');
|
|
38
|
+
const service = new FreshService();
|
|
39
|
+
const buf = Buffer.from('image-data');
|
|
40
|
+
|
|
41
|
+
await service.upload('products/abc/photo.jpg', buf, 'image/jpeg');
|
|
42
|
+
|
|
43
|
+
const { PutObjectCommand } = await import('@aws-sdk/client-s3');
|
|
44
|
+
expect(PutObjectCommand).toHaveBeenCalledWith(
|
|
45
|
+
expect.objectContaining({
|
|
46
|
+
Bucket: 'test-bucket',
|
|
47
|
+
Key: 'products/abc/photo.jpg',
|
|
48
|
+
Body: buf,
|
|
49
|
+
ContentType: 'image/jpeg',
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('deve retornar URL pública no formato correto', async () => {
|
|
55
|
+
const { S3StorageService: FreshService } = await import('../S3StorageService');
|
|
56
|
+
const service = new FreshService();
|
|
57
|
+
|
|
58
|
+
const url = await service.upload('products/id/image.png', Buffer.from('x'), 'image/png');
|
|
59
|
+
|
|
60
|
+
expect(url).toContain('test-bucket');
|
|
61
|
+
expect(url).toContain('products/id/image.png');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('deve propagar erro do S3 como AppError', async () => {
|
|
65
|
+
mockSend.mockRejectedValue(new Error('Network error'));
|
|
66
|
+
const { S3StorageService: FreshService } = await import('../S3StorageService');
|
|
67
|
+
const service = new FreshService();
|
|
68
|
+
|
|
69
|
+
await expect(
|
|
70
|
+
service.upload('products/id/fail.jpg', Buffer.from('x'), 'image/jpeg'),
|
|
71
|
+
).rejects.toMatchObject({ statusCode: 500 });
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../infrastructure/services/storage/storage.registry';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../presentation/middlewares/authenticate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../presentation/middlewares/authorize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../presentation/middlewares/errorHandler';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../presentation/validators/uuidParam';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@/*": ["src/*"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "dist", "**/__tests__/**"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# ─── API ──────────────────────────────────────────────────────────────────────
|
|
2
|
+
# URL base da API (backend Express). Em dev aponta para localhost.
|
|
3
|
+
VITE_API_URL="http://localhost:3000"
|
|
4
|
+
|
|
5
|
+
# ─── Stripe ───────────────────────────────────────────────────────────────────
|
|
6
|
+
# Chave PÚBLICA do Stripe (pode ser exposta no frontend com segurança).
|
|
7
|
+
# Chaves de teste: https://dashboard.stripe.com/test/apikeys
|
|
8
|
+
VITE_STRIPE_PUBLIC_KEY="pk_test_..."
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="pt-BR">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Minha Loja</title>
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
/>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="root"></div>
|
|
17
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
const config: Config = {
|
|
4
|
+
preset: 'ts-jest',
|
|
5
|
+
testEnvironment: 'jsdom',
|
|
6
|
+
rootDir: '.',
|
|
7
|
+
testMatch: ['<rootDir>/src/**/__tests__/**/*.test.{ts,tsx}'],
|
|
8
|
+
moduleNameMapper: {
|
|
9
|
+
'^@/(.*)$': '<rootDir>/src/$1',
|
|
10
|
+
'\\.(css|less|scss|sass)$': '<rootDir>/src/__mocks__/styleMock.ts',
|
|
11
|
+
'\\.(jpg|jpeg|png|gif|webp|svg)$': '<rootDir>/src/__mocks__/fileMock.ts',
|
|
12
|
+
},
|
|
13
|
+
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
|
|
14
|
+
transform: {
|
|
15
|
+
'^.+\\.tsx?$': [
|
|
16
|
+
'ts-jest',
|
|
17
|
+
{
|
|
18
|
+
tsconfig: '<rootDir>/tsconfig.jest.json',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
coverageDirectory: 'coverage',
|
|
23
|
+
collectCoverageFrom: [
|
|
24
|
+
'src/**/*.{ts,tsx}',
|
|
25
|
+
'!src/**/*.d.ts',
|
|
26
|
+
'!src/main.tsx',
|
|
27
|
+
'!src/__mocks__/**',
|
|
28
|
+
'!src/vite-env.d.ts',
|
|
29
|
+
],
|
|
30
|
+
coverageThreshold: {
|
|
31
|
+
global: {
|
|
32
|
+
branches: 80,
|
|
33
|
+
functions: 80,
|
|
34
|
+
lines: 80,
|
|
35
|
+
statements: 80,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
clearMocks: true,
|
|
39
|
+
restoreMocks: true,
|
|
40
|
+
transformIgnorePatterns: [
|
|
41
|
+
'/node_modules/(?!(react-router|react-router-dom)/)',
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default config;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ecommerce/web",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc && vite build",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"test:coverage": "jest --coverage",
|
|
11
|
+
"lint": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"react": "^18.3.1",
|
|
15
|
+
"react-dom": "^18.3.1",
|
|
16
|
+
"react-router-dom": "^7.2.0",
|
|
17
|
+
"zustand": "^5.0.3",
|
|
18
|
+
"@tanstack/react-query": "^5.67.2",
|
|
19
|
+
"@stripe/react-stripe-js": "^3.1.0",
|
|
20
|
+
"@stripe/stripe-js": "^5.6.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.7.3",
|
|
24
|
+
"@types/react": "^18.3.18",
|
|
25
|
+
"@types/react-dom": "^18.3.5",
|
|
26
|
+
"@types/jest": "^29.5.14",
|
|
27
|
+
"vite": "^6.2.0",
|
|
28
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
29
|
+
"jest": "^29.7.0",
|
|
30
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
31
|
+
"@testing-library/react": "^16.2.0",
|
|
32
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
33
|
+
"@testing-library/user-event": "^14.5.2",
|
|
34
|
+
"msw": "^2.7.0",
|
|
35
|
+
"ts-jest": "^29.2.6",
|
|
36
|
+
"ts-node": "^10.9.2"
|
|
37
|
+
}
|
|
38
|
+
}
|