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,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": true,
|
|
10
|
+
"includes": [
|
|
11
|
+
"**/*.ts",
|
|
12
|
+
"**/*.tsx",
|
|
13
|
+
"**/*.js",
|
|
14
|
+
"**/*.jsx",
|
|
15
|
+
"**/*.json",
|
|
16
|
+
"cloudflare/**/*.mjs",
|
|
17
|
+
"!.next",
|
|
18
|
+
"!.open-next",
|
|
19
|
+
"!packages/*/dist",
|
|
20
|
+
"!packages/*/template",
|
|
21
|
+
"!worker-configuration.d.ts"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"formatter": {
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"indentStyle": "space",
|
|
27
|
+
"indentWidth": 2,
|
|
28
|
+
"lineWidth": 80
|
|
29
|
+
},
|
|
30
|
+
"linter": {
|
|
31
|
+
"enabled": true,
|
|
32
|
+
"rules": {
|
|
33
|
+
"recommended": true,
|
|
34
|
+
"correctness": {
|
|
35
|
+
"noUnusedImports": "error",
|
|
36
|
+
"noUnusedVariables": "error",
|
|
37
|
+
"useExhaustiveDependencies": "warn"
|
|
38
|
+
},
|
|
39
|
+
"style": {
|
|
40
|
+
"noNonNullAssertion": "off",
|
|
41
|
+
"useConst": "error",
|
|
42
|
+
"useImportType": "error"
|
|
43
|
+
},
|
|
44
|
+
"suspicious": {
|
|
45
|
+
"noExplicitAny": "error"
|
|
46
|
+
},
|
|
47
|
+
"a11y": {
|
|
48
|
+
"recommended": true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"javascript": {
|
|
53
|
+
"formatter": {
|
|
54
|
+
"quoteStyle": "double",
|
|
55
|
+
"semicolons": "always",
|
|
56
|
+
"trailingCommas": "es5"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"assist": {
|
|
60
|
+
"actions": {
|
|
61
|
+
"source": {
|
|
62
|
+
"organizeImports": {
|
|
63
|
+
"level": "on"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
type LogData = Record<string, unknown>;
|
|
2
|
+
type LogLevel = "debug" | "error" | "fatal" | "info" | "warn";
|
|
3
|
+
type ConsoleMethod = "debug" | "error" | "log" | "warn";
|
|
4
|
+
|
|
5
|
+
export interface Logger {
|
|
6
|
+
child(context: LogData): Logger;
|
|
7
|
+
debug(dataOrMessage: LogData | string, message?: string): void;
|
|
8
|
+
error(dataOrMessage: LogData | string, message?: string): void;
|
|
9
|
+
fatal(dataOrMessage: LogData | string, message?: string): void;
|
|
10
|
+
info(dataOrMessage: LogData | string, message?: string): void;
|
|
11
|
+
warn(dataOrMessage: LogData | string, message?: string): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const CONSOLE_METHODS: Readonly<Record<LogLevel, ConsoleMethod>> = {
|
|
15
|
+
debug: "debug",
|
|
16
|
+
error: "error",
|
|
17
|
+
fatal: "error",
|
|
18
|
+
info: "log",
|
|
19
|
+
warn: "warn",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function writeLog(
|
|
23
|
+
level: LogLevel,
|
|
24
|
+
context: LogData,
|
|
25
|
+
dataOrMessage: LogData | string,
|
|
26
|
+
message?: string
|
|
27
|
+
): void {
|
|
28
|
+
const data =
|
|
29
|
+
typeof dataOrMessage === "string"
|
|
30
|
+
? context
|
|
31
|
+
: { ...context, ...dataOrMessage };
|
|
32
|
+
const text = typeof dataOrMessage === "string" ? dataOrMessage : message;
|
|
33
|
+
const details = Object.keys(data).length > 0 ? data : undefined;
|
|
34
|
+
const output = console[CONSOLE_METHODS[level]];
|
|
35
|
+
|
|
36
|
+
if (text && details) {
|
|
37
|
+
output(text, details);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (text) {
|
|
41
|
+
output(text);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (details) output(details);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function createLogger(context: LogData = {}): Logger {
|
|
48
|
+
return {
|
|
49
|
+
child(childContext) {
|
|
50
|
+
return createLogger({ ...context, ...childContext });
|
|
51
|
+
},
|
|
52
|
+
debug(dataOrMessage, message) {
|
|
53
|
+
writeLog("debug", context, dataOrMessage, message);
|
|
54
|
+
},
|
|
55
|
+
error(dataOrMessage, message) {
|
|
56
|
+
writeLog("error", context, dataOrMessage, message);
|
|
57
|
+
},
|
|
58
|
+
fatal(dataOrMessage, message) {
|
|
59
|
+
writeLog("fatal", context, dataOrMessage, message);
|
|
60
|
+
},
|
|
61
|
+
info(dataOrMessage, message) {
|
|
62
|
+
writeLog("info", context, dataOrMessage, message);
|
|
63
|
+
},
|
|
64
|
+
warn(dataOrMessage, message) {
|
|
65
|
+
writeLog("warn", context, dataOrMessage, message);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const logger = createLogger({
|
|
71
|
+
env: process.env.NODE_ENV,
|
|
72
|
+
service: "nextdevtpl",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export function createContextLogger(context: LogData): Logger {
|
|
76
|
+
return logger.child(context);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function createRequestLogger(request: Request): Logger {
|
|
80
|
+
const url = new URL(request.url);
|
|
81
|
+
return logger.child({
|
|
82
|
+
requestId: crypto.randomUUID(),
|
|
83
|
+
method: request.method,
|
|
84
|
+
path: url.pathname,
|
|
85
|
+
userAgent: request.headers.get("user-agent")?.slice(0, 100),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type BusinessEvent =
|
|
90
|
+
| "user.signup"
|
|
91
|
+
| "user.login"
|
|
92
|
+
| "user.logout"
|
|
93
|
+
| "payment.checkout.started"
|
|
94
|
+
| "payment.checkout.completed"
|
|
95
|
+
| "payment.credits.already_granted"
|
|
96
|
+
| "payment.credits.grant_success"
|
|
97
|
+
| "payment.subscription.created"
|
|
98
|
+
| "payment.subscription.canceled"
|
|
99
|
+
| "payment.subscription.past_due"
|
|
100
|
+
| "payment.subscription.paused"
|
|
101
|
+
| "payment.subscription.upserted"
|
|
102
|
+
| "credits.purchased"
|
|
103
|
+
| "credits.consumed"
|
|
104
|
+
| "credits.expired"
|
|
105
|
+
| "ticket.created"
|
|
106
|
+
| "ticket.replied"
|
|
107
|
+
| "ticket.closed"
|
|
108
|
+
| "email.sent"
|
|
109
|
+
| "file.uploaded"
|
|
110
|
+
| "file.deleted"
|
|
111
|
+
| "admin.user.banned"
|
|
112
|
+
| "admin.user.unbanned";
|
|
113
|
+
|
|
114
|
+
export function logEvent(event: BusinessEvent, data?: LogData): void {
|
|
115
|
+
logger.info({ event, ...data }, `Event: ${event}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function logError(error: unknown, context?: LogData): void {
|
|
119
|
+
if (error instanceof Error) {
|
|
120
|
+
logger.error(
|
|
121
|
+
{
|
|
122
|
+
err: {
|
|
123
|
+
name: error.name,
|
|
124
|
+
message: error.message,
|
|
125
|
+
stack: error.stack,
|
|
126
|
+
},
|
|
127
|
+
...context,
|
|
128
|
+
},
|
|
129
|
+
error.message
|
|
130
|
+
);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
logger.error({ err: error, ...context }, "Unknown error");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function logWarn(message: string, data?: LogData): void {
|
|
137
|
+
logger.warn(data ?? {}, message);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function logDebug(message: string, data?: LogData): void {
|
|
141
|
+
logger.debug(data ?? {}, message);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function logApiResponse(
|
|
145
|
+
request: Request,
|
|
146
|
+
response: Response,
|
|
147
|
+
duration: number
|
|
148
|
+
): void {
|
|
149
|
+
const url = new URL(request.url);
|
|
150
|
+
const level =
|
|
151
|
+
response.status >= 500 ? "error" : response.status >= 400 ? "warn" : "info";
|
|
152
|
+
|
|
153
|
+
logger[level](
|
|
154
|
+
{
|
|
155
|
+
method: request.method,
|
|
156
|
+
path: url.pathname,
|
|
157
|
+
status: response.status,
|
|
158
|
+
duration,
|
|
159
|
+
},
|
|
160
|
+
`${request.method} ${url.pathname} ${response.status} ${duration}ms`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export interface RenderedEmail {
|
|
2
|
+
html: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface ActionEmailParams {
|
|
7
|
+
actionLabel: string;
|
|
8
|
+
actionUrl: string;
|
|
9
|
+
expiresIn: string;
|
|
10
|
+
greeting: string;
|
|
11
|
+
message: string;
|
|
12
|
+
title: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function escapeHtml(value: string): string {
|
|
16
|
+
return value
|
|
17
|
+
.replaceAll("&", "&")
|
|
18
|
+
.replaceAll("<", "<")
|
|
19
|
+
.replaceAll(">", ">")
|
|
20
|
+
.replaceAll('"', """)
|
|
21
|
+
.replaceAll("'", "'");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function createActionEmail(params: ActionEmailParams): RenderedEmail {
|
|
25
|
+
const actionLabel = escapeHtml(params.actionLabel);
|
|
26
|
+
const actionUrl = escapeHtml(params.actionUrl);
|
|
27
|
+
const expiresIn = escapeHtml(params.expiresIn);
|
|
28
|
+
const greeting = escapeHtml(params.greeting);
|
|
29
|
+
const message = escapeHtml(params.message);
|
|
30
|
+
const title = escapeHtml(params.title);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
html: [
|
|
34
|
+
'<!doctype html><html><body style="background:#fff;color:#111827;font-family:Arial,sans-serif">',
|
|
35
|
+
'<main style="border:1px solid #e5e7eb;border-radius:8px;margin:40px auto;max-width:576px;padding:32px">',
|
|
36
|
+
'<h1 style="text-align:center">NextDevTpl</h1>',
|
|
37
|
+
`<h2>${title}</h2>`,
|
|
38
|
+
`<p>${greeting}</p>`,
|
|
39
|
+
`<p>${message}</p>`,
|
|
40
|
+
'<p style="text-align:center">',
|
|
41
|
+
`<a href="${actionUrl}" style="background:#7c3aed;border-radius:6px;color:#fff;display:inline-block;padding:12px 24px;text-decoration:none">${actionLabel}</a>`,
|
|
42
|
+
"</p>",
|
|
43
|
+
`<p style="color:#6b7280;font-size:14px;text-align:center">This link will expire in ${expiresIn}.</p>`,
|
|
44
|
+
`<p style="color:#6b7280;font-size:12px;word-break:break-all">If the button does not work, open: ${actionUrl}</p>`,
|
|
45
|
+
'<p style="color:#9ca3af;font-size:12px;text-align:center">If you did not request this email, you can ignore it.</p>',
|
|
46
|
+
"</main></body></html>",
|
|
47
|
+
].join(""),
|
|
48
|
+
text: [
|
|
49
|
+
params.title,
|
|
50
|
+
"",
|
|
51
|
+
params.greeting,
|
|
52
|
+
params.message,
|
|
53
|
+
"",
|
|
54
|
+
`${params.actionLabel}: ${params.actionUrl}`,
|
|
55
|
+
"",
|
|
56
|
+
`This link will expire in ${params.expiresIn}.`,
|
|
57
|
+
].join("\n"),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createResetPasswordEmail(params: {
|
|
62
|
+
name: string;
|
|
63
|
+
resetUrl: string;
|
|
64
|
+
}): RenderedEmail {
|
|
65
|
+
return createActionEmail({
|
|
66
|
+
actionLabel: "Reset Password",
|
|
67
|
+
actionUrl: params.resetUrl,
|
|
68
|
+
expiresIn: "1 hour",
|
|
69
|
+
greeting: `Hi ${params.name},`,
|
|
70
|
+
message: "We received a request to reset your password.",
|
|
71
|
+
title: "Reset Your Password",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function createVerifyEmail(params: {
|
|
76
|
+
name: string;
|
|
77
|
+
verifyUrl: string;
|
|
78
|
+
}): RenderedEmail {
|
|
79
|
+
return createActionEmail({
|
|
80
|
+
actionLabel: "Verify Email",
|
|
81
|
+
actionUrl: params.verifyUrl,
|
|
82
|
+
expiresIn: "24 hours",
|
|
83
|
+
greeting: `Hi ${params.name},`,
|
|
84
|
+
message: "Please verify your email address to keep your account secure.",
|
|
85
|
+
title: "Verify Your Email",
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { MailAddress } from "@/core/services";
|
|
2
|
+
import { mailService } from "@/services/mail";
|
|
3
|
+
|
|
4
|
+
import type { RenderedEmail } from "./templates";
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_FROM_EMAIL =
|
|
7
|
+
process.env.EMAIL_FROM ?? "NextDevTpl <noreply@example.com>";
|
|
8
|
+
|
|
9
|
+
export interface SendEmailParams {
|
|
10
|
+
bcc?: string | string[];
|
|
11
|
+
cc?: string | string[];
|
|
12
|
+
content: RenderedEmail;
|
|
13
|
+
force?: boolean;
|
|
14
|
+
from?: string;
|
|
15
|
+
replyTo?: string | string[];
|
|
16
|
+
subject: string;
|
|
17
|
+
to: string | string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SendEmailResult {
|
|
21
|
+
error?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
simulated?: boolean;
|
|
24
|
+
success: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseMailAddress(value: string): MailAddress {
|
|
28
|
+
const match = /^\s*(.*?)\s*<([^>]+)>\s*$/.exec(value);
|
|
29
|
+
const email = match?.[2];
|
|
30
|
+
const name = match?.[1]?.trim();
|
|
31
|
+
|
|
32
|
+
if (!email) return { email: value.trim() };
|
|
33
|
+
return name ? { email, name } : { email };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toArray(value: string | string[]): string[] {
|
|
37
|
+
return Array.isArray(value) ? value : [value];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function sendEmail(
|
|
41
|
+
params: SendEmailParams
|
|
42
|
+
): Promise<SendEmailResult> {
|
|
43
|
+
if (process.env.NODE_ENV === "development" && !params.force) {
|
|
44
|
+
console.log("Email preview", {
|
|
45
|
+
from: params.from ?? DEFAULT_FROM_EMAIL,
|
|
46
|
+
subject: params.subject,
|
|
47
|
+
to: params.to,
|
|
48
|
+
});
|
|
49
|
+
return { simulated: true, success: true };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const result = await mailService.send({
|
|
54
|
+
from: parseMailAddress(params.from ?? DEFAULT_FROM_EMAIL),
|
|
55
|
+
to: toArray(params.to),
|
|
56
|
+
subject: params.subject,
|
|
57
|
+
html: params.content.html,
|
|
58
|
+
text: params.content.text,
|
|
59
|
+
...(params.cc ? { cc: toArray(params.cc) } : {}),
|
|
60
|
+
...(params.bcc ? { bcc: toArray(params.bcc) } : {}),
|
|
61
|
+
...(params.replyTo ? { replyTo: toArray(params.replyTo) } : {}),
|
|
62
|
+
});
|
|
63
|
+
return { success: true, ...(result.id ? { id: result.id } : {}) };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
66
|
+
console.error("Email sending error:", message);
|
|
67
|
+
return { error: message, success: false };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WorkflowEntrypoint } from "cloudflare:workers";
|
|
2
|
+
|
|
3
|
+
import nextWorker from "../.open-next/worker.js";
|
|
4
|
+
|
|
5
|
+
export class NextDevTplWorkflow extends WorkflowEntrypoint {
|
|
6
|
+
async run(event, step) {
|
|
7
|
+
return step.do(
|
|
8
|
+
"complete-job",
|
|
9
|
+
{
|
|
10
|
+
retries: {
|
|
11
|
+
delay: "5 seconds",
|
|
12
|
+
limit: 3,
|
|
13
|
+
},
|
|
14
|
+
timeout: "1 minute",
|
|
15
|
+
},
|
|
16
|
+
async () => ({
|
|
17
|
+
id: event.instanceId,
|
|
18
|
+
payload: event.payload,
|
|
19
|
+
status: "completed",
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default nextWorker;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": true,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "src/app/globals.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"iconLibrary": "lucide",
|
|
14
|
+
"aliases": {
|
|
15
|
+
"components": "@/components",
|
|
16
|
+
"utils": "@/lib/utils",
|
|
17
|
+
"ui": "@/components/ui",
|
|
18
|
+
"lib": "@/lib",
|
|
19
|
+
"hooks": "@/hooks"
|
|
20
|
+
},
|
|
21
|
+
"registries": {}
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: nextdevtpl
|
|
2
|
+
|
|
3
|
+
x-app-environment: &app-environment
|
|
4
|
+
APP_VERSION: ${APP_VERSION:-local}
|
|
5
|
+
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?Set BETTER_AUTH_SECRET in .env.production}
|
|
6
|
+
BETTER_AUTH_URL: ${BETTER_AUTH_URL:-http://localhost:3000}
|
|
7
|
+
DATABASE_URL: postgresql://${POSTGRES_USER:-nextdevtpl}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env.production}@database:5432/${POSTGRES_DB:-nextdevtpl}
|
|
8
|
+
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
|
|
9
|
+
PORT: 3000
|
|
10
|
+
|
|
11
|
+
services:
|
|
12
|
+
database:
|
|
13
|
+
image: postgres:17-alpine
|
|
14
|
+
environment:
|
|
15
|
+
POSTGRES_DB: ${POSTGRES_DB:-nextdevtpl}
|
|
16
|
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env.production}
|
|
17
|
+
POSTGRES_USER: ${POSTGRES_USER:-nextdevtpl}
|
|
18
|
+
healthcheck:
|
|
19
|
+
test:
|
|
20
|
+
[
|
|
21
|
+
"CMD-SHELL",
|
|
22
|
+
"pg_isready -U ${POSTGRES_USER:-nextdevtpl} -d ${POSTGRES_DB:-nextdevtpl}",
|
|
23
|
+
]
|
|
24
|
+
interval: 5s
|
|
25
|
+
timeout: 5s
|
|
26
|
+
retries: 12
|
|
27
|
+
restart: unless-stopped
|
|
28
|
+
volumes:
|
|
29
|
+
- postgres_data:/var/lib/postgresql/data
|
|
30
|
+
|
|
31
|
+
migrate:
|
|
32
|
+
build:
|
|
33
|
+
context: .
|
|
34
|
+
target: migrator
|
|
35
|
+
env_file:
|
|
36
|
+
- path: .env.production
|
|
37
|
+
required: false
|
|
38
|
+
environment: *app-environment
|
|
39
|
+
depends_on:
|
|
40
|
+
database:
|
|
41
|
+
condition: service_healthy
|
|
42
|
+
restart: "no"
|
|
43
|
+
|
|
44
|
+
app:
|
|
45
|
+
build:
|
|
46
|
+
context: .
|
|
47
|
+
target: runner
|
|
48
|
+
args:
|
|
49
|
+
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
|
|
50
|
+
env_file:
|
|
51
|
+
- path: .env.production
|
|
52
|
+
required: false
|
|
53
|
+
environment: *app-environment
|
|
54
|
+
depends_on:
|
|
55
|
+
migrate:
|
|
56
|
+
condition: service_completed_successfully
|
|
57
|
+
healthcheck:
|
|
58
|
+
test:
|
|
59
|
+
[
|
|
60
|
+
"CMD",
|
|
61
|
+
"node",
|
|
62
|
+
"-e",
|
|
63
|
+
"fetch('http://127.0.0.1:3000/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))",
|
|
64
|
+
]
|
|
65
|
+
interval: 10s
|
|
66
|
+
timeout: 5s
|
|
67
|
+
retries: 6
|
|
68
|
+
start_period: 20s
|
|
69
|
+
ports:
|
|
70
|
+
- "${PORT:-3000}:3000"
|
|
71
|
+
restart: unless-stopped
|
|
72
|
+
|
|
73
|
+
volumes:
|
|
74
|
+
postgres_data:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const target = process.argv[2] ?? process.env.HEALTHCHECK_URL;
|
|
2
|
+
|
|
3
|
+
if (!target) {
|
|
4
|
+
throw new Error(
|
|
5
|
+
"Health URL is required: pnpm deploy:check -- https://example.com/api/health"
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const response = await fetch(target, {
|
|
10
|
+
headers: { Accept: "application/json" },
|
|
11
|
+
signal: AbortSignal.timeout(10_000),
|
|
12
|
+
});
|
|
13
|
+
const report = await response.json();
|
|
14
|
+
|
|
15
|
+
if (!response.ok || report?.status !== "healthy") {
|
|
16
|
+
throw new Error(`Health check failed with HTTP ${response.status}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
process.stdout.write(
|
|
20
|
+
`${JSON.stringify({
|
|
21
|
+
status: report.status,
|
|
22
|
+
version: report.version,
|
|
23
|
+
timestamp: report.timestamp,
|
|
24
|
+
})}\n`
|
|
25
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Docker Compose 部署
|
|
2
|
+
|
|
3
|
+
Compose 包含 PostgreSQL、一次性迁移服务和应用服务。数据库目录使用
|
|
4
|
+
`postgres_data` named volume,不会写进项目目录。
|
|
5
|
+
|
|
6
|
+
1. 复制 `.env.example` 为 `.env.production`,至少设置
|
|
7
|
+
`POSTGRES_PASSWORD`、`BETTER_AUTH_SECRET`、站点 URL 和所选适配器配置。
|
|
8
|
+
2. 首次生成的项目运行 `pnpm install && pnpm db:generate:init`,检查并提交
|
|
9
|
+
`drizzle/`。后续 Schema 变化继续生成新的迁移。
|
|
10
|
+
3. 执行 `docker compose --env-file .env.production up -d --build`。
|
|
11
|
+
4. 执行 `pnpm deploy:check -- http://localhost:3000/api/health`。
|
|
12
|
+
|
|
13
|
+
`migrate` 成功退出后应用才会启动。升级时先备份 named volume 或外部数据库,
|
|
14
|
+
再构建新镜像;迁移失败会阻止新应用启动。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 服务器部署
|
|
2
|
+
|
|
3
|
+
要求 Node.js 24、pnpm 10、PostgreSQL 和 systemd。数据库连接建议使用独立托管
|
|
4
|
+
实例;应用服务器只保存可替换的 standalone 产物。
|
|
5
|
+
|
|
6
|
+
## 首次部署
|
|
7
|
+
|
|
8
|
+
1. 复制 `.env.example` 为 `.env.production`,填写真实生产配置。不要把这个文件
|
|
9
|
+
加入 Git 或构建包。
|
|
10
|
+
2. 首次生成的项目先运行 `pnpm install && pnpm db:generate:init`,检查生成的 SQL
|
|
11
|
+
并提交 `drizzle/`。仓库已经带迁移时跳过这一步。
|
|
12
|
+
3. 加载生产环境变量后运行 `pnpm deploy:server:build`。脚本先执行已提交迁移,
|
|
13
|
+
再把 standalone 产物写入 `.release/`。
|
|
14
|
+
4. 把 `.release/` 上传到 `/opt/nextdevtpl/current`,把环境文件单独放到
|
|
15
|
+
`/opt/nextdevtpl/shared/.env.production`。
|
|
16
|
+
5. 按实际用户和目录调整 `nextdevtpl.service`,安装到 systemd 后启动服务。
|
|
17
|
+
|
|
18
|
+
反向代理应终止 TLS,并把原始协议和主机头转发给端口 3000。发布完成后执行:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm deploy:check -- https://your-domain.example/api/health
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
接口返回 200 且 `status` 为 `healthy` 才表示配置和数据库均已就绪。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
5
|
+
RELEASE_DIR="${RELEASE_DIR:-$ROOT_DIR/.release}"
|
|
6
|
+
|
|
7
|
+
if [[ "$RELEASE_DIR" == "/" || "$RELEASE_DIR" == "$ROOT_DIR" ]]; then
|
|
8
|
+
echo "Refusing unsafe RELEASE_DIR: $RELEASE_DIR" >&2
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
cd "$ROOT_DIR"
|
|
13
|
+
pnpm install --frozen-lockfile
|
|
14
|
+
pnpm db:migrate
|
|
15
|
+
pnpm build
|
|
16
|
+
|
|
17
|
+
rm -rf -- "$RELEASE_DIR"
|
|
18
|
+
mkdir -p "$RELEASE_DIR/.next"
|
|
19
|
+
cp -R .next/standalone/. "$RELEASE_DIR/"
|
|
20
|
+
cp -R .next/static "$RELEASE_DIR/.next/static"
|
|
21
|
+
cp -R public "$RELEASE_DIR/public"
|
|
22
|
+
cp deploy/server/start.sh "$RELEASE_DIR/start.sh"
|
|
23
|
+
|
|
24
|
+
echo "Standalone release created at $RELEASE_DIR"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=NextDevTpl application
|
|
3
|
+
After=network-online.target
|
|
4
|
+
Wants=network-online.target
|
|
5
|
+
|
|
6
|
+
[Service]
|
|
7
|
+
Type=simple
|
|
8
|
+
User=nextdevtpl
|
|
9
|
+
Group=nextdevtpl
|
|
10
|
+
WorkingDirectory=/opt/nextdevtpl/current
|
|
11
|
+
EnvironmentFile=/opt/nextdevtpl/shared/.env.production
|
|
12
|
+
ExecStart=/opt/nextdevtpl/current/start.sh
|
|
13
|
+
Restart=on-failure
|
|
14
|
+
RestartSec=5
|
|
15
|
+
NoNewPrivileges=true
|
|
16
|
+
PrivateTmp=true
|
|
17
|
+
|
|
18
|
+
[Install]
|
|
19
|
+
WantedBy=multi-user.target
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
ENV_FILE="${ENV_FILE:-$APP_DIR/.env.production}"
|
|
6
|
+
|
|
7
|
+
if [[ -f "$ENV_FILE" ]]; then
|
|
8
|
+
set -a
|
|
9
|
+
# shellcheck disable=SC1090
|
|
10
|
+
source "$ENV_FILE"
|
|
11
|
+
set +a
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
export HOSTNAME="${HOSTNAME:-0.0.0.0}"
|
|
15
|
+
export NODE_ENV=production
|
|
16
|
+
export PORT="${PORT:-3000}"
|
|
17
|
+
|
|
18
|
+
cd "$APP_DIR"
|
|
19
|
+
exec node server.js
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Vercel 部署
|
|
2
|
+
|
|
3
|
+
Vercel 预设使用 Node.js Serverless 运行时。推荐使用 Neon PostgreSQL、S3 兼容
|
|
4
|
+
对象存储、Upstash Redis 和 Inngest;实际启用项以生成器选择的适配器为准。
|
|
5
|
+
|
|
6
|
+
1. 在 Vercel 项目中配置 `.env.example` 列出的变量,并把
|
|
7
|
+
`NEXT_PUBLIC_APP_URL`、`BETTER_AUTH_URL` 设置为正式域名。
|
|
8
|
+
2. 首次生成的项目运行 `pnpm install && pnpm db:generate:init`,检查并提交
|
|
9
|
+
`drizzle/`。
|
|
10
|
+
3. 在发布前的单实例任务或本机受控环境运行 `pnpm db:migrate`。不要把迁移放进
|
|
11
|
+
Vercel `buildCommand`,多个构建实例可能并发执行。
|
|
12
|
+
4. 发布后执行
|
|
13
|
+
`pnpm deploy:check -- https://your-project.vercel.app/api/health`。
|
|
14
|
+
|
|
15
|
+
`vercel.json` 只声明框架、构建命令和已选模块需要的 Cron。OAuth 回调、支付
|
|
16
|
+
Webhook、Inngest 回调和对象存储 CORS 仍需在各服务后台配置正式域名。
|