create-nextdevtpl 2.6.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 +29 -0
- package/catalog.json +385 -0
- package/dist/catalog.d.ts +3 -0
- package/dist/catalog.js +112 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +115 -0
- package/dist/cli.js.map +1 -0
- package/dist/filesystem.d.ts +10 -0
- package/dist/filesystem.js +86 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/generate.d.ts +5 -0
- package/dist/generate.js +758 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/selection.d.ts +2 -0
- package/dist/selection.js +111 -0
- package/dist/selection.js.map +1 -0
- package/dist/service-templates.d.ts +4 -0
- package/dist/service-templates.js +180 -0
- package/dist/service-templates.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
- package/template/.dockerignore +14 -0
- package/template/.env.example +282 -0
- package/template/.gitattributes +17 -0
- package/template/.node-version +1 -0
- package/template/Dockerfile +45 -0
- package/template/LICENSE +21 -0
- package/template/README.md +267 -0
- package/template/biome.json +68 -0
- package/template/cloudflare/templates/logger.ts +162 -0
- package/template/cloudflare/templates/mail/server.ts +6 -0
- package/template/cloudflare/templates/mail/templates.ts +87 -0
- package/template/cloudflare/templates/mail/utils.ts +69 -0
- package/template/cloudflare/worker.mjs +25 -0
- package/template/components.json +22 -0
- package/template/compose.yaml +74 -0
- package/template/deploy/check-health.mjs +25 -0
- package/template/deploy/docker/README.md +14 -0
- package/template/deploy/server/README.md +24 -0
- package/template/deploy/server/build.sh +24 -0
- package/template/deploy/server/nextdevtpl.service +19 -0
- package/template/deploy/server/start.sh +19 -0
- package/template/deploy/vercel/README.md +16 -0
- package/template/deploy/verify-production-health.mjs +86 -0
- package/template/drizzle.config.ts +47 -0
- package/template/gitignore +62 -0
- package/template/manifest.json +35 -0
- package/template/messages/en.json +766 -0
- package/template/messages/zh.json +762 -0
- package/template/next.config.mjs +28 -0
- package/template/open-next.config.ts +3 -0
- package/template/package.json +125 -0
- package/template/pnpm-lock.yaml +15901 -0
- package/template/postcss.config.mjs +7 -0
- package/template/public/file.svg +1 -0
- package/template/public/globe.svg +1 -0
- package/template/public/logo.svg +6 -0
- package/template/public/next.svg +1 -0
- package/template/public/vercel.svg +1 -0
- package/template/public/window.svg +1 -0
- package/template/sentry.client.config.ts +10 -0
- package/template/sentry.edge.config.ts +10 -0
- package/template/sentry.server.config.ts +10 -0
- package/template/source.config.ts +59 -0
- package/template/src/adapters/ai/anthropic.ts +113 -0
- package/template/src/adapters/ai/index.ts +6 -0
- package/template/src/adapters/ai/openai-compatible.ts +88 -0
- package/template/src/adapters/ai/workers-ai.ts +63 -0
- package/template/src/adapters/index.ts +10 -0
- package/template/src/adapters/jobs/cloudflare-workflows.ts +46 -0
- package/template/src/adapters/jobs/index.ts +5 -0
- package/template/src/adapters/jobs/inngest/adapter.ts +29 -0
- package/template/src/adapters/jobs/inngest/client.ts +8 -0
- package/template/src/adapters/jobs/inngest/functions.ts +17 -0
- package/template/src/adapters/jobs/inngest/handler.ts +6 -0
- package/template/src/adapters/jobs/inngest/index.ts +4 -0
- package/template/src/adapters/mail/cloudflare-email.ts +50 -0
- package/template/src/adapters/mail/disabled.ts +17 -0
- package/template/src/adapters/mail/index.ts +7 -0
- package/template/src/adapters/mail/resend.ts +76 -0
- package/template/src/adapters/mail/smtp.ts +82 -0
- package/template/src/adapters/payment/creem.ts +269 -0
- package/template/src/adapters/payment/index.ts +2 -0
- package/template/src/adapters/payment/stripe.ts +302 -0
- package/template/src/adapters/rate-limit/cloudflare.ts +42 -0
- package/template/src/adapters/rate-limit/index.ts +6 -0
- package/template/src/adapters/rate-limit/noop.ts +27 -0
- package/template/src/adapters/rate-limit/upstash.ts +113 -0
- package/template/src/adapters/registry.ts +228 -0
- package/template/src/adapters/storage/index.ts +3 -0
- package/template/src/adapters/storage/r2-binding.ts +105 -0
- package/template/src/adapters/storage/s3-compatible.ts +149 -0
- package/template/src/app/[locale]/(admin)/admin/layout.tsx +36 -0
- package/template/src/app/[locale]/(admin)/admin/page.tsx +345 -0
- package/template/src/app/[locale]/(admin)/admin/tickets/[id]/page.tsx +261 -0
- package/template/src/app/[locale]/(admin)/admin/tickets/page.tsx +236 -0
- package/template/src/app/[locale]/(admin)/admin/users/page.tsx +557 -0
- package/template/src/app/[locale]/(auth)/forgot-password/page.tsx +9 -0
- package/template/src/app/[locale]/(auth)/layout.tsx +28 -0
- package/template/src/app/[locale]/(auth)/sign-in/page.tsx +9 -0
- package/template/src/app/[locale]/(auth)/sign-up/page.tsx +9 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/buy/buy-credits-view.tsx +170 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/buy/page.tsx +12 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/page.tsx +5 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/loading.tsx +41 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/page.tsx +299 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/settings/page.tsx +38 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/[id]/page.tsx +220 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/new/page.tsx +183 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/page.tsx +145 -0
- package/template/src/app/[locale]/(dashboard)/layout.tsx +35 -0
- package/template/src/app/[locale]/(marketing)/blog/[slug]/page.tsx +178 -0
- package/template/src/app/[locale]/(marketing)/blog/blog-post-card.tsx +95 -0
- package/template/src/app/[locale]/(marketing)/blog/page.tsx +127 -0
- package/template/src/app/[locale]/(marketing)/demo/plan-badges/page.tsx +36 -0
- package/template/src/app/[locale]/(marketing)/layout.tsx +15 -0
- package/template/src/app/[locale]/(marketing)/legal/[slug]/page.tsx +130 -0
- package/template/src/app/[locale]/(marketing)/page.tsx +94 -0
- package/template/src/app/[locale]/(marketing)/pseo/[slug]/page.tsx +68 -0
- package/template/src/app/[locale]/(marketing)/pseo/page.tsx +137 -0
- package/template/src/app/[locale]/docs/[[...slug]]/page.tsx +63 -0
- package/template/src/app/[locale]/docs/layout.tsx +39 -0
- package/template/src/app/[locale]/layout.tsx +80 -0
- package/template/src/app/[locale]/opengraph-image.tsx +20 -0
- package/template/src/app/[locale]/twitter-image.tsx +20 -0
- package/template/src/app/api/auth/[...all]/route.ts +20 -0
- package/template/src/app/api/health/route.ts +45 -0
- package/template/src/app/api/inngest/route.ts +12 -0
- package/template/src/app/api/jobs/credits/expire/route.ts +102 -0
- package/template/src/app/api/search/route.ts +17 -0
- package/template/src/app/api/upload/presigned/route.ts +98 -0
- package/template/src/app/api/webhooks/payment/route.ts +363 -0
- package/template/src/app/globals.css +406 -0
- package/template/src/app/icon.svg +6 -0
- package/template/src/app/image-proxy/[...path]/route.ts +137 -0
- package/template/src/app/layout.tsx +73 -0
- package/template/src/app/robots.ts +29 -0
- package/template/src/app/sitemap.ts +68 -0
- package/template/src/components/motion/reveal.tsx +49 -0
- package/template/src/components/seo/json-ld.tsx +87 -0
- package/template/src/components/seo/og-image-template.tsx +118 -0
- package/template/src/components/ui/accordion.tsx +66 -0
- package/template/src/components/ui/alert-dialog.tsx +195 -0
- package/template/src/components/ui/avatar.tsx +53 -0
- package/template/src/components/ui/badge.tsx +46 -0
- package/template/src/components/ui/button.tsx +65 -0
- package/template/src/components/ui/card.tsx +92 -0
- package/template/src/components/ui/checkbox.tsx +32 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/dialog.tsx +124 -0
- package/template/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/src/components/ui/form.tsx +233 -0
- package/template/src/components/ui/index.ts +2 -0
- package/template/src/components/ui/input.tsx +21 -0
- package/template/src/components/ui/label.tsx +24 -0
- package/template/src/components/ui/navigation-menu.tsx +167 -0
- package/template/src/components/ui/pagination.tsx +125 -0
- package/template/src/components/ui/popover.tsx +48 -0
- package/template/src/components/ui/progress.tsx +27 -0
- package/template/src/components/ui/radio-group.tsx +45 -0
- package/template/src/components/ui/select.tsx +190 -0
- package/template/src/components/ui/separator.tsx +28 -0
- package/template/src/components/ui/sheet.tsx +140 -0
- package/template/src/components/ui/switch.tsx +31 -0
- package/template/src/components/ui/tabs.tsx +75 -0
- package/template/src/components/ui/textarea.tsx +18 -0
- package/template/src/config/index.ts +31 -0
- package/template/src/config/nav.ts +238 -0
- package/template/src/config/payment.ts +282 -0
- package/template/src/config/site.ts +53 -0
- package/template/src/config/subscription-plan.ts +164 -0
- package/template/src/content/blog/en/hello-world.mdx +48 -0
- package/template/src/content/blog/zh/hello-world.mdx +48 -0
- package/template/src/content/blog/zh/nextdevtpl-linuxdo-intro.mdx +98 -0
- package/template/src/content/docs/en/admin-and-support.mdx +65 -0
- package/template/src/content/docs/en/authentication.mdx +71 -0
- package/template/src/content/docs/en/background-jobs.mdx +53 -0
- package/template/src/content/docs/en/configuration.mdx +71 -0
- package/template/src/content/docs/en/credits.mdx +69 -0
- package/template/src/content/docs/en/customization.mdx +95 -0
- package/template/src/content/docs/en/database.mdx +66 -0
- package/template/src/content/docs/en/deployment.mdx +62 -0
- package/template/src/content/docs/en/email.mdx +48 -0
- package/template/src/content/docs/en/index.mdx +48 -0
- package/template/src/content/docs/en/internationalization.mdx +78 -0
- package/template/src/content/docs/en/meta.json +22 -0
- package/template/src/content/docs/en/observability.mdx +69 -0
- package/template/src/content/docs/en/payments.mdx +64 -0
- package/template/src/content/docs/en/project-structure.mdx +82 -0
- package/template/src/content/docs/en/quick-start.mdx +113 -0
- package/template/src/content/docs/en/storage.mdx +51 -0
- package/template/src/content/docs/zh/admin-and-support.mdx +65 -0
- package/template/src/content/docs/zh/authentication.mdx +71 -0
- package/template/src/content/docs/zh/background-jobs.mdx +53 -0
- package/template/src/content/docs/zh/configuration.mdx +70 -0
- package/template/src/content/docs/zh/credits.mdx +69 -0
- package/template/src/content/docs/zh/customization.mdx +95 -0
- package/template/src/content/docs/zh/database.mdx +66 -0
- package/template/src/content/docs/zh/deployment.mdx +61 -0
- package/template/src/content/docs/zh/email.mdx +47 -0
- package/template/src/content/docs/zh/index.mdx +48 -0
- package/template/src/content/docs/zh/internationalization.mdx +78 -0
- package/template/src/content/docs/zh/meta.json +22 -0
- package/template/src/content/docs/zh/observability.mdx +68 -0
- package/template/src/content/docs/zh/payments.mdx +64 -0
- package/template/src/content/docs/zh/project-structure.mdx +82 -0
- package/template/src/content/docs/zh/quick-start.mdx +110 -0
- package/template/src/content/docs/zh/storage.mdx +51 -0
- package/template/src/content/legal/en/cookie-policy.mdx +78 -0
- package/template/src/content/legal/en/privacy.mdx +131 -0
- package/template/src/content/legal/en/terms.mdx +93 -0
- package/template/src/content/legal/zh/cookie-policy.mdx +78 -0
- package/template/src/content/legal/zh/privacy.mdx +131 -0
- package/template/src/content/legal/zh/terms.mdx +92 -0
- package/template/src/core/modules/contract.ts +225 -0
- package/template/src/core/modules/index.ts +1 -0
- package/template/src/core/services/ai.ts +31 -0
- package/template/src/core/services/common.ts +112 -0
- package/template/src/core/services/index.ts +8 -0
- package/template/src/core/services/jobs.ts +24 -0
- package/template/src/core/services/mail.ts +35 -0
- package/template/src/core/services/manifest.ts +51 -0
- package/template/src/core/services/payment.ts +92 -0
- package/template/src/core/services/rate-limit.ts +47 -0
- package/template/src/core/services/storage.ts +42 -0
- package/template/src/db/index.ts +71 -0
- package/template/src/db/schema/auth.ts +67 -0
- package/template/src/db/schema/credits.ts +94 -0
- package/template/src/db/schema/index.ts +5 -0
- package/template/src/db/schema/mail.ts +14 -0
- package/template/src/db/schema/subscription.ts +21 -0
- package/template/src/db/schema/support.ts +56 -0
- package/template/src/db/schema.ts +2 -0
- package/template/src/features/admin/components/admin-sidebar.tsx +213 -0
- package/template/src/features/admin/components/index.ts +2 -0
- package/template/src/features/admin/index.ts +3 -0
- package/template/src/features/admin/manifest.ts +41 -0
- package/template/src/features/analytics/components/analytics.tsx +62 -0
- package/template/src/features/analytics/components/index.ts +2 -0
- package/template/src/features/analytics/index.ts +3 -0
- package/template/src/features/analytics/manifest.ts +13 -0
- package/template/src/features/auth/components/auth-brand-panel.tsx +82 -0
- package/template/src/features/auth/components/auth-error-alert.tsx +28 -0
- package/template/src/features/auth/components/auth-footer.tsx +52 -0
- package/template/src/features/auth/components/auth-logo.tsx +30 -0
- package/template/src/features/auth/components/forgot-password-form.tsx +146 -0
- package/template/src/features/auth/components/index.ts +9 -0
- package/template/src/features/auth/components/sign-in-form.tsx +241 -0
- package/template/src/features/auth/components/sign-up-form.tsx +307 -0
- package/template/src/features/auth/index.ts +3 -0
- package/template/src/features/auth/manifest.ts +30 -0
- package/template/src/features/blog/components/blog-post-item.tsx +72 -0
- package/template/src/features/blog/components/index.ts +1 -0
- package/template/src/features/blog/data/mock-posts.ts +62 -0
- package/template/src/features/blog/index.ts +3 -0
- package/template/src/features/blog/manifest.ts +22 -0
- package/template/src/features/credits/account.ts +76 -0
- package/template/src/features/credits/actions.ts +427 -0
- package/template/src/features/credits/components/credit-balance-badge.tsx +54 -0
- package/template/src/features/credits/components/credit-usage-section.tsx +160 -0
- package/template/src/features/credits/components/index.ts +7 -0
- package/template/src/features/credits/components/transaction-history.tsx +346 -0
- package/template/src/features/credits/config.ts +70 -0
- package/template/src/features/credits/consume.ts +140 -0
- package/template/src/features/credits/core.ts +23 -0
- package/template/src/features/credits/errors.ts +26 -0
- package/template/src/features/credits/expire.ts +112 -0
- package/template/src/features/credits/grant.ts +168 -0
- package/template/src/features/credits/index.ts +6 -0
- package/template/src/features/credits/manifest.ts +36 -0
- package/template/src/features/credits/query.ts +65 -0
- package/template/src/features/credits/types.ts +48 -0
- package/template/src/features/dashboard/components/index.ts +3 -0
- package/template/src/features/dashboard/components/main-wrapper.tsx +100 -0
- package/template/src/features/dashboard/components/sidebar.tsx +341 -0
- package/template/src/features/dashboard/context/index.ts +2 -0
- package/template/src/features/dashboard/context/sidebar-context.tsx +72 -0
- package/template/src/features/dashboard/index.ts +4 -0
- package/template/src/features/dashboard/manifest.ts +28 -0
- package/template/src/features/mail/actions.ts +175 -0
- package/template/src/features/mail/index.ts +5 -0
- package/template/src/features/mail/manifest.ts +13 -0
- package/template/src/features/mail/server.ts +8 -0
- package/template/src/features/mail/templates/index.ts +11 -0
- package/template/src/features/mail/templates/primary-action-email.tsx +224 -0
- package/template/src/features/mail/templates/welcome-email.tsx +121 -0
- package/template/src/features/mail/utils.ts +190 -0
- package/template/src/features/marketing/components/animated-price.tsx +51 -0
- package/template/src/features/marketing/components/cookie-consent.tsx +255 -0
- package/template/src/features/marketing/components/cta-section.tsx +50 -0
- package/template/src/features/marketing/components/faq-section.tsx +59 -0
- package/template/src/features/marketing/components/feature-grid.tsx +80 -0
- package/template/src/features/marketing/components/footer.tsx +128 -0
- package/template/src/features/marketing/components/header.tsx +255 -0
- package/template/src/features/marketing/components/hero-section.tsx +323 -0
- package/template/src/features/marketing/components/how-it-works.tsx +115 -0
- package/template/src/features/marketing/components/index.ts +14 -0
- package/template/src/features/marketing/components/nav-menu.tsx +236 -0
- package/template/src/features/marketing/components/pricing-section.tsx +446 -0
- package/template/src/features/marketing/components/testimonials.tsx +59 -0
- package/template/src/features/marketing/components/use-cases-section.tsx +78 -0
- package/template/src/features/marketing/index.ts +3 -0
- package/template/src/features/marketing/manifest.ts +35 -0
- package/template/src/features/payment/actions.ts +182 -0
- package/template/src/features/payment/index.ts +4 -0
- package/template/src/features/payment/manifest.ts +18 -0
- package/template/src/features/payment/server.ts +7 -0
- package/template/src/features/payment/types.ts +202 -0
- package/template/src/features/pseo/components/index.ts +6 -0
- package/template/src/features/pseo/components/pseo-cta.tsx +51 -0
- package/template/src/features/pseo/components/pseo-faq.tsx +40 -0
- package/template/src/features/pseo/components/pseo-feature-grid.tsx +74 -0
- package/template/src/features/pseo/components/pseo-hero.tsx +106 -0
- package/template/src/features/pseo/components/pseo-related.tsx +62 -0
- package/template/src/features/pseo/components/pseo-use-cases.tsx +50 -0
- package/template/src/features/pseo/data/pseo-pages.json +534 -0
- package/template/src/features/pseo/index.ts +4 -0
- package/template/src/features/pseo/lib/pseo-data.ts +140 -0
- package/template/src/features/pseo/manifest.ts +22 -0
- package/template/src/features/settings/actions/delete-account.ts +50 -0
- package/template/src/features/settings/actions/index.ts +3 -0
- package/template/src/features/settings/actions/update-profile.ts +49 -0
- package/template/src/features/settings/components/billing-section.tsx +283 -0
- package/template/src/features/settings/components/index.ts +3 -0
- package/template/src/features/settings/components/profile-form.tsx +154 -0
- package/template/src/features/settings/components/security-section.tsx +158 -0
- package/template/src/features/settings/components/settings-profile-view.tsx +506 -0
- package/template/src/features/settings/index.ts +5 -0
- package/template/src/features/settings/manifest.ts +28 -0
- package/template/src/features/settings/schemas/index.ts +2 -0
- package/template/src/features/settings/schemas/update-profile.ts +21 -0
- package/template/src/features/shared/components/cookie-settings-dialog.tsx +282 -0
- package/template/src/features/shared/components/index.ts +5 -0
- package/template/src/features/shared/components/language-switcher.tsx +82 -0
- package/template/src/features/shared/components/max-width-wrapper.tsx +49 -0
- package/template/src/features/shared/components/mode-toggle.tsx +119 -0
- package/template/src/features/shared/icons/google-icon.tsx +39 -0
- package/template/src/features/shared/icons/index.ts +7 -0
- package/template/src/features/shared/index.ts +5 -0
- package/template/src/features/shared/manifest.ts +13 -0
- package/template/src/features/shared/providers.tsx +59 -0
- package/template/src/features/storage/actions.ts +107 -0
- package/template/src/features/storage/index.ts +6 -0
- package/template/src/features/storage/manifest.ts +22 -0
- package/template/src/features/storage/types.ts +143 -0
- package/template/src/features/storage/utils.ts +85 -0
- package/template/src/features/storage/validation.ts +151 -0
- package/template/src/features/subscription/actions/get-user-plan.ts +26 -0
- package/template/src/features/subscription/actions/index.ts +5 -0
- package/template/src/features/subscription/components/current-plan-badge.tsx +18 -0
- package/template/src/features/subscription/components/index.ts +6 -0
- package/template/src/features/subscription/components/plan-badge.tsx +98 -0
- package/template/src/features/subscription/index.ts +25 -0
- package/template/src/features/subscription/manifest.ts +13 -0
- package/template/src/features/subscription/services/user-plan.ts +181 -0
- package/template/src/features/support/actions/admin-ticket.ts +172 -0
- package/template/src/features/support/actions/admin-users.ts +295 -0
- package/template/src/features/support/actions/index.ts +22 -0
- package/template/src/features/support/actions/ticket.ts +12 -0
- package/template/src/features/support/actions/user-ticket.ts +153 -0
- package/template/src/features/support/components/admin-ticket-reply-form.tsx +109 -0
- package/template/src/features/support/components/admin-ticket-status-select.tsx +119 -0
- package/template/src/features/support/components/index.ts +6 -0
- package/template/src/features/support/components/ticket-message-form.tsx +99 -0
- package/template/src/features/support/components/user-role-select.tsx +107 -0
- package/template/src/features/support/index.ts +5 -0
- package/template/src/features/support/manifest.ts +53 -0
- package/template/src/features/support/schemas/index.ts +15 -0
- package/template/src/features/support/schemas/ticket.ts +81 -0
- package/template/src/hooks/index.ts +2 -0
- package/template/src/i18n/index.ts +12 -0
- package/template/src/i18n/request.ts +24 -0
- package/template/src/i18n/routing.ts +23 -0
- package/template/src/instrumentation.ts +19 -0
- package/template/src/lib/ai/index.ts +16 -0
- package/template/src/lib/api-logger.ts +24 -0
- package/template/src/lib/auth/admin.ts +54 -0
- package/template/src/lib/auth/api.ts +17 -0
- package/template/src/lib/auth/client.ts +227 -0
- package/template/src/lib/auth/edge.ts +84 -0
- package/template/src/lib/auth/errors.ts +99 -0
- package/template/src/lib/auth/index.ts +159 -0
- package/template/src/lib/auth/server.ts +46 -0
- package/template/src/lib/auth/session-context.tsx +96 -0
- package/template/src/lib/cloudflare/bindings.ts +31 -0
- package/template/src/lib/cookie-consent.ts +33 -0
- package/template/src/lib/file-utils.ts +45 -0
- package/template/src/lib/fingerprint/index.ts +73 -0
- package/template/src/lib/health/checks.ts +6 -0
- package/template/src/lib/health/core.ts +86 -0
- package/template/src/lib/health/index.ts +11 -0
- package/template/src/lib/health/types.ts +13 -0
- package/template/src/lib/index.ts +2 -0
- package/template/src/lib/logger/index.ts +258 -0
- package/template/src/lib/monitoring/index.ts +384 -0
- package/template/src/lib/rate-limit/anonymous.ts +85 -0
- package/template/src/lib/rate-limit/index.ts +111 -0
- package/template/src/lib/safe-action.ts +127 -0
- package/template/src/lib/seo/json-ld.ts +188 -0
- package/template/src/lib/source.ts +122 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/middleware.ts +162 -0
- package/template/src/modules/index.ts +10 -0
- package/template/src/modules/presets.ts +8 -0
- package/template/src/modules/registry.ts +34 -0
- package/template/src/modules/selection.ts +45 -0
- package/template/src/services/ai.ts +49 -0
- package/template/src/services/index.ts +6 -0
- package/template/src/services/jobs.ts +3 -0
- package/template/src/services/mail.ts +7 -0
- package/template/src/services/payment.ts +3 -0
- package/template/src/services/rate-limit.ts +12 -0
- package/template/src/services/storage.ts +3 -0
- package/template/src/types/fumadocs-source.d.ts +14 -0
- package/template/src/types/index.ts +2 -0
- package/template/tsconfig.json +53 -0
- package/template/vercel.json +11 -0
- package/template/vitest.config.ts +51 -0
- package/template/wrangler.jsonc +30 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineServiceAdapter,
|
|
3
|
+
type ServiceAdapterManifest,
|
|
4
|
+
type ServiceKind,
|
|
5
|
+
validateServiceAdapterManifests,
|
|
6
|
+
} from "@/core/services";
|
|
7
|
+
|
|
8
|
+
const manifests = [
|
|
9
|
+
defineServiceAdapter({
|
|
10
|
+
id: "payment:creem",
|
|
11
|
+
service: "payment",
|
|
12
|
+
source: "src/adapters/payment/creem.ts",
|
|
13
|
+
runtime: "node",
|
|
14
|
+
packages: [],
|
|
15
|
+
env: ["CREEM_API_KEY", "CREEM_WEBHOOK_SECRET"],
|
|
16
|
+
bindings: [],
|
|
17
|
+
}),
|
|
18
|
+
defineServiceAdapter({
|
|
19
|
+
id: "payment:stripe",
|
|
20
|
+
service: "payment",
|
|
21
|
+
source: "src/adapters/payment/stripe.ts",
|
|
22
|
+
runtime: "universal",
|
|
23
|
+
packages: [],
|
|
24
|
+
env: ["STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET"],
|
|
25
|
+
bindings: [],
|
|
26
|
+
}),
|
|
27
|
+
defineServiceAdapter({
|
|
28
|
+
id: "storage:s3-compatible",
|
|
29
|
+
service: "storage",
|
|
30
|
+
source: "src/adapters/storage/s3-compatible.ts",
|
|
31
|
+
runtime: "node",
|
|
32
|
+
packages: ["@aws-sdk/client-s3", "@aws-sdk/s3-request-presigner"],
|
|
33
|
+
env: [
|
|
34
|
+
"STORAGE_ACCESS_KEY_ID",
|
|
35
|
+
"STORAGE_SECRET_ACCESS_KEY",
|
|
36
|
+
"STORAGE_ENDPOINT",
|
|
37
|
+
"STORAGE_REGION",
|
|
38
|
+
],
|
|
39
|
+
bindings: [],
|
|
40
|
+
}),
|
|
41
|
+
defineServiceAdapter({
|
|
42
|
+
id: "storage:r2-binding",
|
|
43
|
+
service: "storage",
|
|
44
|
+
source: "src/adapters/storage/r2-binding.ts",
|
|
45
|
+
runtime: "worker",
|
|
46
|
+
packages: [],
|
|
47
|
+
env: [],
|
|
48
|
+
bindings: ["R2Bucket"],
|
|
49
|
+
}),
|
|
50
|
+
defineServiceAdapter({
|
|
51
|
+
id: "mail:disabled",
|
|
52
|
+
service: "mail",
|
|
53
|
+
source: "src/adapters/mail/disabled.ts",
|
|
54
|
+
runtime: "universal",
|
|
55
|
+
packages: [],
|
|
56
|
+
env: [],
|
|
57
|
+
bindings: [],
|
|
58
|
+
}),
|
|
59
|
+
defineServiceAdapter({
|
|
60
|
+
id: "mail:resend",
|
|
61
|
+
service: "mail",
|
|
62
|
+
source: "src/adapters/mail/resend.ts",
|
|
63
|
+
runtime: "universal",
|
|
64
|
+
packages: ["resend"],
|
|
65
|
+
env: ["RESEND_API_KEY", "EMAIL_FROM"],
|
|
66
|
+
bindings: [],
|
|
67
|
+
}),
|
|
68
|
+
defineServiceAdapter({
|
|
69
|
+
id: "mail:smtp",
|
|
70
|
+
service: "mail",
|
|
71
|
+
source: "src/adapters/mail/smtp.ts",
|
|
72
|
+
runtime: "node",
|
|
73
|
+
packages: ["nodemailer"],
|
|
74
|
+
env: ["SMTP_HOST", "SMTP_PORT", "SMTP_SECURE", "SMTP_USER", "SMTP_PASS"],
|
|
75
|
+
bindings: [],
|
|
76
|
+
}),
|
|
77
|
+
defineServiceAdapter({
|
|
78
|
+
id: "mail:cloudflare-email",
|
|
79
|
+
service: "mail",
|
|
80
|
+
source: "src/adapters/mail/cloudflare-email.ts",
|
|
81
|
+
runtime: "worker",
|
|
82
|
+
packages: [],
|
|
83
|
+
env: ["EMAIL_FROM"],
|
|
84
|
+
bindings: ["SendEmail"],
|
|
85
|
+
}),
|
|
86
|
+
defineServiceAdapter({
|
|
87
|
+
id: "ai:openai-compatible",
|
|
88
|
+
service: "ai",
|
|
89
|
+
source: "src/adapters/ai/openai-compatible.ts",
|
|
90
|
+
runtime: "universal",
|
|
91
|
+
packages: ["openai"],
|
|
92
|
+
env: [
|
|
93
|
+
"AI_PROVIDER",
|
|
94
|
+
"OPENAI_API_KEY",
|
|
95
|
+
"OPENAI_MODEL",
|
|
96
|
+
"DEEPSEEK_API_KEY",
|
|
97
|
+
"DEEPSEEK_MODEL",
|
|
98
|
+
"MIMO_API_KEY",
|
|
99
|
+
"MIMO_MODEL",
|
|
100
|
+
"CF_AIG_BASE_URL",
|
|
101
|
+
"CF_AIG_TOKEN",
|
|
102
|
+
],
|
|
103
|
+
bindings: [],
|
|
104
|
+
}),
|
|
105
|
+
defineServiceAdapter({
|
|
106
|
+
id: "ai:anthropic",
|
|
107
|
+
service: "ai",
|
|
108
|
+
source: "src/adapters/ai/anthropic.ts",
|
|
109
|
+
runtime: "universal",
|
|
110
|
+
packages: [],
|
|
111
|
+
env: ["ANTHROPIC_API_KEY", "ANTHROPIC_MODEL"],
|
|
112
|
+
bindings: [],
|
|
113
|
+
}),
|
|
114
|
+
defineServiceAdapter({
|
|
115
|
+
id: "ai:workers-ai",
|
|
116
|
+
service: "ai",
|
|
117
|
+
source: "src/adapters/ai/workers-ai.ts",
|
|
118
|
+
runtime: "worker",
|
|
119
|
+
packages: [],
|
|
120
|
+
env: ["WORKERS_AI_MODEL"],
|
|
121
|
+
bindings: ["Ai"],
|
|
122
|
+
}),
|
|
123
|
+
defineServiceAdapter({
|
|
124
|
+
id: "jobs:inngest",
|
|
125
|
+
service: "jobs",
|
|
126
|
+
source: "src/adapters/jobs/inngest",
|
|
127
|
+
runtime: "universal",
|
|
128
|
+
packages: ["inngest"],
|
|
129
|
+
env: ["INNGEST_EVENT_KEY", "INNGEST_SIGNING_KEY"],
|
|
130
|
+
bindings: [],
|
|
131
|
+
}),
|
|
132
|
+
defineServiceAdapter({
|
|
133
|
+
id: "jobs:cloudflare-workflows",
|
|
134
|
+
service: "jobs",
|
|
135
|
+
source: "src/adapters/jobs/cloudflare-workflows.ts",
|
|
136
|
+
runtime: "worker",
|
|
137
|
+
packages: [],
|
|
138
|
+
env: [],
|
|
139
|
+
bindings: ["Workflow"],
|
|
140
|
+
}),
|
|
141
|
+
defineServiceAdapter({
|
|
142
|
+
id: "rate-limit:noop",
|
|
143
|
+
service: "rate-limit",
|
|
144
|
+
source: "src/adapters/rate-limit/noop.ts",
|
|
145
|
+
runtime: "universal",
|
|
146
|
+
packages: [],
|
|
147
|
+
env: [],
|
|
148
|
+
bindings: [],
|
|
149
|
+
}),
|
|
150
|
+
defineServiceAdapter({
|
|
151
|
+
id: "rate-limit:upstash",
|
|
152
|
+
service: "rate-limit",
|
|
153
|
+
source: "src/adapters/rate-limit/upstash.ts",
|
|
154
|
+
runtime: "universal",
|
|
155
|
+
packages: ["@upstash/ratelimit", "@upstash/redis"],
|
|
156
|
+
env: ["UPSTASH_REDIS_REST_URL", "UPSTASH_REDIS_REST_TOKEN"],
|
|
157
|
+
bindings: [],
|
|
158
|
+
}),
|
|
159
|
+
defineServiceAdapter({
|
|
160
|
+
id: "rate-limit:cloudflare-rate-limit",
|
|
161
|
+
service: "rate-limit",
|
|
162
|
+
source: "src/adapters/rate-limit/cloudflare.ts",
|
|
163
|
+
runtime: "worker",
|
|
164
|
+
packages: [],
|
|
165
|
+
env: [],
|
|
166
|
+
bindings: ["RateLimit"],
|
|
167
|
+
}),
|
|
168
|
+
] as const satisfies readonly ServiceAdapterManifest[];
|
|
169
|
+
|
|
170
|
+
const errors = validateServiceAdapterManifests(manifests);
|
|
171
|
+
if (errors.length > 0) {
|
|
172
|
+
throw new Error(`服务适配器注册失败:\n${errors.join("\n")}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const serviceAdapterRegistry = manifests;
|
|
176
|
+
export type ServiceAdapterId = (typeof manifests)[number]["id"];
|
|
177
|
+
type RegisteredServiceAdapter = (typeof manifests)[number];
|
|
178
|
+
type ServiceAdapterIdFor<Kind extends ServiceKind> = Extract<
|
|
179
|
+
RegisteredServiceAdapter,
|
|
180
|
+
{ service: Kind }
|
|
181
|
+
>["id"];
|
|
182
|
+
|
|
183
|
+
export const defaultServiceAdapters = {
|
|
184
|
+
payment: "payment:creem",
|
|
185
|
+
storage: "storage:s3-compatible",
|
|
186
|
+
mail: "mail:resend",
|
|
187
|
+
ai: "ai:openai-compatible",
|
|
188
|
+
jobs: "jobs:inngest",
|
|
189
|
+
"rate-limit": "rate-limit:upstash",
|
|
190
|
+
} as const satisfies Record<ServiceKind, ServiceAdapterId>;
|
|
191
|
+
|
|
192
|
+
export type ServiceAdapterChoices = {
|
|
193
|
+
readonly [Kind in ServiceKind]: ServiceAdapterIdFor<Kind>;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export interface ServiceAdapterSelection {
|
|
197
|
+
bindings: readonly string[];
|
|
198
|
+
env: readonly string[];
|
|
199
|
+
manifests: readonly ServiceAdapterManifest[];
|
|
200
|
+
packages: readonly string[];
|
|
201
|
+
sources: readonly string[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function createServiceAdapterSelection(
|
|
205
|
+
choices: ServiceAdapterChoices
|
|
206
|
+
): ServiceAdapterSelection {
|
|
207
|
+
const selectedIds = new Set<ServiceAdapterId>(Object.values(choices));
|
|
208
|
+
const selected = serviceAdapterRegistry.filter((manifest) =>
|
|
209
|
+
selectedIds.has(manifest.id)
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
if (selected.length !== Object.keys(choices).length) {
|
|
213
|
+
throw new Error("服务适配器选择包含未注册项或重复项");
|
|
214
|
+
}
|
|
215
|
+
for (const manifest of selected) {
|
|
216
|
+
if (choices[manifest.service] !== manifest.id) {
|
|
217
|
+
throw new Error(`适配器 ${manifest.id} 的能力分类不匹配`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
manifests: selected,
|
|
223
|
+
sources: selected.map((manifest) => manifest.source),
|
|
224
|
+
packages: [...new Set(selected.flatMap((manifest) => manifest.packages))],
|
|
225
|
+
env: [...new Set(selected.flatMap((manifest) => manifest.env))],
|
|
226
|
+
bindings: [...new Set(selected.flatMap((manifest) => manifest.bindings))],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdapterError,
|
|
3
|
+
executeAdapterOperation,
|
|
4
|
+
type StorageAdapter,
|
|
5
|
+
type StorageWriteInput,
|
|
6
|
+
} from "@/core/services";
|
|
7
|
+
|
|
8
|
+
interface R2ObjectBodyPort {
|
|
9
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
10
|
+
etag?: string;
|
|
11
|
+
httpMetadata?: { contentType?: string };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface R2BucketPort {
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
get(key: string): Promise<R2ObjectBodyPort | null>;
|
|
17
|
+
put(
|
|
18
|
+
key: string,
|
|
19
|
+
body: StorageWriteInput["body"],
|
|
20
|
+
options?: { httpMetadata?: { contentType?: string } }
|
|
21
|
+
): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createR2BindingStorageAdapter(
|
|
25
|
+
buckets: Readonly<Record<string, R2BucketPort>>
|
|
26
|
+
): StorageAdapter {
|
|
27
|
+
const provider = "r2-binding" as const;
|
|
28
|
+
|
|
29
|
+
function getBucket(name: string): R2BucketPort {
|
|
30
|
+
const bucket = buckets[name];
|
|
31
|
+
if (!bucket) {
|
|
32
|
+
throw new AdapterError({
|
|
33
|
+
code: "configuration",
|
|
34
|
+
message: `R2 binding is not configured for bucket ${name}`,
|
|
35
|
+
provider,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return bucket;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function unsupported(operation: string): never {
|
|
42
|
+
throw new AdapterError({
|
|
43
|
+
code: "unsupported",
|
|
44
|
+
message: `${operation} is unavailable through an R2 binding`,
|
|
45
|
+
provider,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
provider,
|
|
51
|
+
capabilities: {
|
|
52
|
+
directRead: true,
|
|
53
|
+
directWrite: true,
|
|
54
|
+
signedDownloadUrls: false,
|
|
55
|
+
signedUploadUrls: false,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
async createDownloadUrl() {
|
|
59
|
+
return unsupported("Signed download URLs");
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
async createUploadUrl() {
|
|
63
|
+
return unsupported("Signed upload URLs");
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
async deleteObject(bucket, key) {
|
|
67
|
+
await executeAdapterOperation({
|
|
68
|
+
provider,
|
|
69
|
+
fallbackMessage: "R2 object deletion failed",
|
|
70
|
+
operation: () => getBucket(bucket).delete(key),
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
async readObject(bucket, key) {
|
|
75
|
+
const object = await executeAdapterOperation({
|
|
76
|
+
provider,
|
|
77
|
+
fallbackMessage: "R2 object read failed",
|
|
78
|
+
operation: () => getBucket(bucket).get(key),
|
|
79
|
+
});
|
|
80
|
+
if (!object) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
body: new Uint8Array(await object.arrayBuffer()),
|
|
85
|
+
...(object.httpMetadata?.contentType
|
|
86
|
+
? { contentType: object.httpMetadata.contentType }
|
|
87
|
+
: {}),
|
|
88
|
+
...(object.etag ? { etag: object.etag } : {}),
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async writeObject(input) {
|
|
93
|
+
await executeAdapterOperation({
|
|
94
|
+
provider,
|
|
95
|
+
fallbackMessage: "R2 object write failed",
|
|
96
|
+
operation: () =>
|
|
97
|
+
getBucket(input.bucket).put(input.key, input.body, {
|
|
98
|
+
...(input.contentType
|
|
99
|
+
? { httpMetadata: { contentType: input.contentType } }
|
|
100
|
+
: {}),
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeleteObjectCommand,
|
|
3
|
+
GetObjectCommand,
|
|
4
|
+
PutObjectCommand,
|
|
5
|
+
S3Client,
|
|
6
|
+
} from "@aws-sdk/client-s3";
|
|
7
|
+
import type { PutObjectCommandInput } from "@aws-sdk/client-s3";
|
|
8
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
AdapterError,
|
|
12
|
+
executeAdapterOperation,
|
|
13
|
+
type StorageAdapter,
|
|
14
|
+
type StorageWriteInput,
|
|
15
|
+
} from "@/core/services";
|
|
16
|
+
|
|
17
|
+
interface S3CompatibleConfig {
|
|
18
|
+
accessKeyId?: string;
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
region?: string;
|
|
21
|
+
secretAccessKey?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function toSdkBody(
|
|
25
|
+
body: StorageWriteInput["body"]
|
|
26
|
+
): NonNullable<PutObjectCommandInput["Body"]> {
|
|
27
|
+
return body instanceof ArrayBuffer ? new Uint8Array(body) : body;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createS3CompatibleStorageAdapter(
|
|
31
|
+
config: S3CompatibleConfig = {}
|
|
32
|
+
): StorageAdapter {
|
|
33
|
+
const provider = "s3-compatible" as const;
|
|
34
|
+
let client: S3Client | undefined;
|
|
35
|
+
|
|
36
|
+
function getClient(): S3Client {
|
|
37
|
+
if (client) {
|
|
38
|
+
return client;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const accessKeyId = config.accessKeyId ?? process.env.STORAGE_ACCESS_KEY_ID;
|
|
42
|
+
const secretAccessKey =
|
|
43
|
+
config.secretAccessKey ?? process.env.STORAGE_SECRET_ACCESS_KEY;
|
|
44
|
+
const endpoint = config.endpoint ?? process.env.STORAGE_ENDPOINT;
|
|
45
|
+
const region = config.region ?? process.env.STORAGE_REGION ?? "auto";
|
|
46
|
+
|
|
47
|
+
if (!accessKeyId || !secretAccessKey || !endpoint) {
|
|
48
|
+
throw new AdapterError({
|
|
49
|
+
code: "configuration",
|
|
50
|
+
message:
|
|
51
|
+
"Storage credentials are incomplete; configure access key, secret and endpoint",
|
|
52
|
+
provider,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
client = new S3Client({
|
|
57
|
+
region,
|
|
58
|
+
endpoint,
|
|
59
|
+
credentials: { accessKeyId, secretAccessKey },
|
|
60
|
+
forcePathStyle: true,
|
|
61
|
+
});
|
|
62
|
+
return client;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
provider,
|
|
67
|
+
capabilities: {
|
|
68
|
+
directRead: true,
|
|
69
|
+
directWrite: true,
|
|
70
|
+
signedDownloadUrls: true,
|
|
71
|
+
signedUploadUrls: true,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
async createDownloadUrl(input) {
|
|
75
|
+
return executeAdapterOperation({
|
|
76
|
+
provider,
|
|
77
|
+
fallbackMessage: "Signed download URL creation failed",
|
|
78
|
+
operation: () =>
|
|
79
|
+
getSignedUrl(
|
|
80
|
+
getClient(),
|
|
81
|
+
new GetObjectCommand({ Bucket: input.bucket, Key: input.key }),
|
|
82
|
+
{ expiresIn: input.expiresIn }
|
|
83
|
+
),
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
async createUploadUrl(input) {
|
|
88
|
+
return executeAdapterOperation({
|
|
89
|
+
provider,
|
|
90
|
+
fallbackMessage: "Signed upload URL creation failed",
|
|
91
|
+
operation: () =>
|
|
92
|
+
getSignedUrl(
|
|
93
|
+
getClient(),
|
|
94
|
+
new PutObjectCommand({
|
|
95
|
+
Bucket: input.bucket,
|
|
96
|
+
Key: input.key,
|
|
97
|
+
ContentType: input.contentType,
|
|
98
|
+
}),
|
|
99
|
+
{ expiresIn: input.expiresIn }
|
|
100
|
+
),
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
async deleteObject(bucket, key) {
|
|
105
|
+
await executeAdapterOperation({
|
|
106
|
+
provider,
|
|
107
|
+
fallbackMessage: "Object deletion failed",
|
|
108
|
+
operation: () =>
|
|
109
|
+
getClient().send(
|
|
110
|
+
new DeleteObjectCommand({ Bucket: bucket, Key: key })
|
|
111
|
+
),
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
async readObject(bucket, key) {
|
|
116
|
+
const result = await executeAdapterOperation({
|
|
117
|
+
provider,
|
|
118
|
+
fallbackMessage: "Object read failed",
|
|
119
|
+
operation: () =>
|
|
120
|
+
getClient().send(new GetObjectCommand({ Bucket: bucket, Key: key })),
|
|
121
|
+
});
|
|
122
|
+
if (!result.Body) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
body: new Uint8Array(await result.Body.transformToByteArray()),
|
|
128
|
+
...(result.ContentType ? { contentType: result.ContentType } : {}),
|
|
129
|
+
...(result.ETag ? { etag: result.ETag } : {}),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
async writeObject(input) {
|
|
134
|
+
await executeAdapterOperation({
|
|
135
|
+
provider,
|
|
136
|
+
fallbackMessage: "Object write failed",
|
|
137
|
+
operation: () =>
|
|
138
|
+
getClient().send(
|
|
139
|
+
new PutObjectCommand({
|
|
140
|
+
Bucket: input.bucket,
|
|
141
|
+
Key: input.key,
|
|
142
|
+
Body: toSdkBody(input.body),
|
|
143
|
+
...(input.contentType ? { ContentType: input.contentType } : {}),
|
|
144
|
+
})
|
|
145
|
+
),
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AdminSidebar } from "@/features/admin";
|
|
2
|
+
import { checkAdmin } from "@/lib/auth/admin";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Admin 布局组件
|
|
6
|
+
*
|
|
7
|
+
* 功能:
|
|
8
|
+
* - RBAC 权限检查 (只有 admin 角色可访问)
|
|
9
|
+
* - Admin 专用侧边栏(永远深色,控制台调性)
|
|
10
|
+
* - 内容区跟随用户主题,使用设计系统 token(不再硬编码 slate/white)
|
|
11
|
+
*/
|
|
12
|
+
export default async function AdminLayout({
|
|
13
|
+
children,
|
|
14
|
+
}: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}) {
|
|
17
|
+
// 权限检查 - 非管理员会被重定向
|
|
18
|
+
await checkAdmin();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="min-h-screen bg-muted/30">
|
|
22
|
+
<AdminSidebar />
|
|
23
|
+
<div className="pl-64">
|
|
24
|
+
{/* Admin 顶栏 */}
|
|
25
|
+
<header className="sticky top-0 z-30 flex h-14 items-center gap-3 border-b bg-background/80 px-6 backdrop-blur-xl">
|
|
26
|
+
<span className="rounded bg-destructive/10 px-1.5 py-0.5 font-mono text-[10px] font-semibold tracking-[0.14em] text-destructive uppercase">
|
|
27
|
+
ADMIN
|
|
28
|
+
</span>
|
|
29
|
+
<h1 className="text-lg font-semibold tracking-tight">管理后台</h1>
|
|
30
|
+
</header>
|
|
31
|
+
{/* 主内容区域 */}
|
|
32
|
+
<main className="p-6">{children}</main>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|