create-ej-app 4.0.0 → 5.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/LICENSE +1 -1
- package/package.json +4 -4
- package/template/new/.env.example +13 -0
- package/template/new/components.json +22 -0
- package/template/new/drizzle.config.ts +10 -0
- package/template/new/eslint.config.mjs +18 -0
- package/template/new/next.config.ts +14 -0
- package/template/new/package.json +81 -0
- package/template/new/postcss.config.mjs +5 -0
- package/template/new/prettier.config.mjs +11 -0
- package/template/new/public/placeholder.svg +1 -0
- package/template/new/src/app/(auth)/login/email-login-form.tsx +97 -0
- package/template/new/src/app/(auth)/login/page.tsx +72 -0
- package/template/new/src/app/(auth)/login/social-login-buttons.tsx +69 -0
- package/template/new/src/app/api/auth/[...all]/route.ts +4 -0
- package/template/new/src/app/favicon.ico +0 -0
- package/template/new/src/app/globals.css +128 -0
- package/template/new/src/app/layout.tsx +50 -0
- package/template/new/src/app/page.tsx +3 -0
- package/template/new/src/components/loader.tsx +25 -0
- package/template/new/src/components/react-query-provider.tsx +12 -0
- package/template/new/src/components/screen-size.tsx +40 -0
- package/template/new/src/components/theme-toggle.tsx +22 -0
- package/template/new/src/components/ui/button.tsx +60 -0
- package/template/new/src/components/ui/card.tsx +92 -0
- package/template/new/src/components/ui/form.tsx +167 -0
- package/template/new/src/components/ui/input.tsx +21 -0
- package/template/new/src/components/ui/label.tsx +24 -0
- package/template/new/src/components/ui/separator.tsx +28 -0
- package/template/new/src/components/ui/sonner.tsx +40 -0
- package/template/new/src/db/index.ts +7 -0
- package/template/new/src/db/schema.ts +74 -0
- package/template/new/src/env.ts +42 -0
- package/template/new/src/lib/auth-client.ts +18 -0
- package/template/new/src/lib/auth.ts +67 -0
- package/template/new/src/lib/cn.ts +4 -0
- package/template/new/src/lib/delay.ts +2 -0
- package/template/new/src/lib/safe-action.ts +15 -0
- package/template/new/src/lib/siteConfig.ts +4 -0
- package/template/new/src/lib/toast-message.ts +15 -0
- package/template/new/tsconfig.json +49 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import NextTopLoader from 'nextjs-toploader'
|
|
4
|
+
|
|
5
|
+
import { FC } from 'react'
|
|
6
|
+
|
|
7
|
+
export const Loader: FC = () => {
|
|
8
|
+
return (
|
|
9
|
+
<NextTopLoader
|
|
10
|
+
color="#777777"
|
|
11
|
+
initialPosition={0.08}
|
|
12
|
+
crawlSpeed={200}
|
|
13
|
+
height={3}
|
|
14
|
+
crawl={true}
|
|
15
|
+
showSpinner={true}
|
|
16
|
+
easing="ease"
|
|
17
|
+
speed={200}
|
|
18
|
+
shadow={`0 0 10px '#777777',0 0 5px '#777777'`}
|
|
19
|
+
template='<div class="bar" role="bar"><div class="peg"></div></div>
|
|
20
|
+
<div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
|
|
21
|
+
zIndex={10000}
|
|
22
|
+
showAtBottom={false}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
+
import { FC, ReactNode } from 'react'
|
|
5
|
+
|
|
6
|
+
export const ReactQueryProvider: FC<{
|
|
7
|
+
children?: ReactNode
|
|
8
|
+
}> = ({ children }) => {
|
|
9
|
+
const client = new QueryClient({})
|
|
10
|
+
|
|
11
|
+
return <QueryClientProvider client={client}>{children}</QueryClientProvider>
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { FC, useEffect, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
export const ScreenSize: FC = () => {
|
|
6
|
+
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
function updateDimensions() {
|
|
10
|
+
setDimensions({
|
|
11
|
+
width: window.innerWidth,
|
|
12
|
+
height: window.innerHeight
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
updateDimensions()
|
|
17
|
+
window.addEventListener('resize', updateDimensions)
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
window.removeEventListener('resize', updateDimensions)
|
|
21
|
+
}
|
|
22
|
+
}, [])
|
|
23
|
+
|
|
24
|
+
const { width, height } = dimensions
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="bg-foreground text-background fixed right-4 bottom-4 flex items-center gap-2 rounded-full p-2 text-xs font-medium">
|
|
28
|
+
<span>
|
|
29
|
+
{width.toLocaleString()} x {height.toLocaleString()}
|
|
30
|
+
</span>
|
|
31
|
+
<div className="bg-muted-foreground h-4 w-px" />
|
|
32
|
+
<span className="sm:hidden">XS</span>
|
|
33
|
+
<span className="hidden sm:inline md:hidden">SM</span>
|
|
34
|
+
<span className="hidden md:inline lg:hidden">MD</span>
|
|
35
|
+
<span className="hidden lg:inline xl:hidden">LG</span>
|
|
36
|
+
<span className="hidden xl:inline 2xl:hidden">XL</span>
|
|
37
|
+
<span className="hidden 2xl:inline">2XL</span>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Moon, Sun } from 'lucide-react'
|
|
4
|
+
import { useTheme } from 'next-themes'
|
|
5
|
+
import { FC } from 'react'
|
|
6
|
+
import { Button } from './ui/button'
|
|
7
|
+
|
|
8
|
+
export const ThemeToggle: FC = () => {
|
|
9
|
+
const { theme, setTheme } = useTheme()
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Button
|
|
13
|
+
variant="ghost"
|
|
14
|
+
size="icon"
|
|
15
|
+
aria-label="Toggle theme"
|
|
16
|
+
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
|
|
17
|
+
>
|
|
18
|
+
<Sun className="hidden h-5 w-5 dark:inline" />
|
|
19
|
+
<Moon className="inline h-5 w-5 dark:hidden" />
|
|
20
|
+
</Button>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
|
|
5
|
+
import { cn } from '~/lib/cn'
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
13
|
+
destructive:
|
|
14
|
+
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
15
|
+
outline:
|
|
16
|
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
|
17
|
+
secondary:
|
|
18
|
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
19
|
+
ghost:
|
|
20
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
21
|
+
link: 'text-primary underline-offset-4 hover:underline'
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
25
|
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
|
26
|
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
27
|
+
icon: 'size-9',
|
|
28
|
+
'icon-sm': 'size-8',
|
|
29
|
+
'icon-lg': 'size-10'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: 'default',
|
|
34
|
+
size: 'default'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
function Button({
|
|
40
|
+
className,
|
|
41
|
+
variant,
|
|
42
|
+
size,
|
|
43
|
+
asChild = false,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<'button'> &
|
|
46
|
+
VariantProps<typeof buttonVariants> & {
|
|
47
|
+
asChild?: boolean
|
|
48
|
+
}) {
|
|
49
|
+
const Comp = asChild ? Slot : 'button'
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Comp
|
|
53
|
+
data-slot="button"
|
|
54
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '~/lib/cn'
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<'div'>) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
'bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
'@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot="card-title"
|
|
35
|
+
className={cn('leading-none font-semibold', className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-slot="card-description"
|
|
45
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="card-action"
|
|
55
|
+
className={cn(
|
|
56
|
+
'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
data-slot="card-content"
|
|
68
|
+
className={cn('px-6', className)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
data-slot="card-footer"
|
|
78
|
+
className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Card,
|
|
86
|
+
CardAction,
|
|
87
|
+
CardContent,
|
|
88
|
+
CardDescription,
|
|
89
|
+
CardFooter,
|
|
90
|
+
CardHeader,
|
|
91
|
+
CardTitle
|
|
92
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
|
4
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
import {
|
|
7
|
+
Controller,
|
|
8
|
+
FormProvider,
|
|
9
|
+
useFormContext,
|
|
10
|
+
useFormState,
|
|
11
|
+
type ControllerProps,
|
|
12
|
+
type FieldPath,
|
|
13
|
+
type FieldValues
|
|
14
|
+
} from 'react-hook-form'
|
|
15
|
+
|
|
16
|
+
import { Label } from '~/components/ui/label'
|
|
17
|
+
import { cn } from '~/lib/cn'
|
|
18
|
+
|
|
19
|
+
const Form = FormProvider
|
|
20
|
+
|
|
21
|
+
type FormFieldContextValue<
|
|
22
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
23
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
24
|
+
> = {
|
|
25
|
+
name: TName
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
29
|
+
{} as FormFieldContextValue
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const FormField = <
|
|
33
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
34
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
35
|
+
>({
|
|
36
|
+
...props
|
|
37
|
+
}: ControllerProps<TFieldValues, TName>) => {
|
|
38
|
+
return (
|
|
39
|
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
|
40
|
+
<Controller {...props} />
|
|
41
|
+
</FormFieldContext.Provider>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const useFormField = () => {
|
|
46
|
+
const fieldContext = React.useContext(FormFieldContext)
|
|
47
|
+
const itemContext = React.useContext(FormItemContext)
|
|
48
|
+
const { getFieldState } = useFormContext()
|
|
49
|
+
const formState = useFormState({ name: fieldContext.name })
|
|
50
|
+
const fieldState = getFieldState(fieldContext.name, formState)
|
|
51
|
+
|
|
52
|
+
if (!fieldContext) {
|
|
53
|
+
throw new Error('useFormField should be used within <FormField>')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { id } = itemContext
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
id,
|
|
60
|
+
name: fieldContext.name,
|
|
61
|
+
formItemId: `${id}-form-item`,
|
|
62
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
63
|
+
formMessageId: `${id}-form-item-message`,
|
|
64
|
+
...fieldState
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type FormItemContextValue = {
|
|
69
|
+
id: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
73
|
+
{} as FormItemContextValue
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
|
|
77
|
+
const id = React.useId()
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<FormItemContext.Provider value={{ id }}>
|
|
81
|
+
<div
|
|
82
|
+
data-slot="form-item"
|
|
83
|
+
className={cn('grid gap-2', className)}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
</FormItemContext.Provider>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function FormLabel({
|
|
91
|
+
className,
|
|
92
|
+
...props
|
|
93
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
94
|
+
const { error, formItemId } = useFormField()
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Label
|
|
98
|
+
data-slot="form-label"
|
|
99
|
+
data-error={!!error}
|
|
100
|
+
className={cn('data-[error=true]:text-destructive', className)}
|
|
101
|
+
htmlFor={formItemId}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
|
108
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Slot
|
|
112
|
+
data-slot="form-control"
|
|
113
|
+
id={formItemId}
|
|
114
|
+
aria-describedby={
|
|
115
|
+
!error
|
|
116
|
+
? `${formDescriptionId}`
|
|
117
|
+
: `${formDescriptionId} ${formMessageId}`
|
|
118
|
+
}
|
|
119
|
+
aria-invalid={!!error}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function FormDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
126
|
+
const { formDescriptionId } = useFormField()
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<p
|
|
130
|
+
data-slot="form-description"
|
|
131
|
+
id={formDescriptionId}
|
|
132
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
133
|
+
{...props}
|
|
134
|
+
/>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
|
|
139
|
+
const { error, formMessageId } = useFormField()
|
|
140
|
+
const body = error ? String(error?.message ?? '') : props.children
|
|
141
|
+
|
|
142
|
+
if (!body) {
|
|
143
|
+
return null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<p
|
|
148
|
+
data-slot="form-message"
|
|
149
|
+
id={formMessageId}
|
|
150
|
+
className={cn('text-destructive text-sm', className)}
|
|
151
|
+
{...props}
|
|
152
|
+
>
|
|
153
|
+
{body}
|
|
154
|
+
</p>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
Form,
|
|
160
|
+
FormControl,
|
|
161
|
+
FormDescription,
|
|
162
|
+
FormField,
|
|
163
|
+
FormItem,
|
|
164
|
+
FormLabel,
|
|
165
|
+
FormMessage,
|
|
166
|
+
useFormField
|
|
167
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '~/lib/cn'
|
|
4
|
+
|
|
5
|
+
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
|
6
|
+
return (
|
|
7
|
+
<input
|
|
8
|
+
type={type}
|
|
9
|
+
data-slot="input"
|
|
10
|
+
className={cn(
|
|
11
|
+
'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
|
12
|
+
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
|
13
|
+
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { Input }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
|
4
|
+
import * as React from 'react'
|
|
5
|
+
|
|
6
|
+
import { cn } from '~/lib/cn'
|
|
7
|
+
|
|
8
|
+
function Label({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<LabelPrimitive.Root
|
|
14
|
+
data-slot="label"
|
|
15
|
+
className={cn(
|
|
16
|
+
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Label }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator'
|
|
4
|
+
import * as React from 'react'
|
|
5
|
+
|
|
6
|
+
import { cn } from '~/lib/cn'
|
|
7
|
+
|
|
8
|
+
function Separator({
|
|
9
|
+
className,
|
|
10
|
+
orientation = 'horizontal',
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
14
|
+
return (
|
|
15
|
+
<SeparatorPrimitive.Root
|
|
16
|
+
data-slot="separator"
|
|
17
|
+
decorative={decorative}
|
|
18
|
+
orientation={orientation}
|
|
19
|
+
className={cn(
|
|
20
|
+
'bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Separator }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CircleCheckIcon,
|
|
5
|
+
InfoIcon,
|
|
6
|
+
Loader2Icon,
|
|
7
|
+
OctagonXIcon,
|
|
8
|
+
TriangleAlertIcon
|
|
9
|
+
} from 'lucide-react'
|
|
10
|
+
import { useTheme } from 'next-themes'
|
|
11
|
+
import { Toaster as Sonner, type ToasterProps } from 'sonner'
|
|
12
|
+
|
|
13
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
14
|
+
const { theme = 'system' } = useTheme()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Sonner
|
|
18
|
+
theme={theme as ToasterProps['theme']}
|
|
19
|
+
className="toaster group"
|
|
20
|
+
icons={{
|
|
21
|
+
success: <CircleCheckIcon className="size-4" />,
|
|
22
|
+
info: <InfoIcon className="size-4" />,
|
|
23
|
+
warning: <TriangleAlertIcon className="size-4" />,
|
|
24
|
+
error: <OctagonXIcon className="size-4" />,
|
|
25
|
+
loading: <Loader2Icon className="size-4 animate-spin" />
|
|
26
|
+
}}
|
|
27
|
+
style={
|
|
28
|
+
{
|
|
29
|
+
'--normal-bg': 'var(--popover)',
|
|
30
|
+
'--normal-text': 'var(--popover-foreground)',
|
|
31
|
+
'--normal-border': 'var(--border)',
|
|
32
|
+
'--border-radius': 'var(--radius)'
|
|
33
|
+
} as React.CSSProperties
|
|
34
|
+
}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { Toaster }
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createId } from '@paralleldrive/cuid2'
|
|
2
|
+
import { boolean, pgTable, text, timestamp, varchar } from 'drizzle-orm/pg-core'
|
|
3
|
+
|
|
4
|
+
const commonFieldDefs = {
|
|
5
|
+
id: (prefix: string) =>
|
|
6
|
+
varchar('id')
|
|
7
|
+
.primaryKey()
|
|
8
|
+
.$defaultFn(() => prefix + '_' + createId()),
|
|
9
|
+
date: (name: string) =>
|
|
10
|
+
timestamp(name, {
|
|
11
|
+
mode: 'date',
|
|
12
|
+
withTimezone: true
|
|
13
|
+
}),
|
|
14
|
+
dates: {
|
|
15
|
+
createdAt: timestamp('created_at', {
|
|
16
|
+
mode: 'date',
|
|
17
|
+
withTimezone: true
|
|
18
|
+
})
|
|
19
|
+
.notNull()
|
|
20
|
+
.defaultNow(),
|
|
21
|
+
updatedAt: timestamp('updated_at', {
|
|
22
|
+
mode: 'date',
|
|
23
|
+
withTimezone: true
|
|
24
|
+
})
|
|
25
|
+
.notNull()
|
|
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
|
+
...commonFieldDefs.dates
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const sessionsTable = pgTable('sessions', {
|
|
40
|
+
id: commonFieldDefs.id('session'),
|
|
41
|
+
expiresAt: commonFieldDefs.date('expires_at').notNull(),
|
|
42
|
+
token: text('token').notNull().unique(),
|
|
43
|
+
ipAddress: text('ip_address'),
|
|
44
|
+
userAgent: text('user_agent'),
|
|
45
|
+
userId: text('user_id')
|
|
46
|
+
.notNull()
|
|
47
|
+
.references(() => usersTable.id, { onDelete: 'cascade' }),
|
|
48
|
+
...commonFieldDefs.dates
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
export const accountsTable = pgTable('accounts', {
|
|
52
|
+
id: commonFieldDefs.id('account'),
|
|
53
|
+
accountId: text('account_id').notNull(),
|
|
54
|
+
providerId: text('provider_id').notNull(),
|
|
55
|
+
userId: text('user_id')
|
|
56
|
+
.notNull()
|
|
57
|
+
.references(() => usersTable.id, { onDelete: 'cascade' }),
|
|
58
|
+
accessToken: text('access_token'),
|
|
59
|
+
refreshToken: text('refresh_token'),
|
|
60
|
+
idToken: text('id_token'),
|
|
61
|
+
accessTokenExpiresAt: commonFieldDefs.date('access_token_expires_at'),
|
|
62
|
+
refreshTokenExpiresAt: commonFieldDefs.date('refresh_token_expires_at'),
|
|
63
|
+
scope: text('scope'),
|
|
64
|
+
password: text('password'),
|
|
65
|
+
...commonFieldDefs.dates
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
export const verificationsTable = pgTable('verifications', {
|
|
69
|
+
id: commonFieldDefs.id('verification'),
|
|
70
|
+
identifier: text('identifier').notNull(),
|
|
71
|
+
value: text('value').notNull(),
|
|
72
|
+
expiresAt: commonFieldDefs.date('expires_at').notNull(),
|
|
73
|
+
...commonFieldDefs.dates
|
|
74
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createEnv } from '@t3-oss/env-nextjs'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const env = createEnv({
|
|
5
|
+
server: {
|
|
6
|
+
NODE_ENV: z.enum(['development', 'production']),
|
|
7
|
+
ANALYZE: z.string().optional(),
|
|
8
|
+
DATABASE_URL: z.url(),
|
|
9
|
+
BETTER_AUTH_URL: z.url(),
|
|
10
|
+
BETTER_AUTH_SECRET: z.string(),
|
|
11
|
+
BETTER_AUTH_GITHUB_ID: z.string(),
|
|
12
|
+
BETTER_AUTH_GITHUB_SECRET: z.string(),
|
|
13
|
+
BETTER_AUTH_GOOGLE_ID: z.string(),
|
|
14
|
+
BETTER_AUTH_GOOGLE_SECRET: z.string(),
|
|
15
|
+
EMAIL_SERVER_USER: z.string(),
|
|
16
|
+
EMAIL_SERVER_PASSWORD: z.string(),
|
|
17
|
+
EMAIL_SERVER_HOST: z.string(),
|
|
18
|
+
EMAIL_SERVER_PORT: z.string(),
|
|
19
|
+
EMAIL_FROM: z.email()
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
client: {},
|
|
23
|
+
|
|
24
|
+
runtimeEnv: {
|
|
25
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
26
|
+
ANALYZE: process.env.ANALYZE,
|
|
27
|
+
DATABASE_URL: process.env.DATABASE_URL,
|
|
28
|
+
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL,
|
|
29
|
+
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
30
|
+
BETTER_AUTH_GITHUB_ID: process.env.BETTER_AUTH_GITHUB_ID,
|
|
31
|
+
BETTER_AUTH_GITHUB_SECRET: process.env.BETTER_AUTH_GITHUB_SECRET,
|
|
32
|
+
BETTER_AUTH_GOOGLE_ID: process.env.BETTER_AUTH_GOOGLE_ID,
|
|
33
|
+
BETTER_AUTH_GOOGLE_SECRET: process.env.BETTER_AUTH_GOOGLE_SECRET,
|
|
34
|
+
EMAIL_SERVER_USER: process.env.EMAIL_SERVER_USER,
|
|
35
|
+
EMAIL_SERVER_PASSWORD: process.env.EMAIL_SERVER_PASSWORD,
|
|
36
|
+
EMAIL_SERVER_HOST: process.env.EMAIL_SERVER_HOST,
|
|
37
|
+
EMAIL_SERVER_PORT: process.env.EMAIL_SERVER_PORT,
|
|
38
|
+
EMAIL_FROM: process.env.EMAIL_FROM
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
emptyStringAsUndefined: true
|
|
42
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
inferAdditionalFields,
|
|
5
|
+
lastLoginMethodClient,
|
|
6
|
+
magicLinkClient
|
|
7
|
+
} from 'better-auth/client/plugins'
|
|
8
|
+
import { createAuthClient } from 'better-auth/react'
|
|
9
|
+
import type { auth } from './auth'
|
|
10
|
+
|
|
11
|
+
export const { signIn, signOut, useSession, getLastUsedLoginMethod } =
|
|
12
|
+
createAuthClient({
|
|
13
|
+
plugins: [
|
|
14
|
+
inferAdditionalFields<typeof auth>(),
|
|
15
|
+
magicLinkClient(),
|
|
16
|
+
lastLoginMethodClient()
|
|
17
|
+
]
|
|
18
|
+
})
|