create-ej-app 26.0.0 → 27.0.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 +125 -226
- package/cli.ts +79 -29
- package/package.json +2 -2
- package/template/api/.vscode/settings.json +1 -1
- package/template/api/{.github/copilot-instructions.md → AGENTS.md} +0 -2
- package/template/api/CLAUDE.md +1 -0
- package/template/api/package.json +10 -10
- package/template/nextjs/.dockerignore +1 -0
- package/template/nextjs/AGENTS.md +260 -0
- package/template/nextjs/CLAUDE.md +1 -0
- package/template/nextjs/README.md +109 -0
- package/template/nextjs/bunfig.toml +3 -0
- package/template/nextjs/eslint.config.mjs +6 -5
- package/template/nextjs/gitignore +6 -1
- package/template/nextjs/next.config.ts +8 -1
- package/template/nextjs/package.json +46 -39
- package/template/nextjs/public/logo-dark.svg +4 -0
- package/template/nextjs/public/logo.svg +4 -0
- package/template/nextjs/src/app/(admin)/actions/users.ts +183 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-header.tsx +24 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-search.tsx +16 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-sidebar.tsx +42 -0
- package/template/nextjs/src/app/(admin)/admin/layout.tsx +53 -0
- package/template/nextjs/src/app/(admin)/admin/page.tsx +11 -2
- package/template/nextjs/src/app/(admin)/admin/settings/layout.tsx +24 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/[userId]/page.tsx +43 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/new/page.tsx +16 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/page.tsx +377 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/user-form.tsx +138 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/validation.ts +23 -0
- package/template/nextjs/src/app/(app)/app/layout.tsx +44 -0
- package/template/nextjs/src/app/(app)/app/page.tsx +14 -2
- package/template/nextjs/src/app/(auth)/(account)/layout.tsx +64 -0
- package/template/nextjs/src/app/(auth)/(account)/profile/page.tsx +16 -0
- package/template/nextjs/src/app/(auth)/(account)/profile/profile-form.tsx +247 -0
- package/template/nextjs/src/app/(auth)/login/email-login-form.tsx +56 -29
- package/template/nextjs/src/app/(auth)/login/page.tsx +45 -12
- package/template/nextjs/src/app/(auth)/login/social-login-buttons.tsx +85 -17
- package/template/nextjs/src/app/(marketing)/layout.tsx +35 -4
- package/template/nextjs/src/app/(marketing)/legal.tsx +56 -0
- package/template/nextjs/src/app/(marketing)/page.tsx +20 -2
- package/template/nextjs/src/app/(marketing)/privacy/page.tsx +43 -2
- package/template/nextjs/src/app/(marketing)/terms/page.tsx +33 -2
- package/template/nextjs/src/app/error.tsx +37 -0
- package/template/nextjs/src/app/fonts/geist-mono/GeistMono-Variable.woff2 +0 -0
- package/template/nextjs/src/app/fonts/geist-sans/Geist-Variable.woff2 +0 -0
- package/template/nextjs/src/app/fonts/index.ts +60 -0
- package/template/nextjs/src/app/global-error.tsx +38 -0
- package/template/nextjs/src/app/globals.css +29 -0
- package/template/nextjs/src/app/layout.tsx +45 -18
- package/template/nextjs/src/app/not-found.tsx +25 -3
- package/template/nextjs/src/app/robots.ts +29 -0
- package/template/nextjs/src/app/sitemap.ts +21 -0
- package/template/nextjs/src/components/confirm-dialog.tsx +79 -0
- package/template/nextjs/src/components/dashboard-header.tsx +70 -0
- package/template/nextjs/src/components/data-table/enum.ts +5 -0
- package/template/nextjs/src/components/data-table/features.ts +49 -0
- package/template/nextjs/src/components/data-table/index.tsx +961 -0
- package/template/nextjs/src/components/data-table/types.ts +76 -0
- package/template/nextjs/src/components/error.tsx +71 -0
- package/template/nextjs/src/components/loader.tsx +18 -2
- package/template/nextjs/src/components/logo.tsx +49 -0
- package/template/nextjs/src/components/navigation-search.tsx +140 -0
- package/template/nextjs/src/components/navigation-sidebar.tsx +241 -0
- package/template/nextjs/src/components/page-heading.tsx +38 -0
- package/template/nextjs/src/components/react-query-provider.tsx +41 -2
- package/template/nextjs/src/components/route-error.tsx +55 -0
- package/template/nextjs/src/components/screen-size.tsx +36 -0
- package/template/nextjs/src/components/site-footer.tsx +20 -4
- package/template/nextjs/src/components/theme-provider.tsx +48 -0
- package/template/nextjs/src/components/theme-toggle.tsx +58 -5
- package/template/nextjs/src/components/ui/alert-dialog.tsx +199 -0
- package/template/nextjs/src/components/ui/avatar.tsx +112 -0
- package/template/nextjs/src/components/ui/badge.tsx +54 -0
- package/template/nextjs/src/components/ui/button.tsx +3 -1
- package/template/nextjs/src/components/ui/card.tsx +4 -4
- package/template/nextjs/src/components/ui/collapsible.tsx +33 -0
- package/template/nextjs/src/components/ui/command.tsx +192 -0
- package/template/nextjs/src/components/ui/dialog.tsx +164 -0
- package/template/nextjs/src/components/ui/dropdown-menu.tsx +273 -0
- package/template/nextjs/src/components/ui/input-group.tsx +156 -0
- package/template/nextjs/src/components/ui/select.tsx +195 -0
- package/template/nextjs/src/components/ui/sheet.tsx +143 -0
- package/template/nextjs/src/components/ui/sidebar.tsx +702 -0
- package/template/nextjs/src/components/ui/skeleton.tsx +13 -0
- package/template/nextjs/src/components/ui/table.tsx +116 -0
- package/template/nextjs/src/components/ui/textarea.tsx +18 -0
- package/template/nextjs/src/components/ui/tooltip.tsx +57 -0
- package/template/nextjs/src/components/user-menu.tsx +206 -0
- package/template/nextjs/src/db/common.ts +10 -0
- package/template/nextjs/src/db/index.ts +16 -6
- package/template/nextjs/src/db/relations.ts +21 -0
- package/template/nextjs/src/db/schema.ts +85 -46
- package/template/nextjs/src/emails/components/email-layout.tsx +27 -11
- package/template/nextjs/src/emails/magic-link.tsx +15 -13
- package/template/nextjs/src/emails/test.tsx +11 -9
- package/template/nextjs/src/emails/welcome.tsx +12 -9
- package/template/nextjs/src/env.ts +1 -1
- package/template/nextjs/src/hooks/use-mobile.ts +14 -12
- package/template/nextjs/src/instrumentation.ts +20 -2
- package/template/nextjs/src/lib/actions.ts +55 -0
- package/template/nextjs/src/lib/admin-navigation.ts +43 -0
- package/template/nextjs/src/lib/auth-client.ts +20 -9
- package/template/nextjs/src/lib/auth-permissions.ts +61 -0
- package/template/nextjs/src/lib/auth.ts +33 -3
- package/template/nextjs/src/lib/callback-url.ts +28 -0
- package/template/nextjs/src/lib/constants.ts +21 -0
- package/template/nextjs/src/lib/delay.ts +10 -0
- package/template/nextjs/src/lib/email-service.ts +21 -0
- package/template/nextjs/src/lib/errors.ts +74 -0
- package/template/nextjs/src/lib/format-currency.ts +22 -24
- package/template/nextjs/src/lib/format-date.ts +69 -6
- package/template/nextjs/src/lib/nodemailer.ts +27 -3
- package/template/nextjs/src/lib/otel.ts +92 -2
- package/template/nextjs/src/lib/safe-action-client.ts +60 -9
- package/template/nextjs/src/lib/safe-action.ts +152 -16
- package/template/nextjs/src/lib/search.ts +16 -0
- package/template/nextjs/src/lib/seo.ts +7 -0
- package/template/nextjs/src/lib/siteConfig.ts +17 -1
- package/template/nextjs/src/lib/toast-message.ts +87 -1
- package/template/nextjs/src/lib/validations.ts +30 -0
- package/template/nextjs/src/proxy.ts +48 -0
- package/template/nextjs/src/scripts/reset-db.ts +22 -0
- package/template/nextjs/src/scripts/seed.ts +59 -8
- package/template/nextjs/src/scripts/test-mail.ts +28 -20
- package/template/nextjs/tests/admin/users.test.ts +64 -0
- package/template/nextjs/tests/db/fk-indexes.test.ts +62 -0
- package/template/nextjs/tests/db/seed.test.ts +49 -0
- package/template/nextjs/tests/helpers/action.ts +71 -0
- package/template/nextjs/tests/helpers/fixtures.ts +78 -0
- package/template/nextjs/tests/helpers/index.ts +2 -0
- package/template/nextjs/tests/lib/callback-url.test.ts +48 -0
- package/template/nextjs/tests/lib/client-server-boundary.test.ts +57 -0
- package/template/nextjs/tests/lib/errors.test.ts +10 -0
- package/template/nextjs/tests/lib/search.test.ts +23 -0
- package/template/nextjs/tests/setup/pglite-db.ts +63 -0
- package/template/nextjs/tests/setup/preload.ts +95 -0
- package/template/nextjs/tsconfig.json +1 -0
- package/template/saas-starter/.dockerignore +1 -0
- package/template/saas-starter/.env.example +15 -15
- package/template/saas-starter/AGENTS.md +302 -0
- package/template/saas-starter/CLAUDE.md +1 -0
- package/template/saas-starter/README.md +124 -2
- package/template/saas-starter/bunfig.toml +3 -0
- package/template/saas-starter/eslint.config.mjs +6 -5
- package/template/saas-starter/gitignore +6 -1
- package/template/saas-starter/next.config.ts +19 -1
- package/template/saas-starter/package.json +49 -44
- package/template/saas-starter/public/logo-dark.svg +4 -0
- package/template/saas-starter/public/logo.svg +4 -0
- package/template/saas-starter/src/app/(admin)/actions/contact-leads.ts +51 -0
- package/template/saas-starter/src/app/(admin)/actions/feedbacks.ts +91 -0
- package/template/saas-starter/src/app/(admin)/actions/users.ts +145 -59
- package/template/saas-starter/src/app/(admin)/admin/_components/admin-header.tsx +4 -1
- package/template/saas-starter/src/app/(admin)/admin/_components/admin-sidebar.tsx +12 -10
- package/template/saas-starter/src/app/(admin)/admin/contact-leads/page.tsx +123 -0
- package/template/saas-starter/src/app/(admin)/admin/feedbacks/page.tsx +161 -0
- package/template/saas-starter/src/app/(admin)/admin/layout.tsx +24 -28
- package/template/saas-starter/src/app/(admin)/admin/page.tsx +59 -2
- package/template/saas-starter/src/app/(admin)/admin/settings/layout.tsx +24 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/[userId]/page.tsx +43 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/new/page.tsx +16 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/page.tsx +372 -10
- package/template/saas-starter/src/app/(admin)/admin/settings/users/user-form.tsx +138 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/validation.ts +23 -0
- package/template/saas-starter/src/app/(admin)/admin/support-tickets/[ticketId]/page.tsx +17 -0
- package/template/saas-starter/src/app/(admin)/admin/support-tickets/page.tsx +5 -0
- package/template/saas-starter/src/app/(app)/actions/billing.ts +171 -107
- package/template/saas-starter/src/app/(app)/actions/feedbacks.ts +28 -0
- package/template/saas-starter/src/app/(app)/actions/feedbacks.validation.ts +12 -0
- package/template/saas-starter/src/app/(app)/actions/members.ts +149 -123
- package/template/saas-starter/src/app/(app)/actions/organizations.ts +230 -0
- package/template/saas-starter/src/app/(app)/actions/organizations.validation.ts +17 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/dashboard/page.tsx +6 -9
- package/template/saas-starter/src/app/(app)/app/[orgId]/layout.tsx +6 -9
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/billing-email-form.tsx +45 -53
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/danger-zone.tsx +40 -47
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/general-settings-form.tsx +80 -105
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/plans-section.tsx +72 -82
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/billing/page.tsx +51 -52
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/layout.tsx +24 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/_components/invite-member-dialog.tsx +15 -16
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/_components/members-tabs.tsx +77 -44
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/page.tsx +11 -18
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/page.tsx +14 -28
- package/template/saas-starter/src/app/(app)/app/[orgId]/support-tickets/[ticketId]/page.tsx +25 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/support-tickets/page.tsx +25 -0
- package/template/saas-starter/src/app/(app)/app/_components/app-header.tsx +15 -13
- package/template/saas-starter/src/app/(app)/app/_components/app-search.tsx +15 -6
- package/template/saas-starter/src/app/(app)/app/_components/app-sidebar.tsx +6 -3
- package/template/saas-starter/src/app/(app)/app/_components/feedback-dialog.tsx +108 -0
- package/template/saas-starter/src/app/(app)/app/_components/organization-context.tsx +5 -9
- package/template/saas-starter/src/app/(app)/app/_components/organization-switcher.tsx +68 -8
- package/template/saas-starter/src/app/(app)/app/layout.tsx +44 -32
- package/template/saas-starter/src/app/(app)/app/onboarding/_components/create-organization-form.tsx +75 -87
- package/template/saas-starter/src/app/(app)/app/onboarding/page.tsx +10 -12
- package/template/saas-starter/src/app/(app)/app/page.tsx +16 -21
- package/template/saas-starter/src/app/(auth)/(account)/layout.tsx +64 -0
- package/template/saas-starter/src/app/(auth)/(account)/profile/page.tsx +16 -0
- package/template/saas-starter/src/app/(auth)/(account)/profile/profile-form.tsx +247 -0
- package/template/saas-starter/src/app/(auth)/(account)/support/[ticketId]/page.tsx +19 -0
- package/template/saas-starter/src/app/(auth)/(account)/support/page.tsx +9 -0
- package/template/saas-starter/src/app/(auth)/login/email-login-form.tsx +49 -27
- package/template/saas-starter/src/app/(auth)/login/page.tsx +39 -21
- package/template/saas-starter/src/app/(auth)/login/social-login-buttons.tsx +80 -18
- package/template/saas-starter/src/app/(invitation)/accept-invitation/[id]/accept-invitation-form.tsx +16 -10
- package/template/saas-starter/src/app/(invitation)/accept-invitation/[id]/page.tsx +28 -42
- package/template/saas-starter/src/app/(invitation)/actions/invitations.ts +32 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/actions.ts +23 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/contact-form.tsx +118 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/page.tsx +20 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/validation.ts +22 -0
- package/template/saas-starter/src/app/(marketing)/layout.tsx +38 -4
- package/template/saas-starter/src/app/(marketing)/legal.tsx +66 -0
- package/template/saas-starter/src/app/(marketing)/page.tsx +23 -2
- package/template/saas-starter/src/app/(marketing)/privacy/page.tsx +62 -2
- package/template/saas-starter/src/app/(marketing)/terms/page.tsx +40 -2
- package/template/saas-starter/src/app/actions/support-tickets.ts +510 -0
- package/template/saas-starter/src/app/actions/support-tickets.validation.ts +112 -0
- package/template/saas-starter/src/app/actions/uploads.ts +36 -0
- package/template/saas-starter/src/app/actions/uploads.validation.ts +24 -0
- package/template/saas-starter/src/app/error.tsx +37 -0
- package/template/saas-starter/src/app/fonts/geist-mono/GeistMono-Variable.woff2 +0 -0
- package/template/saas-starter/src/app/fonts/geist-sans/Geist-Variable.woff2 +0 -0
- package/template/saas-starter/src/app/fonts/index.ts +60 -0
- package/template/saas-starter/src/app/global-error.tsx +38 -0
- package/template/saas-starter/src/app/globals.css +29 -0
- package/template/saas-starter/src/app/layout.tsx +43 -19
- package/template/saas-starter/src/app/not-found.tsx +25 -3
- package/template/saas-starter/src/app/robots.ts +14 -10
- package/template/saas-starter/src/app/sitemap.ts +2 -1
- package/template/saas-starter/src/components/confirm-dialog.tsx +79 -0
- package/template/saas-starter/src/components/dashboard-header.tsx +7 -1
- package/template/saas-starter/src/components/data-table/features.ts +49 -0
- package/template/saas-starter/src/components/data-table/index.tsx +65 -64
- package/template/saas-starter/src/components/data-table/types.ts +5 -4
- package/template/saas-starter/src/components/error.tsx +45 -0
- package/template/saas-starter/src/components/file-upload.tsx +65 -26
- package/template/saas-starter/src/components/loader.tsx +18 -2
- package/template/saas-starter/src/components/logo.tsx +49 -0
- package/template/saas-starter/src/components/navigation-search.tsx +2 -2
- package/template/saas-starter/src/components/page-heading.tsx +6 -0
- package/template/saas-starter/src/components/react-query-provider.tsx +41 -2
- package/template/saas-starter/src/components/route-error.tsx +55 -0
- package/template/saas-starter/src/components/screen-size.tsx +36 -0
- package/template/saas-starter/src/components/site-footer.tsx +20 -4
- package/template/saas-starter/src/components/support/create-support-ticket-dialog.tsx +122 -0
- package/template/saas-starter/src/components/support/support-ticket-conversation.tsx +236 -0
- package/template/saas-starter/src/components/support/support-ticket-shared.tsx +58 -0
- package/template/saas-starter/src/components/support/support-tickets-table.tsx +281 -0
- package/template/saas-starter/src/components/theme-provider.tsx +48 -0
- package/template/saas-starter/src/components/theme-toggle.tsx +58 -5
- package/template/saas-starter/src/components/ui/alert-dialog.tsx +199 -0
- package/template/saas-starter/src/components/ui/badge.tsx +6 -1
- package/template/saas-starter/src/components/ui/button.tsx +2 -0
- package/template/saas-starter/src/components/ui/command.tsx +1 -1
- package/template/saas-starter/src/components/user-menu.tsx +147 -24
- package/template/saas-starter/src/db/common.ts +33 -1
- package/template/saas-starter/src/db/enums.ts +24 -0
- package/template/saas-starter/src/db/index.ts +14 -5
- package/template/saas-starter/src/db/relations.ts +40 -3
- package/template/saas-starter/src/db/schema.ts +186 -35
- package/template/saas-starter/src/emails/components/email-layout.tsx +27 -11
- package/template/saas-starter/src/emails/invitation.tsx +34 -21
- package/template/saas-starter/src/emails/magic-link.tsx +15 -13
- package/template/saas-starter/src/emails/test.tsx +11 -9
- package/template/saas-starter/src/emails/welcome.tsx +12 -9
- package/template/saas-starter/src/env.ts +1 -1
- package/template/saas-starter/src/hooks/use-mobile.ts +14 -12
- package/template/saas-starter/src/instrumentation.ts +20 -2
- package/template/saas-starter/src/lib/actions.ts +34 -0
- package/template/saas-starter/src/lib/admin-navigation.ts +33 -1
- package/template/saas-starter/src/lib/app-navigation.ts +45 -41
- package/template/saas-starter/src/lib/auth-client.ts +8 -3
- package/template/saas-starter/src/lib/auth-permissions.ts +50 -11
- package/template/saas-starter/src/lib/auth.ts +122 -21
- package/template/saas-starter/src/lib/billing.ts +59 -24
- package/template/saas-starter/src/lib/callback-url.ts +28 -0
- package/template/saas-starter/src/lib/constants.ts +78 -9
- package/template/saas-starter/src/lib/delay.ts +10 -0
- package/template/saas-starter/src/lib/email-service.ts +30 -1
- package/template/saas-starter/src/lib/errors.ts +74 -0
- package/template/saas-starter/src/lib/format-currency.ts +22 -24
- package/template/saas-starter/src/lib/format-date.ts +69 -6
- package/template/saas-starter/src/lib/image-url.ts +54 -0
- package/template/saas-starter/src/lib/nodemailer.ts +27 -3
- package/template/saas-starter/src/lib/organization-access.ts +56 -76
- package/template/saas-starter/src/lib/otel.ts +92 -2
- package/template/saas-starter/src/lib/plan-limits.ts +37 -0
- package/template/saas-starter/src/lib/plans.ts +40 -13
- package/template/saas-starter/src/lib/rbac.ts +44 -0
- package/template/saas-starter/src/lib/safe-action-client.ts +60 -9
- package/template/saas-starter/src/lib/safe-action.ts +137 -17
- package/template/saas-starter/src/lib/search.ts +16 -0
- package/template/saas-starter/src/lib/seo.ts +7 -0
- package/template/saas-starter/src/lib/siteConfig.ts +17 -1
- package/template/saas-starter/src/lib/storage.ts +176 -46
- package/template/saas-starter/src/lib/stripe.ts +4 -1
- package/template/saas-starter/src/lib/toast-message.ts +87 -1
- package/template/saas-starter/src/lib/validations.ts +85 -2
- package/template/saas-starter/src/proxy.ts +48 -0
- package/template/saas-starter/src/scripts/cleanup-temp-uploads.ts +24 -0
- package/template/saas-starter/src/scripts/seed.ts +82 -8
- package/template/saas-starter/src/scripts/setup-db.ts +72 -0
- package/template/saas-starter/src/scripts/setup-stripe-plans.ts +13 -7
- package/template/saas-starter/src/scripts/test-mail.ts +28 -20
- package/template/saas-starter/tests/admin/users.test.ts +64 -0
- package/template/saas-starter/tests/db/fk-indexes.test.ts +62 -0
- package/template/saas-starter/tests/db/seed.test.ts +57 -0
- package/template/saas-starter/tests/helpers/action.ts +71 -0
- package/template/saas-starter/tests/helpers/fixtures.ts +151 -0
- package/template/saas-starter/tests/helpers/index.ts +2 -0
- package/template/saas-starter/tests/lib/callback-url.test.ts +48 -0
- package/template/saas-starter/tests/lib/client-server-boundary.test.ts +57 -0
- package/template/saas-starter/tests/lib/errors.test.ts +10 -0
- package/template/saas-starter/tests/lib/image-url.test.ts +31 -0
- package/template/saas-starter/tests/lib/search.test.ts +23 -0
- package/template/saas-starter/tests/marketing/contact-and-feedback.test.ts +86 -0
- package/template/saas-starter/tests/organizations/organizations.test.ts +175 -0
- package/template/saas-starter/tests/setup/pglite-db.ts +67 -0
- package/template/saas-starter/tests/setup/preload.ts +108 -0
- package/template/saas-starter/tests/support/support-tickets.test.ts +145 -0
- package/template/saas-starter/tsconfig.json +1 -0
- package/cli.js +0 -147
- package/template/nextjs/src/app/(admin)/layout.tsx +0 -20
- package/template/nextjs/src/app/(app)/layout.tsx +0 -20
- package/template/nextjs/terraform/artifact-registry.tf +0 -5
- package/template/nextjs/terraform/backend-service.tf +0 -13
- package/template/nextjs/terraform/cleanup.sh +0 -9
- package/template/nextjs/terraform/cloudbuild.tf +0 -70
- package/template/nextjs/terraform/cloudrun.tf +0 -68
- package/template/nextjs/terraform/database.tf +0 -60
- package/template/nextjs/terraform/forwarding-rule.tf +0 -43
- package/template/nextjs/terraform/gitignore +0 -4
- package/template/nextjs/terraform/ip-address.tf +0 -11
- package/template/nextjs/terraform/network-endpoint-group.tf +0 -11
- package/template/nextjs/terraform/network.tf +0 -21
- package/template/nextjs/terraform/pre.sh +0 -3
- package/template/nextjs/terraform/providers.tf +0 -18
- package/template/nextjs/terraform/secret.txt +0 -11
- package/template/nextjs/terraform/setup.sh +0 -25
- package/template/nextjs/terraform/ssl-certs.tf +0 -32
- package/template/nextjs/terraform/target-https-proxy copy.tf +0 -14
- package/template/nextjs/terraform/target-https-proxy.tf +0 -14
- package/template/nextjs/terraform/terraform.tfvars +0 -4
- package/template/nextjs/terraform/url-map.tf +0 -23
- package/template/nextjs/terraform/variables.tf +0 -21
- package/template/saas-starter/next-env.d.ts +0 -6
- package/template/saas-starter/src/actions/uploads.ts +0 -28
- package/template/saas-starter/src/actions/uploads.validation.ts +0 -14
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/create-user-dialog.tsx +0 -183
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/edit-name-dialog.tsx +0 -129
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/users-table.tsx +0 -415
- package/template/saas-starter/src/app/(app)/actions/organization.ts +0 -92
- package/template/saas-starter/src/app/proxy.ts +0 -28
- package/template/saas-starter/src/components/impersonation-banner.tsx +0 -44
- package/template/saas-starter/src/lib/organization-plan-limits.ts +0 -38
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun test preload (runs before every test file and worker).
|
|
3
|
+
*
|
|
4
|
+
* - In-memory PGlite Postgres (WASM) through a `~/db` mock
|
|
5
|
+
* - R2 env cleared, so storage stays in base64 dev mode (no bucket I/O)
|
|
6
|
+
* - `react.cache` becomes identity
|
|
7
|
+
* - `getAuthSession` reads an AsyncLocalStorage (parallel-safe)
|
|
8
|
+
*
|
|
9
|
+
* Set `TEST_DATABASE=postgres` to use the real `DATABASE_URL` instead.
|
|
10
|
+
*/
|
|
11
|
+
import { mock } from 'bun:test'
|
|
12
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
13
|
+
import { createRequire } from 'node:module'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
|
|
16
|
+
// Bun loads `.env` before preload, so unsetting these is not enough: empty
|
|
17
|
+
// strings become undefined through `emptyStringAsUndefined` in ~/env.
|
|
18
|
+
for (const key of [
|
|
19
|
+
'R2_ACCOUNT_ID',
|
|
20
|
+
'R2_ACCESS_KEY_ID',
|
|
21
|
+
'R2_SECRET_ACCESS_KEY',
|
|
22
|
+
'R2_BUCKET_NAME',
|
|
23
|
+
'R2_PUBLIC_URL'
|
|
24
|
+
] as const) {
|
|
25
|
+
process.env[key] = ''
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Bun does not set the `react-server` export condition, so the real
|
|
29
|
+
// `server-only` package throws. Next.js client builds still fail on it.
|
|
30
|
+
mock.module('server-only', () => ({}))
|
|
31
|
+
|
|
32
|
+
// `start()` needs the Workflow runtime. Tests only need fire-and-forget
|
|
33
|
+
// side effects such as emails to no-op.
|
|
34
|
+
mock.module('workflow/api', () => ({
|
|
35
|
+
start: async () => ({ runId: 'test-workflow-run' })
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Database: PGlite (default) or real Postgres
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
process.env.TEST_DATABASE ??= 'pglite'
|
|
43
|
+
|
|
44
|
+
if (process.env.TEST_DATABASE === 'pglite') {
|
|
45
|
+
// ~/env requires a URL even though PGlite never connects to it.
|
|
46
|
+
process.env.DATABASE_URL ??= 'postgres://pglite.local/test'
|
|
47
|
+
|
|
48
|
+
const { initPgliteDatabase } = await import('./pglite-db')
|
|
49
|
+
const dbModule = { db: await initPgliteDatabase() }
|
|
50
|
+
|
|
51
|
+
mock.module('~/db', () => dbModule)
|
|
52
|
+
mock.module(
|
|
53
|
+
path.resolve(import.meta.dir, '../../src/db/index.ts'),
|
|
54
|
+
() => dbModule
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Auth and request headers
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
type MockAuthSession = {
|
|
63
|
+
user: { id: string; email: string; name: string; role?: string | null }
|
|
64
|
+
session: { id: string; userId: string; impersonatedBy?: string | null }
|
|
65
|
+
isAdmin: boolean
|
|
66
|
+
isSuperAdmin: boolean
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const authAls = new AsyncLocalStorage<MockAuthSession | null>()
|
|
70
|
+
|
|
71
|
+
/** Runs `fn` with `getAuthSession()` returning `session`. */
|
|
72
|
+
export function runWithAuthSession<T>(
|
|
73
|
+
session: MockAuthSession | null,
|
|
74
|
+
fn: () => Promise<T>
|
|
75
|
+
): Promise<T> {
|
|
76
|
+
return authAls.run(session, fn)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const require = createRequire(import.meta.url)
|
|
80
|
+
const React = require('react') as typeof import('react')
|
|
81
|
+
|
|
82
|
+
mock.module('react', () => ({
|
|
83
|
+
...React,
|
|
84
|
+
default: React,
|
|
85
|
+
cache: <T extends (...args: never[]) => unknown>(fn: T) => fn
|
|
86
|
+
}))
|
|
87
|
+
|
|
88
|
+
const authModuleMock = {
|
|
89
|
+
getAuthSession: async () => authAls.getStore() ?? null,
|
|
90
|
+
auth: null as unknown
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
mock.module('~/lib/auth', () => authModuleMock)
|
|
94
|
+
mock.module(
|
|
95
|
+
path.resolve(import.meta.dir, '../../src/lib/auth.ts'),
|
|
96
|
+
() => authModuleMock
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
mock.module('next/headers', () => ({
|
|
100
|
+
headers: async () => new Headers(),
|
|
101
|
+
cookies: async () => ({
|
|
102
|
+
get: () => undefined,
|
|
103
|
+
getAll: () => [],
|
|
104
|
+
has: () => false,
|
|
105
|
+
set: () => {},
|
|
106
|
+
delete: () => {}
|
|
107
|
+
})
|
|
108
|
+
}))
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test'
|
|
2
|
+
import {
|
|
3
|
+
addSupportTicketMessageAction,
|
|
4
|
+
createSupportTicketAction,
|
|
5
|
+
getAdminSupportTicketsAction,
|
|
6
|
+
getMyAccountSupportTicketsAction,
|
|
7
|
+
getOrganizationSupportTicketsAction,
|
|
8
|
+
getSupportTicketDetailsAction,
|
|
9
|
+
updateSupportTicketStatusAction
|
|
10
|
+
} from '~/app/actions/support-tickets'
|
|
11
|
+
import { asUser, expectData, expectServerError, Fixtures } from '../helpers'
|
|
12
|
+
|
|
13
|
+
describe('support tickets', () => {
|
|
14
|
+
const fx = new Fixtures()
|
|
15
|
+
afterEach(() => fx.cleanup())
|
|
16
|
+
|
|
17
|
+
test('organization tickets are shared by managers and hidden from members', async () => {
|
|
18
|
+
const ws = await fx.workspace()
|
|
19
|
+
|
|
20
|
+
const created = await asUser(ws.owner, () =>
|
|
21
|
+
createSupportTicketAction({
|
|
22
|
+
organizationId: ws.organization.id,
|
|
23
|
+
subject: 'Invoices are missing',
|
|
24
|
+
priority: 'high',
|
|
25
|
+
message: 'Last month has no invoice.'
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
expectData(created)
|
|
29
|
+
expect(created.data.ticketNumber).toMatch(/^TICKET-\d{6}$/)
|
|
30
|
+
|
|
31
|
+
const asAdmin = await asUser(ws.admin, () =>
|
|
32
|
+
getSupportTicketDetailsAction({ ticketId: created.data.id })
|
|
33
|
+
)
|
|
34
|
+
expectData(asAdmin)
|
|
35
|
+
|
|
36
|
+
const asMember = await asUser(ws.member, () =>
|
|
37
|
+
getSupportTicketDetailsAction({ ticketId: created.data.id })
|
|
38
|
+
)
|
|
39
|
+
expectServerError(asMember, 'permission')
|
|
40
|
+
|
|
41
|
+
const memberList = await asUser(ws.member, () =>
|
|
42
|
+
getOrganizationSupportTicketsAction({
|
|
43
|
+
organizationId: ws.organization.id,
|
|
44
|
+
page: 1,
|
|
45
|
+
limit: 10
|
|
46
|
+
})
|
|
47
|
+
)
|
|
48
|
+
expectServerError(memberList, 'permission')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('account tickets belong to their author alone', async () => {
|
|
52
|
+
const author = await fx.user()
|
|
53
|
+
const other = await fx.user()
|
|
54
|
+
|
|
55
|
+
const created = await asUser(author, () =>
|
|
56
|
+
createSupportTicketAction({
|
|
57
|
+
subject: 'Change my email',
|
|
58
|
+
message: 'I need a new sign-in address.'
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
expectData(created)
|
|
62
|
+
|
|
63
|
+
const mine = await asUser(author, () =>
|
|
64
|
+
getMyAccountSupportTicketsAction({ page: 1, limit: 10 })
|
|
65
|
+
)
|
|
66
|
+
expectData(mine)
|
|
67
|
+
expect(mine.data[0].map(ticket => ticket.id)).toContain(created.data.id)
|
|
68
|
+
|
|
69
|
+
const theirs = await asUser(other, () =>
|
|
70
|
+
getSupportTicketDetailsAction({ ticketId: created.data.id })
|
|
71
|
+
)
|
|
72
|
+
expectServerError(theirs, 'permission')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('an admin replying from their own ticket page counts as the customer', async () => {
|
|
76
|
+
const admin = await fx.platformUser('admin')
|
|
77
|
+
|
|
78
|
+
const created = await asUser(admin, () =>
|
|
79
|
+
createSupportTicketAction({
|
|
80
|
+
subject: 'My own account',
|
|
81
|
+
message: 'Testing the customer view.'
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
expectData(created)
|
|
85
|
+
|
|
86
|
+
const reply = await asUser(admin, () =>
|
|
87
|
+
addSupportTicketMessageAction({
|
|
88
|
+
ticketId: created.data.id,
|
|
89
|
+
message: 'Adding detail as the customer.'
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
expectData(reply)
|
|
93
|
+
expect(reply.data?.isAdmin).toBe(false)
|
|
94
|
+
|
|
95
|
+
const asSupport = await asUser(admin, () =>
|
|
96
|
+
addSupportTicketMessageAction({
|
|
97
|
+
ticketId: created.data.id,
|
|
98
|
+
message: 'Replying as support.',
|
|
99
|
+
asSupport: true
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
expectData(asSupport)
|
|
103
|
+
expect(asSupport.data?.isAdmin).toBe(true)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('only platform admins list every ticket and change status', async () => {
|
|
107
|
+
const author = await fx.user()
|
|
108
|
+
const admin = await fx.platformUser('admin')
|
|
109
|
+
|
|
110
|
+
const created = await asUser(author, () =>
|
|
111
|
+
createSupportTicketAction({
|
|
112
|
+
subject: 'Billing question',
|
|
113
|
+
message: 'Which plan fits a team of 10?'
|
|
114
|
+
})
|
|
115
|
+
)
|
|
116
|
+
expectData(created)
|
|
117
|
+
|
|
118
|
+
const denied = await asUser(author, () =>
|
|
119
|
+
getAdminSupportTicketsAction({ page: 1, limit: 10 })
|
|
120
|
+
)
|
|
121
|
+
expectServerError(denied, 'permission')
|
|
122
|
+
|
|
123
|
+
const list = await asUser(admin, () =>
|
|
124
|
+
getAdminSupportTicketsAction({ page: 1, limit: 50 })
|
|
125
|
+
)
|
|
126
|
+
expectData(list)
|
|
127
|
+
expect(list.data[0].map(ticket => ticket.id)).toContain(created.data.id)
|
|
128
|
+
|
|
129
|
+
const closed = await asUser(admin, () =>
|
|
130
|
+
updateSupportTicketStatusAction({
|
|
131
|
+
ticketId: created.data.id,
|
|
132
|
+
status: 'closed'
|
|
133
|
+
})
|
|
134
|
+
)
|
|
135
|
+
expectData(closed)
|
|
136
|
+
|
|
137
|
+
const reply = await asUser(author, () =>
|
|
138
|
+
addSupportTicketMessageAction({
|
|
139
|
+
ticketId: created.data.id,
|
|
140
|
+
message: 'One more thing.'
|
|
141
|
+
})
|
|
142
|
+
)
|
|
143
|
+
expectServerError(reply, 'closed')
|
|
144
|
+
})
|
|
145
|
+
})
|
package/cli.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
import { program } from 'commander';
|
|
4
|
-
import enquirer from 'enquirer';
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const detectPackageManager = () => {
|
|
10
|
-
const userAgent = process.env.npm_config_user_agent;
|
|
11
|
-
if (userAgent) {
|
|
12
|
-
if (userAgent.startsWith('pnpm'))
|
|
13
|
-
return 'pnpm';
|
|
14
|
-
if (userAgent.startsWith('yarn'))
|
|
15
|
-
return 'yarn';
|
|
16
|
-
if (userAgent.startsWith('bun'))
|
|
17
|
-
return 'bun';
|
|
18
|
-
}
|
|
19
|
-
return 'npm';
|
|
20
|
-
};
|
|
21
|
-
const getInstallCommand = (packageManager) => {
|
|
22
|
-
switch (packageManager) {
|
|
23
|
-
case 'pnpm':
|
|
24
|
-
return 'pnpm i';
|
|
25
|
-
case 'yarn':
|
|
26
|
-
return 'yarn';
|
|
27
|
-
case 'bun':
|
|
28
|
-
return 'bun i';
|
|
29
|
-
default:
|
|
30
|
-
return 'npm i';
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const getDevCommand = (packageManager) => {
|
|
34
|
-
switch (packageManager) {
|
|
35
|
-
case 'pnpm':
|
|
36
|
-
return 'pnpm dev';
|
|
37
|
-
case 'yarn':
|
|
38
|
-
return 'yarn dev';
|
|
39
|
-
case 'bun':
|
|
40
|
-
return 'bun dev';
|
|
41
|
-
default:
|
|
42
|
-
return 'npm run dev';
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
program.action(async () => {
|
|
46
|
-
const response = await enquirer.prompt([
|
|
47
|
-
{
|
|
48
|
-
type: 'input',
|
|
49
|
-
name: 'projectName',
|
|
50
|
-
message: 'Enter the project name:',
|
|
51
|
-
initial: 'my-project'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: 'input',
|
|
55
|
-
name: 'description',
|
|
56
|
-
message: 'Enter a description for the project:',
|
|
57
|
-
initial: 'A Legendary Project'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: 'select',
|
|
61
|
-
name: 'template',
|
|
62
|
-
message: 'Select a template:',
|
|
63
|
-
choices: [
|
|
64
|
-
{
|
|
65
|
-
name: 'nextjs',
|
|
66
|
-
message: 'Full Stack setup with Next 16, Better Auth, shadcn and Drizzle'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'saas-starter',
|
|
70
|
-
message: 'SaaS Starter with Stripe, Next 16, Better Auth, shadcn and Drizzle'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'api',
|
|
74
|
-
message: 'API Server setup with Elysia, Drizzle, Typescript'
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
type: 'select',
|
|
80
|
-
name: 'git',
|
|
81
|
-
message: 'Initialize a git repository?',
|
|
82
|
-
choices: ['yes', 'no']
|
|
83
|
-
}
|
|
84
|
-
]);
|
|
85
|
-
const { projectName, description, template, git } = response;
|
|
86
|
-
const projectDir = path.join(process.cwd(), projectName);
|
|
87
|
-
if (fs.existsSync(projectDir)) {
|
|
88
|
-
console.error(`Error: Directory '${projectName}' already exists.`);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
fs.mkdirSync(projectDir);
|
|
92
|
-
const templateDir = path.join(__dirname, 'template', template);
|
|
93
|
-
fs.cpSync(templateDir, projectDir, { recursive: true });
|
|
94
|
-
const renameGitignore = (dir) => {
|
|
95
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
96
|
-
const fullPath = path.join(dir, entry.name);
|
|
97
|
-
if (entry.isDirectory()) {
|
|
98
|
-
renameGitignore(fullPath);
|
|
99
|
-
}
|
|
100
|
-
else if (entry.name === 'gitignore') {
|
|
101
|
-
fs.renameSync(fullPath, path.join(dir, '.gitignore'));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
renameGitignore(projectDir);
|
|
106
|
-
const packageJsonFile = path.join(projectDir, 'package.json');
|
|
107
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, 'utf-8'));
|
|
108
|
-
packageJson.name = projectName;
|
|
109
|
-
packageJson.description = description;
|
|
110
|
-
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
|
111
|
-
const envExampleFile = path.join(projectDir, '.env.example');
|
|
112
|
-
const envExample = fs.readFileSync(envExampleFile, 'utf-8');
|
|
113
|
-
fs.writeFileSync(path.join(projectDir, '.env'), envExample);
|
|
114
|
-
fs.writeFileSync(path.join(projectDir, 'README.md'), `# ${projectName}
|
|
115
|
-
|
|
116
|
-
${description}
|
|
117
|
-
`);
|
|
118
|
-
if (git === 'yes') {
|
|
119
|
-
try {
|
|
120
|
-
execSync('git init', { cwd: projectDir, stdio: 'inherit' });
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
console.error('Error initializing git repository:', err);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const pm = detectPackageManager();
|
|
127
|
-
const installCommand = getInstallCommand(pm);
|
|
128
|
-
const devCommand = getDevCommand(pm);
|
|
129
|
-
console.log(`
|
|
130
|
-
Created a new app called '${projectName}' 🎉
|
|
131
|
-
|
|
132
|
-
To open the project in vscode run:
|
|
133
|
-
|
|
134
|
-
code ${projectName}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
To get started, run the following commands:
|
|
138
|
-
cd ${projectName}
|
|
139
|
-
|
|
140
|
-
${installCommand}
|
|
141
|
-
|
|
142
|
-
${devCommand}
|
|
143
|
-
|
|
144
|
-
Happy coding! 🚀
|
|
145
|
-
`);
|
|
146
|
-
});
|
|
147
|
-
program.parse(process.argv);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { notFound } from 'next/navigation'
|
|
2
|
-
import { getAuthSession } from '~/lib/auth'
|
|
3
|
-
|
|
4
|
-
export default async function Layout({
|
|
5
|
-
children
|
|
6
|
-
}: Readonly<{
|
|
7
|
-
children: React.ReactNode
|
|
8
|
-
}>) {
|
|
9
|
-
const authSession = await getAuthSession()
|
|
10
|
-
|
|
11
|
-
if (!authSession?.isAdmin) {
|
|
12
|
-
return notFound()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div className="flex min-h-screen flex-col space-y-4">
|
|
17
|
-
<main className="flex-1">{children}</main>
|
|
18
|
-
</div>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { redirect } from 'next/navigation'
|
|
2
|
-
import { getAuthSession } from '~/lib/auth'
|
|
3
|
-
|
|
4
|
-
export default async function Layout({
|
|
5
|
-
children
|
|
6
|
-
}: Readonly<{
|
|
7
|
-
children: React.ReactNode
|
|
8
|
-
}>) {
|
|
9
|
-
const authSession = await getAuthSession()
|
|
10
|
-
|
|
11
|
-
if (!authSession) {
|
|
12
|
-
return redirect('/login')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div className="flex min-h-screen flex-col space-y-4">
|
|
17
|
-
<main className="flex-1">{children}</main>
|
|
18
|
-
</div>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
resource "google_compute_backend_service" "my_app_prod_service" {
|
|
2
|
-
name = "my-app-prod-service"
|
|
3
|
-
|
|
4
|
-
backend {
|
|
5
|
-
group = google_compute_region_network_endpoint_group.my_app_prod_neg.id
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
protocol = "HTTPS"
|
|
9
|
-
locality_lb_policy = "ROUND_ROBIN"
|
|
10
|
-
load_balancing_scheme = "EXTERNAL_MANAGED"
|
|
11
|
-
|
|
12
|
-
depends_on = [google_compute_region_network_endpoint_group.my_app_prod_neg]
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
gcloud run revisions list \
|
|
2
|
-
--region=us-central1 \
|
|
3
|
-
--format=json | \
|
|
4
|
-
jq -r '.[] | select(.status.conditions[] | select(.type == "Active" and .status != "True")) | .metadata.name' | \
|
|
5
|
-
sort -u | \
|
|
6
|
-
xargs -I {} gcloud run revisions delete {} \
|
|
7
|
-
--region=us-central1 --quiet
|
|
8
|
-
|
|
9
|
-
gcloud artifacts docker images list us-docker.pkg.dev/project-id/github/my-app --format=json --include-tags | jq -r '.[] | select((.tags // []) as $tags | ($tags | index("main") // -1) == -1 and ($tags | index("dev") // -1) == -1) | .version' | while read -r digest; do echo "Deleting image with digest: $digest"; gcloud artifacts docker images delete us-docker.pkg.dev/project-id/github/my-app@$digest --delete-tags --quiet || true; done
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
resource "google_cloudbuild_trigger" "my_app_main_build_trigger" {
|
|
2
|
-
name = "my-app-main-build-trigger"
|
|
3
|
-
description = "Build trigger for My App"
|
|
4
|
-
location = "global"
|
|
5
|
-
include_build_logs = "INCLUDE_BUILD_LOGS_WITH_STATUS"
|
|
6
|
-
disabled = false
|
|
7
|
-
|
|
8
|
-
github {
|
|
9
|
-
owner = "github-username"
|
|
10
|
-
name = "my-app"
|
|
11
|
-
push {
|
|
12
|
-
branch = "^main$"
|
|
13
|
-
invert_regex = false
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
substitutions = {
|
|
18
|
-
_IMAGE_REGION = "us-docker.pkg.dev"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
service_account = "projects/${var.project}/serviceAccounts/${var.compute_service_account}"
|
|
22
|
-
|
|
23
|
-
build {
|
|
24
|
-
timeout = "600s"
|
|
25
|
-
step {
|
|
26
|
-
name = "gcr.io/cloud-builders/docker"
|
|
27
|
-
args = [
|
|
28
|
-
"build",
|
|
29
|
-
"-t",
|
|
30
|
-
"$${_IMAGE_REGION}/$${PROJECT_ID}/github/my-app:$${COMMIT_SHA}",
|
|
31
|
-
"-t",
|
|
32
|
-
"$${_IMAGE_REGION}/$${PROJECT_ID}/github/my-app:main",
|
|
33
|
-
"."
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
step {
|
|
38
|
-
name = "gcr.io/cloud-builders/docker"
|
|
39
|
-
args = [
|
|
40
|
-
"push",
|
|
41
|
-
"$${_IMAGE_REGION}/$${PROJECT_ID}/github/my-app:$${COMMIT_SHA}"
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
step {
|
|
46
|
-
name = "gcr.io/cloud-builders/docker"
|
|
47
|
-
args = [
|
|
48
|
-
"push",
|
|
49
|
-
"$${_IMAGE_REGION}/$${PROJECT_ID}/github/my-app:main"
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
step {
|
|
54
|
-
name = "gcr.io/cloud-builders/gcloud"
|
|
55
|
-
args = [
|
|
56
|
-
"run",
|
|
57
|
-
"deploy",
|
|
58
|
-
"my-app-prod",
|
|
59
|
-
"--image",
|
|
60
|
-
"$${_IMAGE_REGION}/$${PROJECT_ID}/github/my-app:$${COMMIT_SHA}",
|
|
61
|
-
"--region",
|
|
62
|
-
var.region
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
options {
|
|
67
|
-
logging = "CLOUD_LOGGING_ONLY"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
resource "google_cloud_run_v2_service" "my_app_prod" {
|
|
2
|
-
name = "my-app-prod"
|
|
3
|
-
location = var.region
|
|
4
|
-
ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER"
|
|
5
|
-
|
|
6
|
-
scaling {
|
|
7
|
-
max_instance_count = 1
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
template {
|
|
11
|
-
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"
|
|
12
|
-
service_account = var.compute_service_account
|
|
13
|
-
max_instance_request_concurrency = 80
|
|
14
|
-
|
|
15
|
-
vpc_access {
|
|
16
|
-
network_interfaces {
|
|
17
|
-
network = google_compute_network.vpc_network.name
|
|
18
|
-
subnetwork = google_compute_network.vpc_network.name
|
|
19
|
-
}
|
|
20
|
-
egress = "PRIVATE_RANGES_ONLY"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
containers {
|
|
24
|
-
name = "my-app-prod-1"
|
|
25
|
-
image = "us-docker.pkg.dev/${var.project}/github/my-app:main"
|
|
26
|
-
|
|
27
|
-
ports {
|
|
28
|
-
container_port = 3000
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
resources {
|
|
32
|
-
limits = {
|
|
33
|
-
cpu = "1000m"
|
|
34
|
-
memory = "1Gi"
|
|
35
|
-
}
|
|
36
|
-
cpu_idle = true # Set to false when using workflow
|
|
37
|
-
startup_cpu_boost = true
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
env {
|
|
41
|
-
name = "APP_ENV"
|
|
42
|
-
value = "production"
|
|
43
|
-
}
|
|
44
|
-
env {
|
|
45
|
-
name = "DATABASE_URL"
|
|
46
|
-
value_source {
|
|
47
|
-
secret_key_ref {
|
|
48
|
-
secret = "PROD_DATABASE_URL"
|
|
49
|
-
version = "latest"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Add rest of env variables as needed
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
depends_on = [google_sql_database.prod_db]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
resource "google_cloud_run_service_iam_member" "my_app_prod_unauthenticated" {
|
|
62
|
-
location = google_cloud_run_v2_service.my_app_prod.location
|
|
63
|
-
service = google_cloud_run_v2_service.my_app_prod.name
|
|
64
|
-
role = "roles/run.invoker"
|
|
65
|
-
member = "allUsers"
|
|
66
|
-
|
|
67
|
-
depends_on = [google_cloud_run_v2_service.my_app_prod]
|
|
68
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
resource "google_sql_database_instance" "prod_postgres_instance" {
|
|
2
|
-
name = "prod-db"
|
|
3
|
-
database_version = "POSTGRES_17"
|
|
4
|
-
|
|
5
|
-
settings {
|
|
6
|
-
location_preference {
|
|
7
|
-
zone = var.zone
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
edition = "ENTERPRISE"
|
|
11
|
-
tier = "db-f1-micro"
|
|
12
|
-
deletion_protection_enabled = true
|
|
13
|
-
|
|
14
|
-
disk_size = 10
|
|
15
|
-
disk_autoresize = true
|
|
16
|
-
retain_backups_on_delete = true
|
|
17
|
-
|
|
18
|
-
backup_configuration {
|
|
19
|
-
enabled = true
|
|
20
|
-
start_time = "00:00"
|
|
21
|
-
point_in_time_recovery_enabled = true
|
|
22
|
-
backup_retention_settings {
|
|
23
|
-
retained_backups = 30
|
|
24
|
-
}
|
|
25
|
-
transaction_log_retention_days = 7
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
ip_configuration {
|
|
29
|
-
private_network = google_compute_network.vpc_network.self_link
|
|
30
|
-
ipv4_enabled = true
|
|
31
|
-
authorized_networks {
|
|
32
|
-
value = "103.53.75.58"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
insights_config {
|
|
37
|
-
query_insights_enabled = true
|
|
38
|
-
record_client_address = true
|
|
39
|
-
record_application_tags = true
|
|
40
|
-
query_string_length = 4096
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
lifecycle {
|
|
45
|
-
prevent_destroy = true
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
depends_on = [google_service_networking_connection.private_connection]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
resource "google_sql_database" "prod_db" {
|
|
52
|
-
name = "prod_database"
|
|
53
|
-
instance = google_sql_database_instance.prod_postgres_instance.name
|
|
54
|
-
|
|
55
|
-
lifecycle {
|
|
56
|
-
prevent_destroy = true
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
depends_on = [google_sql_database_instance.prod_postgres_instance]
|
|
60
|
-
}
|