create-ej-app 6.0.0 → 8.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/cli.js +88 -14
- package/cli.ts +100 -17
- package/package.json +2 -2
- package/template/base/.env.example +11 -15
- package/template/base/Dockerfile +15 -0
- package/template/base/components.json +10 -5
- package/template/base/drizzle.config.ts +4 -5
- package/template/{new → base}/eslint.config.mjs +6 -1
- package/template/base/package.json +58 -75
- package/template/base/postcss.config.mjs +1 -4
- package/template/base/src/app/(admin)/layout.tsx +20 -0
- package/template/base/src/app/(app)/layout.tsx +13 -118
- package/template/base/src/app/(auth)/login/page.tsx +65 -42
- package/template/base/src/app/(marketing)/layout.tsx +7 -35
- package/template/base/src/app/(marketing)/page.tsx +2 -96
- package/template/base/src/app/(marketing)/privacy/page.tsx +3 -0
- package/template/base/src/app/(marketing)/terms/page.tsx +3 -0
- package/template/base/src/app/globals.css +118 -66
- package/template/base/src/app/layout.tsx +27 -12
- package/template/base/src/app/not-found.tsx +27 -0
- package/template/base/src/components/site-footer.tsx +16 -24
- package/template/base/src/components/ui/button.tsx +31 -27
- package/template/base/src/components/ui/card.tsx +83 -70
- package/template/base/src/components/ui/form.tsx +38 -47
- package/template/base/src/components/ui/input.tsx +16 -20
- package/template/base/src/components/ui/label.tsx +16 -18
- package/template/base/src/components/ui/separator.tsx +11 -14
- package/template/base/src/components/ui/sonner.tsx +22 -13
- package/template/base/src/db/index.ts +4 -11
- package/template/base/src/db/schema.ts +60 -268
- package/template/{new → base}/src/env.ts +2 -2
- package/template/{new → base}/src/lib/auth-client.ts +2 -0
- package/template/base/src/lib/auth.ts +64 -80
- package/template/base/src/lib/safe-action.ts +30 -6
- package/template/base/tsconfig.json +9 -7
- package/template/{prisma-advanced → old}/.env.example +10 -9
- package/template/{prisma → old}/components.json +1 -1
- package/template/old/drizzle.config.ts +11 -0
- package/template/old/package.json +87 -0
- package/template/old/postcss.config.mjs +8 -0
- package/template/{prisma-advanced → old}/src/app/(app)/layout.tsx +11 -3
- package/template/{prisma-advanced → old}/src/app/(auth)/login/page.tsx +2 -2
- package/template/{prisma → old}/src/app/(marketing)/page.tsx +8 -7
- package/template/old/src/app/layout.tsx +31 -0
- package/template/old/src/components/ui/sonner.tsx +31 -0
- package/template/old/src/db/index.ts +14 -0
- package/template/old/src/db/schema.ts +287 -0
- package/template/old/src/lib/auth.ts +89 -0
- package/template/old/src/lib/safe-action.ts +19 -0
- package/template/{prisma-advanced → old}/tsconfig.json +3 -2
- package/template/new/.env.example +0 -13
- package/template/new/components.json +0 -22
- package/template/new/drizzle.config.ts +0 -10
- package/template/new/package.json +0 -81
- package/template/new/postcss.config.mjs +0 -5
- package/template/new/src/app/(auth)/login/page.tsx +0 -72
- package/template/new/src/app/globals.css +0 -128
- package/template/new/src/app/layout.tsx +0 -50
- package/template/new/src/app/page.tsx +0 -3
- package/template/new/src/components/ui/button.tsx +0 -60
- package/template/new/src/components/ui/card.tsx +0 -92
- package/template/new/src/components/ui/form.tsx +0 -167
- package/template/new/src/components/ui/input.tsx +0 -21
- package/template/new/src/components/ui/label.tsx +0 -24
- package/template/new/src/components/ui/separator.tsx +0 -28
- package/template/new/src/components/ui/sonner.tsx +0 -40
- package/template/new/src/db/index.ts +0 -7
- package/template/new/src/db/schema.ts +0 -74
- package/template/new/src/lib/auth.ts +0 -67
- package/template/new/src/lib/safe-action.ts +0 -15
- package/template/new/tsconfig.json +0 -49
- package/template/prisma/.env.example +0 -16
- package/template/prisma/.eslintrc.cjs +0 -24
- package/template/prisma/next.config.mjs +0 -15
- package/template/prisma/package.json +0 -80
- package/template/prisma/postcss.config.cjs +0 -6
- package/template/prisma/prettier.config.ts +0 -11
- package/template/prisma/prisma/schema.prisma +0 -115
- package/template/prisma/public/next.svg +0 -1
- package/template/prisma/src/app/(app)/dashboard/page.tsx +0 -19
- package/template/prisma/src/app/(app)/layout.tsx +0 -90
- package/template/prisma/src/app/(app)/settings/actions.ts +0 -18
- package/template/prisma/src/app/(app)/settings/loading.tsx +0 -28
- package/template/prisma/src/app/(app)/settings/page.tsx +0 -28
- package/template/prisma/src/app/(app)/settings/render.tsx +0 -113
- package/template/prisma/src/app/(app)/tasks/[id]/actions.ts +0 -147
- package/template/prisma/src/app/(app)/tasks/[id]/page.tsx +0 -25
- package/template/prisma/src/app/(app)/tasks/[id]/render.tsx +0 -413
- package/template/prisma/src/app/(app)/tasks/actions.ts +0 -69
- package/template/prisma/src/app/(app)/tasks/page.tsx +0 -53
- package/template/prisma/src/app/(app)/tasks/render.tsx +0 -107
- package/template/prisma/src/app/(app)/users/[id]/actions.ts +0 -83
- package/template/prisma/src/app/(app)/users/[id]/page.tsx +0 -32
- package/template/prisma/src/app/(app)/users/[id]/render.tsx +0 -240
- package/template/prisma/src/app/(app)/users/actions.ts +0 -55
- package/template/prisma/src/app/(app)/users/page.tsx +0 -49
- package/template/prisma/src/app/(app)/users/render.tsx +0 -80
- package/template/prisma/src/app/(auth)/layout.tsx +0 -20
- package/template/prisma/src/app/(auth)/login/page.tsx +0 -49
- package/template/prisma/src/app/(auth)/login/user-auth-form.tsx +0 -152
- package/template/prisma/src/app/api/auth/[...nextauth]/route.ts +0 -7
- package/template/prisma/src/app/api/upload/route.ts +0 -36
- package/template/prisma/src/app/favicon.ico +0 -0
- package/template/prisma/src/app/layout.tsx +0 -34
- package/template/prisma/src/components/app-nav-command.tsx +0 -160
- package/template/prisma/src/components/dark-mode-toggle.tsx +0 -43
- package/template/prisma/src/components/data-table/data-table-column-header.tsx +0 -91
- package/template/prisma/src/components/data-table/data-table-faceted-filter.tsx +0 -149
- package/template/prisma/src/components/data-table/data-table-loading.tsx +0 -77
- package/template/prisma/src/components/data-table/data-table-pagination.tsx +0 -94
- package/template/prisma/src/components/data-table/data-table-toolbar.tsx +0 -78
- package/template/prisma/src/components/data-table/data-table-types.ts +0 -17
- package/template/prisma/src/components/data-table/data-table-view-options.tsx +0 -59
- package/template/prisma/src/components/data-table/data-table.tsx +0 -301
- package/template/prisma/src/components/data-table/simple-data-table.tsx +0 -109
- package/template/prisma/src/components/empty-placeholder.tsx +0 -78
- package/template/prisma/src/components/heading.tsx +0 -17
- package/template/prisma/src/components/icons.tsx +0 -85
- package/template/prisma/src/components/main-nav.tsx +0 -64
- package/template/prisma/src/components/mobile-nav.tsx +0 -50
- package/template/prisma/src/components/shell.tsx +0 -13
- package/template/prisma/src/components/side-nav.tsx +0 -51
- package/template/prisma/src/components/site-footer.tsx +0 -31
- package/template/prisma/src/components/system-info.tsx +0 -36
- package/template/prisma/src/components/theme-provider.tsx +0 -13
- package/template/prisma/src/components/ui/alert-dialog.tsx +0 -141
- package/template/prisma/src/components/ui/avatar.tsx +0 -50
- package/template/prisma/src/components/ui/badge.tsx +0 -36
- package/template/prisma/src/components/ui/button.tsx +0 -56
- package/template/prisma/src/components/ui/card.tsx +0 -79
- package/template/prisma/src/components/ui/checkbox.tsx +0 -30
- package/template/prisma/src/components/ui/command.tsx +0 -155
- package/template/prisma/src/components/ui/dialog.tsx +0 -122
- package/template/prisma/src/components/ui/dropdown-menu.tsx +0 -200
- package/template/prisma/src/components/ui/form.tsx +0 -176
- package/template/prisma/src/components/ui/input.tsx +0 -25
- package/template/prisma/src/components/ui/label.tsx +0 -26
- package/template/prisma/src/components/ui/popover.tsx +0 -31
- package/template/prisma/src/components/ui/select.tsx +0 -160
- package/template/prisma/src/components/ui/separator.tsx +0 -31
- package/template/prisma/src/components/ui/skeleton.tsx +0 -15
- package/template/prisma/src/components/ui/table.tsx +0 -117
- package/template/prisma/src/components/ui/textarea.tsx +0 -24
- package/template/prisma/src/components/ui/toast.tsx +0 -127
- package/template/prisma/src/components/ui/toaster.tsx +0 -35
- package/template/prisma/src/components/ui/use-toast.ts +0 -189
- package/template/prisma/src/components/user-account-nav.tsx +0 -60
- package/template/prisma/src/components/user-avatar.tsx +0 -25
- package/template/prisma/src/env.mjs +0 -78
- package/template/prisma/src/hooks/use-debounce.ts +0 -17
- package/template/prisma/src/hooks/use-lock-body.tsx +0 -12
- package/template/prisma/src/lib/auth.ts +0 -80
- package/template/prisma/src/lib/cn.ts +0 -4
- package/template/prisma/src/lib/db.ts +0 -20
- package/template/prisma/src/lib/delay.ts +0 -2
- package/template/prisma/src/lib/formatDate.ts +0 -11
- package/template/prisma/src/lib/generateLabel.ts +0 -5
- package/template/prisma/src/lib/siteConfig.ts +0 -4
- package/template/prisma/src/lib/storageClient.ts +0 -11
- package/template/prisma/src/styles/editor.css +0 -61
- package/template/prisma/src/styles/globals.css +0 -76
- package/template/prisma/src/types/UnwrapPromise.ts +0 -1
- package/template/prisma/tailwind.config.ts +0 -80
- package/template/prisma/tsconfig.json +0 -46
- package/template/prisma-advanced/.eslintrc.cjs +0 -24
- package/template/prisma-advanced/components.json +0 -17
- package/template/prisma-advanced/next.config.mjs +0 -15
- package/template/prisma-advanced/package.json +0 -80
- package/template/prisma-advanced/postcss.config.cjs +0 -6
- package/template/prisma-advanced/prettier.config.ts +0 -11
- package/template/prisma-advanced/prisma/schema.prisma +0 -154
- package/template/prisma-advanced/public/next.svg +0 -1
- package/template/prisma-advanced/src/app/(app)/dashboard/page.tsx +0 -19
- package/template/prisma-advanced/src/app/(app)/roles/[id]/actions.ts +0 -100
- package/template/prisma-advanced/src/app/(app)/roles/[id]/page.tsx +0 -36
- package/template/prisma-advanced/src/app/(app)/roles/[id]/render.tsx +0 -266
- package/template/prisma-advanced/src/app/(app)/roles/actions.ts +0 -67
- package/template/prisma-advanced/src/app/(app)/roles/page.tsx +0 -51
- package/template/prisma-advanced/src/app/(app)/roles/render.tsx +0 -70
- package/template/prisma-advanced/src/app/(app)/settings/actions.ts +0 -18
- package/template/prisma-advanced/src/app/(app)/settings/loading.tsx +0 -28
- package/template/prisma-advanced/src/app/(app)/settings/page.tsx +0 -28
- package/template/prisma-advanced/src/app/(app)/settings/render.tsx +0 -113
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/actions.ts +0 -147
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/page.tsx +0 -55
- package/template/prisma-advanced/src/app/(app)/tasks/[id]/render.tsx +0 -418
- package/template/prisma-advanced/src/app/(app)/tasks/actions.ts +0 -69
- package/template/prisma-advanced/src/app/(app)/tasks/page.tsx +0 -63
- package/template/prisma-advanced/src/app/(app)/tasks/render.tsx +0 -114
- package/template/prisma-advanced/src/app/(app)/users/[id]/actions.ts +0 -104
- package/template/prisma-advanced/src/app/(app)/users/[id]/page.tsx +0 -39
- package/template/prisma-advanced/src/app/(app)/users/[id]/render.tsx +0 -320
- package/template/prisma-advanced/src/app/(app)/users/actions.ts +0 -67
- package/template/prisma-advanced/src/app/(app)/users/page.tsx +0 -61
- package/template/prisma-advanced/src/app/(app)/users/render.tsx +0 -108
- package/template/prisma-advanced/src/app/(auth)/layout.tsx +0 -20
- package/template/prisma-advanced/src/app/(auth)/login/user-auth-form.tsx +0 -152
- package/template/prisma-advanced/src/app/(marketing)/layout.tsx +0 -42
- package/template/prisma-advanced/src/app/(marketing)/page.tsx +0 -96
- package/template/prisma-advanced/src/app/api/auth/[...nextauth]/route.ts +0 -7
- package/template/prisma-advanced/src/app/api/upload/route.ts +0 -36
- package/template/prisma-advanced/src/app/favicon.ico +0 -0
- package/template/prisma-advanced/src/app/layout.tsx +0 -34
- package/template/prisma-advanced/src/components/app-nav-command.tsx +0 -160
- package/template/prisma-advanced/src/components/dark-mode-toggle.tsx +0 -43
- package/template/prisma-advanced/src/components/data-table/data-table-column-header.tsx +0 -91
- package/template/prisma-advanced/src/components/data-table/data-table-faceted-filter.tsx +0 -149
- package/template/prisma-advanced/src/components/data-table/data-table-loading.tsx +0 -77
- package/template/prisma-advanced/src/components/data-table/data-table-pagination.tsx +0 -94
- package/template/prisma-advanced/src/components/data-table/data-table-toolbar.tsx +0 -78
- package/template/prisma-advanced/src/components/data-table/data-table-types.ts +0 -17
- package/template/prisma-advanced/src/components/data-table/data-table-view-options.tsx +0 -59
- package/template/prisma-advanced/src/components/data-table/data-table.tsx +0 -301
- package/template/prisma-advanced/src/components/data-table/simple-data-table.tsx +0 -109
- package/template/prisma-advanced/src/components/empty-placeholder.tsx +0 -78
- package/template/prisma-advanced/src/components/heading.tsx +0 -17
- package/template/prisma-advanced/src/components/icons.tsx +0 -85
- package/template/prisma-advanced/src/components/main-nav.tsx +0 -64
- package/template/prisma-advanced/src/components/shell.tsx +0 -13
- package/template/prisma-advanced/src/components/side-nav.tsx +0 -51
- package/template/prisma-advanced/src/components/system-info.tsx +0 -36
- package/template/prisma-advanced/src/components/theme-provider.tsx +0 -13
- package/template/prisma-advanced/src/components/ui/alert-dialog.tsx +0 -141
- package/template/prisma-advanced/src/components/ui/avatar.tsx +0 -50
- package/template/prisma-advanced/src/components/ui/badge.tsx +0 -36
- package/template/prisma-advanced/src/components/ui/checkbox.tsx +0 -30
- package/template/prisma-advanced/src/components/ui/command.tsx +0 -155
- package/template/prisma-advanced/src/components/ui/dialog.tsx +0 -122
- package/template/prisma-advanced/src/components/ui/dropdown-menu.tsx +0 -200
- package/template/prisma-advanced/src/components/ui/popover.tsx +0 -31
- package/template/prisma-advanced/src/components/ui/select.tsx +0 -160
- package/template/prisma-advanced/src/components/ui/skeleton.tsx +0 -15
- package/template/prisma-advanced/src/components/ui/table.tsx +0 -117
- package/template/prisma-advanced/src/components/ui/textarea.tsx +0 -24
- package/template/prisma-advanced/src/components/ui/toast.tsx +0 -127
- package/template/prisma-advanced/src/components/ui/toaster.tsx +0 -35
- package/template/prisma-advanced/src/components/ui/use-toast.ts +0 -189
- package/template/prisma-advanced/src/components/user-account-nav.tsx +0 -60
- package/template/prisma-advanced/src/components/user-avatar.tsx +0 -25
- package/template/prisma-advanced/src/env.mjs +0 -78
- package/template/prisma-advanced/src/hooks/use-debounce.ts +0 -17
- package/template/prisma-advanced/src/hooks/use-lock-body.tsx +0 -12
- package/template/prisma-advanced/src/lib/auth.ts +0 -180
- package/template/prisma-advanced/src/lib/cn.ts +0 -4
- package/template/prisma-advanced/src/lib/db.ts +0 -20
- package/template/prisma-advanced/src/lib/delay.ts +0 -2
- package/template/prisma-advanced/src/lib/formatDate.ts +0 -11
- package/template/prisma-advanced/src/lib/generateLabel.ts +0 -5
- package/template/prisma-advanced/src/lib/siteConfig.ts +0 -4
- package/template/prisma-advanced/src/lib/storageClient.ts +0 -11
- package/template/prisma-advanced/src/styles/editor.css +0 -61
- package/template/prisma-advanced/src/types/UnwrapPromise.ts +0 -1
- package/template/prisma-advanced/tailwind.config.ts +0 -80
- package/template/{new → base}/next.config.ts +0 -0
- package/template/{new → base}/public/placeholder.svg +0 -0
- package/template/{new → base}/src/app/(auth)/login/email-login-form.tsx +0 -0
- package/template/{new → base}/src/app/(auth)/login/social-login-buttons.tsx +0 -0
- package/template/{new → base}/src/app/api/auth/[...all]/route.ts +0 -0
- package/template/{new → base}/src/components/loader.tsx +0 -0
- package/template/{new → base}/src/components/react-query-provider.tsx +0 -0
- package/template/{new → base}/src/components/screen-size.tsx +0 -0
- package/template/{new → base}/src/components/theme-toggle.tsx +0 -0
- package/template/{new → base}/src/lib/toast-message.ts +0 -0
- package/template/{base → old}/.eslintrc.cjs +0 -0
- package/template/{base → old}/next.config.mjs +0 -0
- package/template/{new → old}/prettier.config.mjs +0 -0
- package/template/{base → old}/public/next.svg +0 -0
- package/template/{base → old}/public/vercel.svg +0 -0
- package/template/{base → old}/src/app/(app)/dashboard/layout.tsx +0 -0
- package/template/{base → old}/src/app/(app)/dashboard/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/roles/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/roles/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/settings/layout.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/loading.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/settings/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/tasks/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/tasks/statusEnum.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/render.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/[id]/validation.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/actions.ts +0 -0
- package/template/{base → old}/src/app/(app)/users/page.tsx +0 -0
- package/template/{base → old}/src/app/(app)/users/render.tsx +0 -0
- package/template/{base → old}/src/app/(auth)/layout.tsx +0 -0
- package/template/{base → old}/src/app/(auth)/login/render.tsx +0 -0
- package/template/{prisma → old}/src/app/(marketing)/layout.tsx +1 -1
- /package/template/{base → old}/src/app/api/auth/[...nextauth]/route.ts +0 -0
- /package/template/{new → old}/src/app/favicon.ico +0 -0
- /package/template/{prisma-advanced/src/styles → old/src/app}/globals.css +0 -0
- /package/template/{base → old}/src/components/app-nav-command.tsx +0 -0
- /package/template/{base → old}/src/components/dark-mode-toggle.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-column-header.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-faceted-filter.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-loading.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-pagination.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-toolbar.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-types.ts +0 -0
- /package/template/{base → old}/src/components/data-table/data-table-view-options.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/data-table.tsx +0 -0
- /package/template/{base → old}/src/components/data-table/simple-data-table.tsx +0 -0
- /package/template/{base → old}/src/components/empty-placeholder.tsx +0 -0
- /package/template/{base → old}/src/components/heading.tsx +0 -0
- /package/template/{base → old}/src/components/icons.tsx +0 -0
- /package/template/{base → old}/src/components/main-nav.tsx +0 -0
- /package/template/{base → old}/src/components/mobile-nav.tsx +0 -0
- /package/template/{base → old}/src/components/shell.tsx +0 -0
- /package/template/{base → old}/src/components/side-nav.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/site-footer.tsx +0 -0
- /package/template/{base → old}/src/components/system-info.tsx +0 -0
- /package/template/{base → old}/src/components/ui/alert-dialog.tsx +0 -0
- /package/template/{base → old}/src/components/ui/avatar.tsx +0 -0
- /package/template/{base → old}/src/components/ui/badge.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/button.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/card.tsx +0 -0
- /package/template/{base → old}/src/components/ui/checkbox.tsx +0 -0
- /package/template/{base → old}/src/components/ui/command.tsx +0 -0
- /package/template/{base → old}/src/components/ui/dialog.tsx +0 -0
- /package/template/{base → old}/src/components/ui/dropdown-menu.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/form.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/input.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/label.tsx +0 -0
- /package/template/{base → old}/src/components/ui/popover.tsx +0 -0
- /package/template/{base → old}/src/components/ui/select.tsx +0 -0
- /package/template/{prisma-advanced → old}/src/components/ui/separator.tsx +0 -0
- /package/template/{base → old}/src/components/ui/skeleton.tsx +0 -0
- /package/template/{base → old}/src/components/ui/table.tsx +0 -0
- /package/template/{base → old}/src/components/user-account-nav.tsx +0 -0
- /package/template/{base → old}/src/components/user-avatar.tsx +0 -0
- /package/template/{base → old}/src/data-access/resource.ts +0 -0
- /package/template/{base → old}/src/data-access/role-permission.ts +0 -0
- /package/template/{base → old}/src/data-access/role.ts +0 -0
- /package/template/{base → old}/src/data-access/task.ts +0 -0
- /package/template/{base → old}/src/data-access/user.ts +0 -0
- /package/template/{base → old}/src/env.mjs +0 -0
- /package/template/{base → old}/src/hooks/use-debounce.tsx +0 -0
- /package/template/{base → old}/src/hooks/use-lock-body.tsx +0 -0
- /package/template/{new → old}/src/lib/cn.ts +0 -0
- /package/template/{base → old}/src/lib/currentUser.ts +0 -0
- /package/template/{new → old}/src/lib/delay.ts +0 -0
- /package/template/{base → old}/src/lib/formatDate.ts +0 -0
- /package/template/{base → old}/src/lib/generateLabel.ts +0 -0
- /package/template/{base → old}/src/lib/s3Client.ts +0 -0
- /package/template/{new → old}/src/lib/siteConfig.ts +0 -0
- /package/template/{base → old}/src/lib/sortOrderEnum.ts +0 -0
- /package/template/{base → old}/src/use-case/role-permission.ts +0 -0
- /package/template/{base → old}/src/use-case/role.ts +0 -0
- /package/template/{base → old}/src/use-case/task.ts +0 -0
- /package/template/{base → old}/src/use-case/user.ts +0 -0
- /package/template/{base → old}/tailwind.config.ts +0 -0
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { drizzle } from 'drizzle-orm/postgres-js'
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { env } from '@/env.mjs'
|
|
2
|
+
import { env } from '~/env'
|
|
5
3
|
import * as schema from './schema'
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const conn = globalForDb.conn ?? postgres(env.DATABASE_URL)
|
|
12
|
-
if (env.NODE_ENV !== 'production') globalForDb.conn = conn
|
|
13
|
-
|
|
14
|
-
export const db = drizzle(conn, { schema })
|
|
5
|
+
export const db = drizzle(env.DATABASE_URL, {
|
|
6
|
+
schema: { ...schema }
|
|
7
|
+
})
|
|
@@ -1,287 +1,79 @@
|
|
|
1
1
|
import { createId } from '@paralleldrive/cuid2'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
bigint,
|
|
5
|
-
boolean,
|
|
6
|
-
index,
|
|
7
|
-
integer,
|
|
8
|
-
pgEnum,
|
|
9
|
-
pgTable,
|
|
10
|
-
primaryKey,
|
|
11
|
-
text,
|
|
12
|
-
timestamp,
|
|
13
|
-
unique,
|
|
14
|
-
varchar
|
|
15
|
-
} from 'drizzle-orm/pg-core'
|
|
2
|
+
import { boolean, pgTable, text, timestamp, varchar } from 'drizzle-orm/pg-core'
|
|
16
3
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
id: text('id')
|
|
21
|
-
.notNull()
|
|
22
|
-
.primaryKey()
|
|
23
|
-
.$defaultFn(() => createId()),
|
|
24
|
-
userId: text('userId')
|
|
25
|
-
.notNull()
|
|
26
|
-
.references(() => User.id),
|
|
27
|
-
type: varchar('type', { length: 255 }).notNull(),
|
|
28
|
-
provider: varchar('provider', { length: 255 }).notNull(),
|
|
29
|
-
providerAccountId: varchar('providerAccountId', { length: 255 }).notNull(),
|
|
30
|
-
refresh_token: text('refresh_token'),
|
|
31
|
-
access_token: text('access_token'),
|
|
32
|
-
expires_at: integer('expires_at'),
|
|
33
|
-
token_type: varchar('token_type', { length: 255 }),
|
|
34
|
-
scope: varchar('scope', { length: 255 }),
|
|
35
|
-
id_token: text('id_token'),
|
|
36
|
-
session_state: varchar('session_state', { length: 255 })
|
|
37
|
-
},
|
|
38
|
-
account => ({
|
|
39
|
-
userIdIdx: index('Accounts_idx_userId').on(account.userId),
|
|
40
|
-
uniqueProviderAccount: unique('Accounts_uq_provider_providerAccountId').on(
|
|
41
|
-
account.provider,
|
|
42
|
-
account.providerAccountId
|
|
43
|
-
)
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
export const AccountRelations = relations(Account, ({ one }) => ({
|
|
48
|
-
user: one(User, { fields: [Account.userId], references: [User.id] })
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
export const Session = pgTable(
|
|
52
|
-
'Sessions',
|
|
53
|
-
{
|
|
54
|
-
id: text('id')
|
|
55
|
-
.notNull()
|
|
4
|
+
const commonFieldDefs = {
|
|
5
|
+
id: (prefix: string) =>
|
|
6
|
+
varchar('id')
|
|
56
7
|
.primaryKey()
|
|
57
|
-
.$defaultFn(() => createId()),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.notNull()
|
|
61
|
-
.references(() => User.id),
|
|
62
|
-
expires: timestamp('expires', {
|
|
8
|
+
.$defaultFn(() => prefix + '_' + createId()),
|
|
9
|
+
date: (name: string) =>
|
|
10
|
+
timestamp(name, {
|
|
63
11
|
mode: 'date',
|
|
64
12
|
withTimezone: true
|
|
65
|
-
})
|
|
66
|
-
|
|
13
|
+
}),
|
|
14
|
+
dates: {
|
|
15
|
+
createdAt: timestamp('created_at', {
|
|
67
16
|
mode: 'date',
|
|
68
17
|
withTimezone: true
|
|
69
18
|
})
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
updatedAt: timestamp('
|
|
19
|
+
.notNull()
|
|
20
|
+
.defaultNow(),
|
|
21
|
+
updatedAt: timestamp('updated_at', {
|
|
73
22
|
mode: 'date',
|
|
74
23
|
withTimezone: true
|
|
75
24
|
})
|
|
76
|
-
},
|
|
77
|
-
session => ({
|
|
78
|
-
userIdIdx: index('Sessions_idx_userId').on(session.userId)
|
|
79
|
-
})
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
export const SessionRelations = relations(Session, ({ one }) => ({
|
|
83
|
-
user: one(User, { fields: [Session.userId], references: [User.id] })
|
|
84
|
-
}))
|
|
85
|
-
|
|
86
|
-
export const Role = pgTable('Roles', {
|
|
87
|
-
id: text('id')
|
|
88
|
-
.notNull()
|
|
89
|
-
.primaryKey()
|
|
90
|
-
.$defaultFn(() => createId()),
|
|
91
|
-
name: varchar('name', { length: 255 }).notNull().unique(),
|
|
92
|
-
createdAt: timestamp('createdAt', {
|
|
93
|
-
mode: 'date',
|
|
94
|
-
withTimezone: true
|
|
95
|
-
})
|
|
96
|
-
.default(sql`CURRENT_TIMESTAMP`)
|
|
97
|
-
.notNull(),
|
|
98
|
-
updatedAt: timestamp('updatedAt', {
|
|
99
|
-
mode: 'date',
|
|
100
|
-
withTimezone: true
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
export const RoleRelations = relations(Role, ({ many }) => ({
|
|
105
|
-
permissions: many(RolePermission),
|
|
106
|
-
users: many(User)
|
|
107
|
-
}))
|
|
108
|
-
|
|
109
|
-
export const PermissionEnum = pgEnum('PermissionEnum', [
|
|
110
|
-
'TaskList',
|
|
111
|
-
'TaskView',
|
|
112
|
-
'TaskCreate',
|
|
113
|
-
'TaskUpdate',
|
|
114
|
-
'TaskDelete'
|
|
115
|
-
])
|
|
116
|
-
|
|
117
|
-
export const RolePermission = pgTable(
|
|
118
|
-
'RolePermissions',
|
|
119
|
-
{
|
|
120
|
-
id: text('id')
|
|
121
|
-
.notNull()
|
|
122
|
-
.primaryKey()
|
|
123
|
-
.$defaultFn(() => createId()),
|
|
124
|
-
roleId: text('roleId')
|
|
125
25
|
.notNull()
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}))
|
|
143
|
-
|
|
144
|
-
export const UserTypeEnum = pgEnum('UserTypeEnum', ['Root', 'Normal'])
|
|
26
|
+
.defaultNow()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const usersTable = pgTable('users', {
|
|
31
|
+
id: commonFieldDefs.id('user'),
|
|
32
|
+
email: text('email').notNull().unique(),
|
|
33
|
+
name: text('name').notNull(),
|
|
34
|
+
emailVerified: boolean('email_verified').default(false).notNull(),
|
|
35
|
+
image: text('image'),
|
|
36
|
+
role: text('role'),
|
|
37
|
+
banned: boolean('banned').default(false),
|
|
38
|
+
banReason: text('ban_reason'),
|
|
39
|
+
banExpires: commonFieldDefs.date('ban_expires'),
|
|
40
|
+
...commonFieldDefs.dates
|
|
41
|
+
})
|
|
145
42
|
|
|
146
|
-
export const
|
|
147
|
-
id:
|
|
43
|
+
export const sessionsTable = pgTable('sessions', {
|
|
44
|
+
id: commonFieldDefs.id('session'),
|
|
45
|
+
expiresAt: commonFieldDefs.date('expires_at').notNull(),
|
|
46
|
+
token: text('token').notNull().unique(),
|
|
47
|
+
ipAddress: text('ip_address'),
|
|
48
|
+
userAgent: text('user_agent'),
|
|
49
|
+
userId: text('user_id')
|
|
148
50
|
.notNull()
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
email: varchar('email', { length: 255 }).notNull().unique(),
|
|
153
|
-
emailVerified: timestamp('emailVerified', {
|
|
154
|
-
mode: 'date',
|
|
155
|
-
withTimezone: true
|
|
156
|
-
}),
|
|
157
|
-
image: varchar('image', { length: 255 }),
|
|
158
|
-
type: UserTypeEnum('type').notNull().default('Normal'),
|
|
159
|
-
roleId: text('roleId').references(() => Role.id),
|
|
160
|
-
createdAt: timestamp('createdAt', {
|
|
161
|
-
mode: 'date',
|
|
162
|
-
withTimezone: true
|
|
163
|
-
})
|
|
164
|
-
.default(sql`CURRENT_TIMESTAMP`)
|
|
165
|
-
.notNull(),
|
|
166
|
-
updatedAt: timestamp('updatedAt', {
|
|
167
|
-
mode: 'date',
|
|
168
|
-
withTimezone: true
|
|
169
|
-
})
|
|
51
|
+
.references(() => usersTable.id, { onDelete: 'cascade' }),
|
|
52
|
+
impersonatedBy: text('impersonated_by'),
|
|
53
|
+
...commonFieldDefs.dates
|
|
170
54
|
})
|
|
171
55
|
|
|
172
|
-
export const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
references: [Role.id]
|
|
178
|
-
})
|
|
179
|
-
}))
|
|
180
|
-
|
|
181
|
-
export const VerificationToken = pgTable(
|
|
182
|
-
'VerificationTokens',
|
|
183
|
-
{
|
|
184
|
-
identifier: varchar('identifier', { length: 255 }).notNull(),
|
|
185
|
-
token: varchar('token', { length: 255 }).notNull(),
|
|
186
|
-
expires: timestamp('expires', {
|
|
187
|
-
mode: 'date',
|
|
188
|
-
withTimezone: true
|
|
189
|
-
}).notNull()
|
|
190
|
-
},
|
|
191
|
-
vt => ({
|
|
192
|
-
pk: primaryKey({ columns: [vt.identifier, vt.token] })
|
|
193
|
-
})
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
export const TaskStatusEnum = pgEnum('TaskStatusEnum', [
|
|
197
|
-
'Backlog',
|
|
198
|
-
'Todo',
|
|
199
|
-
'In Progress',
|
|
200
|
-
'Done',
|
|
201
|
-
'Cancelled'
|
|
202
|
-
])
|
|
203
|
-
|
|
204
|
-
export const Task = pgTable('Tasks', {
|
|
205
|
-
id: text('id')
|
|
206
|
-
.notNull()
|
|
207
|
-
.primaryKey()
|
|
208
|
-
.$defaultFn(() => createId()),
|
|
209
|
-
title: varchar('title', { length: 255 }).notNull(),
|
|
210
|
-
status: TaskStatusEnum('status').notNull().default('Todo'),
|
|
211
|
-
description: text('description'),
|
|
212
|
-
createdAt: timestamp('createdAt', {
|
|
213
|
-
mode: 'date',
|
|
214
|
-
withTimezone: true
|
|
215
|
-
})
|
|
216
|
-
.default(sql`CURRENT_TIMESTAMP`)
|
|
217
|
-
.notNull(),
|
|
218
|
-
updatedAt: timestamp('updatedAt', {
|
|
219
|
-
mode: 'date',
|
|
220
|
-
withTimezone: true
|
|
221
|
-
}),
|
|
222
|
-
createdById: text('createdById')
|
|
56
|
+
export const accountsTable = pgTable('accounts', {
|
|
57
|
+
id: commonFieldDefs.id('account'),
|
|
58
|
+
accountId: text('account_id').notNull(),
|
|
59
|
+
providerId: text('provider_id').notNull(),
|
|
60
|
+
userId: text('user_id')
|
|
223
61
|
.notNull()
|
|
224
|
-
.references(() =>
|
|
225
|
-
|
|
62
|
+
.references(() => usersTable.id, { onDelete: 'cascade' }),
|
|
63
|
+
accessToken: text('access_token'),
|
|
64
|
+
refreshToken: text('refresh_token'),
|
|
65
|
+
idToken: text('id_token'),
|
|
66
|
+
accessTokenExpiresAt: commonFieldDefs.date('access_token_expires_at'),
|
|
67
|
+
refreshTokenExpiresAt: commonFieldDefs.date('refresh_token_expires_at'),
|
|
68
|
+
scope: text('scope'),
|
|
69
|
+
password: text('password'),
|
|
70
|
+
...commonFieldDefs.dates
|
|
226
71
|
})
|
|
227
72
|
|
|
228
|
-
export const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
references: [User.id]
|
|
236
|
-
}),
|
|
237
|
-
images: many(Resource)
|
|
238
|
-
}))
|
|
239
|
-
|
|
240
|
-
export const Resource = pgTable(
|
|
241
|
-
'Resources',
|
|
242
|
-
{
|
|
243
|
-
id: text('id')
|
|
244
|
-
.notNull()
|
|
245
|
-
.primaryKey()
|
|
246
|
-
.$defaultFn(() => createId()),
|
|
247
|
-
filename: varchar('filename', { length: 255 }).notNull(),
|
|
248
|
-
key: varchar('key', { length: 255 }).notNull().unique(),
|
|
249
|
-
isTemp: boolean('isTemp').notNull().default(false),
|
|
250
|
-
url: varchar('url', { length: 255 }).notNull().unique(),
|
|
251
|
-
size: bigint('size', { mode: 'number' }).notNull(),
|
|
252
|
-
contentType: varchar('contentType', { length: 255 }).notNull(),
|
|
253
|
-
|
|
254
|
-
taskId: text('taskId').references(() => Task.id),
|
|
255
|
-
|
|
256
|
-
createdAt: timestamp('createdAt', {
|
|
257
|
-
mode: 'date',
|
|
258
|
-
withTimezone: true
|
|
259
|
-
})
|
|
260
|
-
.default(sql`CURRENT_TIMESTAMP`)
|
|
261
|
-
.notNull(),
|
|
262
|
-
updatedAt: timestamp('updatedAt', {
|
|
263
|
-
mode: 'date',
|
|
264
|
-
withTimezone: true
|
|
265
|
-
}),
|
|
266
|
-
createdById: text('createdById').references(() => User.id),
|
|
267
|
-
updatedById: text('updatedById').references(() => User.id)
|
|
268
|
-
},
|
|
269
|
-
resource => ({
|
|
270
|
-
taskIdIdx: index('Resources_idx_taskId').on(resource.taskId)
|
|
271
|
-
})
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
export const ResourceRelations = relations(Resource, ({ one }) => ({
|
|
275
|
-
task: one(Task, {
|
|
276
|
-
fields: [Resource.taskId],
|
|
277
|
-
references: [Task.id]
|
|
278
|
-
}),
|
|
279
|
-
createdBy: one(User, {
|
|
280
|
-
fields: [Resource.createdById],
|
|
281
|
-
references: [User.id]
|
|
282
|
-
}),
|
|
283
|
-
updatedBy: one(User, {
|
|
284
|
-
fields: [Resource.updatedById],
|
|
285
|
-
references: [User.id]
|
|
286
|
-
})
|
|
287
|
-
}))
|
|
73
|
+
export const verificationsTable = pgTable('verifications', {
|
|
74
|
+
id: commonFieldDefs.id('verification'),
|
|
75
|
+
identifier: text('identifier').notNull(),
|
|
76
|
+
value: text('value').notNull(),
|
|
77
|
+
expiresAt: commonFieldDefs.date('expires_at').notNull(),
|
|
78
|
+
...commonFieldDefs.dates
|
|
79
|
+
})
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
|
|
4
4
|
export const env = createEnv({
|
|
5
5
|
server: {
|
|
6
|
-
|
|
6
|
+
APP_ENV: z.enum(['development', 'staging', 'production']),
|
|
7
7
|
ANALYZE: z.string().optional(),
|
|
8
8
|
DATABASE_URL: z.url(),
|
|
9
9
|
BETTER_AUTH_URL: z.url(),
|
|
@@ -22,7 +22,7 @@ export const env = createEnv({
|
|
|
22
22
|
client: {},
|
|
23
23
|
|
|
24
24
|
runtimeEnv: {
|
|
25
|
-
|
|
25
|
+
APP_ENV: process.env.APP_ENV,
|
|
26
26
|
ANALYZE: process.env.ANALYZE,
|
|
27
27
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
28
28
|
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
adminClient,
|
|
4
5
|
inferAdditionalFields,
|
|
5
6
|
lastLoginMethodClient,
|
|
6
7
|
magicLinkClient
|
|
@@ -13,6 +14,7 @@ export const { signIn, signOut, useSession, getLastUsedLoginMethod } =
|
|
|
13
14
|
plugins: [
|
|
14
15
|
inferAdditionalFields<typeof auth>(),
|
|
15
16
|
magicLinkClient(),
|
|
17
|
+
adminClient(),
|
|
16
18
|
lastLoginMethodClient()
|
|
17
19
|
]
|
|
18
20
|
})
|
|
@@ -1,89 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type DefaultSession,
|
|
7
|
-
type NextAuthOptions
|
|
8
|
-
} from 'next-auth'
|
|
9
|
-
import { Adapter } from 'next-auth/adapters'
|
|
10
|
-
import EmailProvider from 'next-auth/providers/email'
|
|
11
|
-
import GitHubProvider from 'next-auth/providers/github'
|
|
12
|
-
import GoogleProvider from 'next-auth/providers/google'
|
|
1
|
+
import { createId } from '@paralleldrive/cuid2'
|
|
2
|
+
import { betterAuth } from 'better-auth'
|
|
3
|
+
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
|
|
4
|
+
import { admin, lastLoginMethod, magicLink } from 'better-auth/plugins'
|
|
5
|
+
import { headers } from 'next/headers'
|
|
13
6
|
import { cache } from 'react'
|
|
7
|
+
import { db } from '~/db'
|
|
8
|
+
import {
|
|
9
|
+
accountsTable,
|
|
10
|
+
sessionsTable,
|
|
11
|
+
usersTable,
|
|
12
|
+
verificationsTable
|
|
13
|
+
} from '~/db/schema'
|
|
14
|
+
import { env } from '~/env'
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface User extends InferSelectModel<typeof User> {}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const authOptions: NextAuthOptions = {
|
|
35
|
-
pages: {
|
|
36
|
-
signIn: '/login'
|
|
16
|
+
export const auth = betterAuth({
|
|
17
|
+
database: drizzleAdapter(db, {
|
|
18
|
+
provider: 'pg',
|
|
19
|
+
schema: {
|
|
20
|
+
user: usersTable,
|
|
21
|
+
session: sessionsTable,
|
|
22
|
+
account: accountsTable,
|
|
23
|
+
verification: verificationsTable
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
account: {
|
|
27
|
+
accountLinking: {
|
|
28
|
+
enabled: true
|
|
29
|
+
}
|
|
37
30
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...session,
|
|
42
|
-
user: {
|
|
43
|
-
...session.user,
|
|
44
|
-
id: user.id,
|
|
45
|
-
type: user.type,
|
|
46
|
-
roleId: user.roleId
|
|
47
|
-
}
|
|
48
|
-
}
|
|
31
|
+
advanced: {
|
|
32
|
+
database: {
|
|
33
|
+
generateId: ({ model }) => `${model}_${createId()}`
|
|
49
34
|
}
|
|
50
35
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
36
|
+
socialProviders: {
|
|
37
|
+
github: {
|
|
38
|
+
prompt: 'select_account',
|
|
39
|
+
clientId: env.BETTER_AUTH_GITHUB_ID,
|
|
40
|
+
clientSecret: env.BETTER_AUTH_GITHUB_SECRET
|
|
41
|
+
},
|
|
42
|
+
google: {
|
|
43
|
+
prompt: 'select_account',
|
|
44
|
+
clientId: env.BETTER_AUTH_GOOGLE_ID,
|
|
45
|
+
clientSecret: env.BETTER_AUTH_GOOGLE_SECRET
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
plugins: [
|
|
49
|
+
magicLink({
|
|
50
|
+
sendMagicLink: async ({ email, token, url }) => {
|
|
51
|
+
console.warn('TODO: send email', {
|
|
52
|
+
email,
|
|
53
|
+
token,
|
|
54
|
+
url
|
|
55
|
+
})
|
|
56
|
+
}
|
|
72
57
|
}),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
clientSecret: env.GITHUB_SECRET
|
|
76
|
-
})
|
|
58
|
+
admin(),
|
|
59
|
+
lastLoginMethod()
|
|
77
60
|
]
|
|
78
|
-
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
export const getAuthSession = cache(async () => {
|
|
64
|
+
const authSession = await auth.api.getSession({
|
|
65
|
+
headers: await headers()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
if (!authSession || !authSession.user || !authSession.session) return null
|
|
79
69
|
|
|
80
|
-
|
|
70
|
+
const isAdmin = authSession.user.role === 'admin'
|
|
81
71
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
checkForRolePermissionUseCase(
|
|
85
|
-
session.user.type,
|
|
86
|
-
session.user.roleId,
|
|
87
|
-
permission
|
|
88
|
-
)
|
|
89
|
-
)
|
|
72
|
+
return { ...authSession, isAdmin }
|
|
73
|
+
})
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import { createSafeActionClient } from 'next-safe-action'
|
|
2
|
-
|
|
3
2
|
import { getAuthSession } from './auth'
|
|
4
3
|
|
|
5
|
-
const actionClient = createSafeActionClient()
|
|
4
|
+
export const actionClient = createSafeActionClient().use(
|
|
5
|
+
async ({ next, ctx }) => {
|
|
6
|
+
const authSession = await getAuthSession()
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
return next({
|
|
9
|
+
ctx: {
|
|
10
|
+
...ctx,
|
|
11
|
+
...authSession
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
)
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
export const authActionClient = actionClient.use(async ({ ctx, next }) => {
|
|
18
|
+
if (!ctx?.user || !ctx?.session) {
|
|
11
19
|
throw new Error('Unauthorized')
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
return next({
|
|
15
23
|
ctx: {
|
|
16
|
-
|
|
24
|
+
...ctx,
|
|
25
|
+
user: ctx.user,
|
|
26
|
+
session: ctx.session
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export const adminActionClient = authActionClient.use(async ({ ctx, next }) => {
|
|
32
|
+
if (!ctx.isAdmin) {
|
|
33
|
+
throw new Error('Forbidden')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return next({
|
|
37
|
+
ctx: {
|
|
38
|
+
...ctx,
|
|
39
|
+
user: ctx.user,
|
|
40
|
+
session: ctx.session
|
|
17
41
|
}
|
|
18
42
|
})
|
|
19
43
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2017",
|
|
4
4
|
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
5
|
"allowJs": true,
|
|
6
6
|
"checkJs": true,
|
|
@@ -22,26 +22,28 @@
|
|
|
22
22
|
"moduleResolution": "bundler",
|
|
23
23
|
"resolveJsonModule": true,
|
|
24
24
|
"isolatedModules": true,
|
|
25
|
-
"jsx": "
|
|
25
|
+
"jsx": "react-jsx",
|
|
26
26
|
"incremental": true,
|
|
27
27
|
"plugins": [
|
|
28
28
|
{
|
|
29
29
|
"name": "next"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "workflow"
|
|
30
33
|
}
|
|
31
34
|
],
|
|
32
35
|
"paths": {
|
|
33
|
-
"
|
|
36
|
+
"~/*": ["./src/*"]
|
|
34
37
|
}
|
|
35
38
|
},
|
|
36
39
|
"include": [
|
|
37
|
-
".eslintrc.cjs",
|
|
38
40
|
"next-env.d.ts",
|
|
39
41
|
"**/*.ts",
|
|
40
42
|
"**/*.tsx",
|
|
41
|
-
"
|
|
43
|
+
".next/types/**/*.ts",
|
|
44
|
+
".next/dev/types/**/*.ts",
|
|
42
45
|
"**/*.cjs",
|
|
43
|
-
"**/*.mjs"
|
|
44
|
-
".next/types/**/*.ts"
|
|
46
|
+
"**/*.mjs"
|
|
45
47
|
],
|
|
46
48
|
"exclude": ["node_modules"]
|
|
47
49
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
NODE_ENV="development"
|
|
2
|
+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
|
|
2
3
|
NEXTAUTH_SECRET="secret"
|
|
3
4
|
NEXTAUTH_URL="http://localhost:3000"
|
|
4
5
|
EMAIL_SERVER_HOST="example.com"
|
|
@@ -6,11 +7,11 @@ EMAIL_SERVER_PORT="123"
|
|
|
6
7
|
EMAIL_SERVER_USER="example@example.com"
|
|
7
8
|
EMAIL_SERVER_PASSWORD="password"
|
|
8
9
|
EMAIL_FROM="example@example.com"
|
|
9
|
-
GOOGLE_ID=""
|
|
10
|
-
GOOGLE_SECRET=""
|
|
11
|
-
GITHUB_ID=""
|
|
12
|
-
GITHUB_SECRET=""
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
GOOGLE_ID="id"
|
|
11
|
+
GOOGLE_SECRET="secret"
|
|
12
|
+
GITHUB_ID="id"
|
|
13
|
+
GITHUB_SECRET="secret"
|
|
14
|
+
S3_REGION="ap-south-1"
|
|
15
|
+
S3_BUCKET="bucket"
|
|
16
|
+
S3_ACCESS_KEY="key"
|
|
17
|
+
S3_SECRET_KEY="secret"
|