create-lx2-app 0.7.2 → 0.9.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 +2 -1
- package/dist/index.js +27 -24
- package/package.json +1 -1
- package/template/packages/config/drizzle/with-mysql.ts +12 -0
- package/template/packages/config/drizzle/with-postgres.ts +12 -0
- package/template/packages/config/drizzle/with-sqlite.ts +12 -0
- package/template/packages/src/app/page/base.tsx +2 -2
- package/template/packages/src/app/page/with-authjs-drizzle.tsx +222 -0
- package/template/packages/src/app/page/with-authjs-prisma.tsx +2 -2
- package/template/packages/src/app/page/with-authjs.tsx +2 -2
- package/template/packages/src/app/page/with-better-auth-drizzle.tsx +234 -0
- package/template/packages/src/app/page/with-better-auth-prisma.tsx +2 -2
- package/template/packages/src/app/page/with-better-auth.tsx +2 -2
- package/template/packages/src/app/page/with-drizzle.tsx +172 -0
- package/template/packages/src/app/page/with-payload.tsx +2 -4
- package/template/packages/src/app/page/with-prisma.tsx +2 -2
- package/template/packages/src/server/auth/config/authjs-with-drizzle.ts +51 -0
- package/template/packages/src/server/auth/config/better-auth-with-prisma.ts +1 -0
- package/template/packages/src/server/db/index-drizzle/with-mysql.ts +19 -0
- package/template/packages/src/server/db/index-drizzle/with-postgres.ts +19 -0
- package/template/packages/src/server/db/index-drizzle/with-sqlite.ts +20 -0
- package/template/packages/src/server/db/schema-drizzle/base-mysql.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/base-postgres.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/base-sqlite.ts +27 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-mysql.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-postgres.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-authjs-sqlite.ts +138 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-mysql.ts +113 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-postgres.ts +113 -0
- package/template/packages/src/server/db/schema-drizzle/with-better-auth-sqlite.ts +113 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { fileURLToPath } from "url"
|
|
2
|
+
import { eq } from "drizzle-orm"
|
|
3
|
+
import { revalidatePath } from "next/cache"
|
|
4
|
+
import { headers } from "next/headers"
|
|
5
|
+
import { redirect } from "next/navigation"
|
|
6
|
+
|
|
7
|
+
import { auth } from "@/server/auth"
|
|
8
|
+
import { db } from "@/server/db"
|
|
9
|
+
import { post as postTable } from "@/server/db/schema"
|
|
10
|
+
|
|
11
|
+
export default async function HomePage() {
|
|
12
|
+
const session = await auth.api.getSession({
|
|
13
|
+
headers: await headers(),
|
|
14
|
+
})
|
|
15
|
+
const user = session?.user
|
|
16
|
+
|
|
17
|
+
const posts = await db.query.post.findMany()
|
|
18
|
+
|
|
19
|
+
const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
|
|
23
|
+
<header className="ml-auto">
|
|
24
|
+
{user ? (
|
|
25
|
+
<button
|
|
26
|
+
onClick={async () => {
|
|
27
|
+
"use server"
|
|
28
|
+
await auth.api.signOut({
|
|
29
|
+
headers: await headers(),
|
|
30
|
+
})
|
|
31
|
+
}}
|
|
32
|
+
className="cursor-pointer rounded-md bg-rose-400 px-4 py-2"
|
|
33
|
+
>
|
|
34
|
+
Sign Out
|
|
35
|
+
</button>
|
|
36
|
+
) : (
|
|
37
|
+
<button
|
|
38
|
+
onClick={async () => {
|
|
39
|
+
"use server"
|
|
40
|
+
const response = await auth.api.signInSocial({
|
|
41
|
+
body: {
|
|
42
|
+
provider: "discord",
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
if (!response) {
|
|
46
|
+
throw new Error("Failed to sign in")
|
|
47
|
+
}
|
|
48
|
+
if (response.url) {
|
|
49
|
+
redirect(response.url)
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
className="cursor-pointer rounded-md bg-purple-400 px-4 py-2"
|
|
53
|
+
>
|
|
54
|
+
Sign In
|
|
55
|
+
</button>
|
|
56
|
+
)}
|
|
57
|
+
</header>
|
|
58
|
+
|
|
59
|
+
<div className="flex grow flex-col items-center justify-center">
|
|
60
|
+
{/* Logo */}
|
|
61
|
+
<picture className="relative">
|
|
62
|
+
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
63
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
64
|
+
<img
|
|
65
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
66
|
+
alt="Logo"
|
|
67
|
+
width={65}
|
|
68
|
+
height={65}
|
|
69
|
+
className="block h-auto max-w-full"
|
|
70
|
+
/>
|
|
71
|
+
</picture>
|
|
72
|
+
|
|
73
|
+
{user ? (
|
|
74
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
75
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
76
|
+
</h1>
|
|
77
|
+
) : (
|
|
78
|
+
<>
|
|
79
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
80
|
+
Lx2 Next.js App
|
|
81
|
+
</h1>
|
|
82
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
83
|
+
Build modern web applications with today's most popular tools
|
|
84
|
+
</p>
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<div className="mt-12 flex items-center gap-3">
|
|
89
|
+
<a
|
|
90
|
+
href="https://create.lx2.dev"
|
|
91
|
+
target="_blank"
|
|
92
|
+
rel="noopener noreferrer"
|
|
93
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
94
|
+
>
|
|
95
|
+
Website
|
|
96
|
+
<svg
|
|
97
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
98
|
+
viewBox="0 0 24 24"
|
|
99
|
+
strokeLinecap="round"
|
|
100
|
+
strokeLinejoin="round"
|
|
101
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
102
|
+
>
|
|
103
|
+
<path d="M7 7h10v10" />
|
|
104
|
+
<path d="M7 17 17 7" />
|
|
105
|
+
</svg>
|
|
106
|
+
</a>
|
|
107
|
+
<a
|
|
108
|
+
href="https://create.lx2.dev/docs"
|
|
109
|
+
target="_blank"
|
|
110
|
+
rel="noopener noreferrer"
|
|
111
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
112
|
+
>
|
|
113
|
+
Docs
|
|
114
|
+
<svg
|
|
115
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
116
|
+
viewBox="0 0 24 24"
|
|
117
|
+
strokeLinecap="round"
|
|
118
|
+
strokeLinejoin="round"
|
|
119
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
120
|
+
>
|
|
121
|
+
<path d="M7 7h10v10" />
|
|
122
|
+
<path d="M7 17 17 7" />
|
|
123
|
+
</svg>
|
|
124
|
+
</a>
|
|
125
|
+
<a
|
|
126
|
+
href="https://github.com/SlickYeet/create-lx2-app"
|
|
127
|
+
target="_blank"
|
|
128
|
+
rel="noopener noreferrer"
|
|
129
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
130
|
+
>
|
|
131
|
+
GitHub
|
|
132
|
+
<svg
|
|
133
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
134
|
+
viewBox="0 0 24 24"
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
strokeLinejoin="round"
|
|
137
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
138
|
+
>
|
|
139
|
+
<path d="M7 7h10v10" />
|
|
140
|
+
<path d="M7 17 17 7" />
|
|
141
|
+
</svg>
|
|
142
|
+
</a>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="mt-12 flex flex-col items-center gap-3">
|
|
146
|
+
<div className="mb-4">
|
|
147
|
+
<h1 className="mb-4 text-center">
|
|
148
|
+
<span className="text-2xl text-neutral-700 dark:text-neutral-300">
|
|
149
|
+
Posts {posts.length}
|
|
150
|
+
</span>
|
|
151
|
+
</h1>
|
|
152
|
+
|
|
153
|
+
{user ? (
|
|
154
|
+
<form
|
|
155
|
+
action={async (formData: FormData) => {
|
|
156
|
+
"use server"
|
|
157
|
+
|
|
158
|
+
const name =
|
|
159
|
+
formData.get("name")?.toString() ||
|
|
160
|
+
`New Post ${posts.length + 1}`
|
|
161
|
+
|
|
162
|
+
await db.insert(postTable).values({ name })
|
|
163
|
+
|
|
164
|
+
revalidatePath("/")
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<input
|
|
168
|
+
type="text"
|
|
169
|
+
name="name"
|
|
170
|
+
placeholder="New Post"
|
|
171
|
+
className="h-8 rounded-md border border-neutral-300 px-2 outline-none dark:border-neutral-700 dark:bg-neutral-800"
|
|
172
|
+
/>
|
|
173
|
+
<button
|
|
174
|
+
type="submit"
|
|
175
|
+
className="ml-2 size-8 cursor-pointer rounded-md bg-neutral-200 outline-none hover:opacity-80 focus:opacity-80 dark:bg-neutral-800"
|
|
176
|
+
>
|
|
177
|
+
+
|
|
178
|
+
</button>
|
|
179
|
+
</form>
|
|
180
|
+
) : (
|
|
181
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
182
|
+
Sign in to create posts
|
|
183
|
+
</p>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div className="grid w-full grid-cols-1 gap-2 space-y-2 sm:grid-cols-2">
|
|
188
|
+
{posts.map((post) => (
|
|
189
|
+
<div
|
|
190
|
+
key={post.id}
|
|
191
|
+
className="flex h-10 max-w-40 items-center rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
192
|
+
>
|
|
193
|
+
<span className="truncate text-sm text-neutral-700 dark:text-neutral-300">
|
|
194
|
+
{post.name}
|
|
195
|
+
</span>
|
|
196
|
+
{user && (
|
|
197
|
+
<form
|
|
198
|
+
action={async () => {
|
|
199
|
+
"use server"
|
|
200
|
+
|
|
201
|
+
await db
|
|
202
|
+
.delete(postTable)
|
|
203
|
+
.where(eq(postTable.id, post.id))
|
|
204
|
+
|
|
205
|
+
revalidatePath("/")
|
|
206
|
+
}}
|
|
207
|
+
className="ml-auto"
|
|
208
|
+
>
|
|
209
|
+
<button
|
|
210
|
+
type="submit"
|
|
211
|
+
className="ml-2 cursor-pointer rounded-md text-rose-500 outline-none hover:opacity-80 focus:opacity-80"
|
|
212
|
+
>
|
|
213
|
+
x
|
|
214
|
+
</button>
|
|
215
|
+
</form>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
))}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
<div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
|
|
224
|
+
<p className="m-0">Get started by editing </p>
|
|
225
|
+
<a
|
|
226
|
+
href={fileURL}
|
|
227
|
+
className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
228
|
+
>
|
|
229
|
+
<code>src/app/page.tsx</code>
|
|
230
|
+
</a>
|
|
231
|
+
</div>
|
|
232
|
+
</main>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
@@ -58,9 +58,9 @@ export default async function HomePage() {
|
|
|
58
58
|
{/* Logo */}
|
|
59
59
|
<picture className="relative">
|
|
60
60
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
61
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
61
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
62
62
|
<img
|
|
63
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
63
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
64
64
|
alt="Logo"
|
|
65
65
|
width={65}
|
|
66
66
|
height={65}
|
|
@@ -54,9 +54,9 @@ export default async function HomePage() {
|
|
|
54
54
|
{/* Logo */}
|
|
55
55
|
<picture className="relative">
|
|
56
56
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
57
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
57
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
58
58
|
<img
|
|
59
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
59
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
60
60
|
alt="Logo"
|
|
61
61
|
width={65}
|
|
62
62
|
height={65}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { fileURLToPath } from "url"
|
|
2
|
+
import { eq } from "drizzle-orm"
|
|
3
|
+
import { revalidatePath } from "next/cache"
|
|
4
|
+
|
|
5
|
+
import { db } from "@/server/db"
|
|
6
|
+
import { post as postTable } from "@/server/db/schema"
|
|
7
|
+
|
|
8
|
+
export default async function HomePage() {
|
|
9
|
+
const posts = await db.query.post.findMany()
|
|
10
|
+
|
|
11
|
+
const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
|
|
15
|
+
<div className="flex grow flex-col items-center justify-center">
|
|
16
|
+
{/* Logo */}
|
|
17
|
+
<picture className="relative">
|
|
18
|
+
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
19
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
20
|
+
<img
|
|
21
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
22
|
+
alt="Logo"
|
|
23
|
+
width={65}
|
|
24
|
+
height={65}
|
|
25
|
+
className="block h-auto max-w-full"
|
|
26
|
+
/>
|
|
27
|
+
</picture>
|
|
28
|
+
|
|
29
|
+
<h1 className="mt-6 bg-gradient-to-r from-purple-500 to-cyan-500 bg-clip-text text-center text-4xl leading-10 text-transparent sm:text-5xl sm:leading-14 md:text-6xl md:leading-20 lg:mt-10 lg:text-7xl lg:font-bold">
|
|
30
|
+
Lx2 Next.js App
|
|
31
|
+
</h1>
|
|
32
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
33
|
+
Build modern web applications with today's most popular tools
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<div className="mt-12 flex items-center gap-3">
|
|
37
|
+
<a
|
|
38
|
+
href="https://create.lx2.dev"
|
|
39
|
+
target="_blank"
|
|
40
|
+
rel="noopener noreferrer"
|
|
41
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
42
|
+
>
|
|
43
|
+
Website
|
|
44
|
+
<svg
|
|
45
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
46
|
+
viewBox="0 0 24 24"
|
|
47
|
+
strokeLinecap="round"
|
|
48
|
+
strokeLinejoin="round"
|
|
49
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
50
|
+
>
|
|
51
|
+
<path d="M7 7h10v10" />
|
|
52
|
+
<path d="M7 17 17 7" />
|
|
53
|
+
</svg>
|
|
54
|
+
</a>
|
|
55
|
+
<a
|
|
56
|
+
href="https://create.lx2.dev/docs"
|
|
57
|
+
target="_blank"
|
|
58
|
+
rel="noopener noreferrer"
|
|
59
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
60
|
+
>
|
|
61
|
+
Docs
|
|
62
|
+
<svg
|
|
63
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
64
|
+
viewBox="0 0 24 24"
|
|
65
|
+
strokeLinecap="round"
|
|
66
|
+
strokeLinejoin="round"
|
|
67
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
68
|
+
>
|
|
69
|
+
<path d="M7 7h10v10" />
|
|
70
|
+
<path d="M7 17 17 7" />
|
|
71
|
+
</svg>
|
|
72
|
+
</a>
|
|
73
|
+
<a
|
|
74
|
+
href="https://github.com/SlickYeet/create-lx2-app"
|
|
75
|
+
target="_blank"
|
|
76
|
+
rel="noopener noreferrer"
|
|
77
|
+
className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
|
|
78
|
+
>
|
|
79
|
+
GitHub
|
|
80
|
+
<svg
|
|
81
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
82
|
+
viewBox="0 0 24 24"
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
strokeLinejoin="round"
|
|
85
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
86
|
+
>
|
|
87
|
+
<path d="M7 7h10v10" />
|
|
88
|
+
<path d="M7 17 17 7" />
|
|
89
|
+
</svg>
|
|
90
|
+
</a>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div className="mt-12 flex flex-col items-center gap-3">
|
|
94
|
+
<div className="mb-4">
|
|
95
|
+
<h1 className="mb-4 text-center">
|
|
96
|
+
<span className="text-2xl text-neutral-700 dark:text-neutral-300">
|
|
97
|
+
Posts {posts.length}
|
|
98
|
+
</span>
|
|
99
|
+
</h1>
|
|
100
|
+
|
|
101
|
+
<form
|
|
102
|
+
action={async (formData: FormData) => {
|
|
103
|
+
"use server"
|
|
104
|
+
|
|
105
|
+
const name =
|
|
106
|
+
formData.get("name")?.toString() ||
|
|
107
|
+
`New Post ${posts.length + 1}`
|
|
108
|
+
|
|
109
|
+
await db.insert(postTable).values({ name })
|
|
110
|
+
|
|
111
|
+
revalidatePath("/")
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<input
|
|
115
|
+
type="text"
|
|
116
|
+
name="name"
|
|
117
|
+
placeholder="New Post"
|
|
118
|
+
className="h-8 rounded-md border border-neutral-300 px-2 outline-none dark:border-neutral-700 dark:bg-neutral-800"
|
|
119
|
+
/>
|
|
120
|
+
<button
|
|
121
|
+
type="submit"
|
|
122
|
+
className="ml-2 size-8 cursor-pointer rounded-md bg-neutral-200 outline-none hover:opacity-80 focus:opacity-80 dark:bg-neutral-800"
|
|
123
|
+
>
|
|
124
|
+
+
|
|
125
|
+
</button>
|
|
126
|
+
</form>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div className="grid w-full grid-cols-1 gap-2 space-y-2 sm:grid-cols-2">
|
|
130
|
+
{posts.map((post) => (
|
|
131
|
+
<div
|
|
132
|
+
key={post.id}
|
|
133
|
+
className="flex h-10 max-w-40 items-center rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
134
|
+
>
|
|
135
|
+
<span className="truncate text-sm text-neutral-700 dark:text-neutral-300">
|
|
136
|
+
{post.name}
|
|
137
|
+
</span>
|
|
138
|
+
<form
|
|
139
|
+
action={async () => {
|
|
140
|
+
"use server"
|
|
141
|
+
|
|
142
|
+
await db.delete(postTable).where(eq(postTable.id, post.id))
|
|
143
|
+
|
|
144
|
+
revalidatePath("/")
|
|
145
|
+
}}
|
|
146
|
+
className="ml-auto"
|
|
147
|
+
>
|
|
148
|
+
<button
|
|
149
|
+
type="submit"
|
|
150
|
+
className="ml-2 cursor-pointer rounded-md text-rose-500 outline-none hover:opacity-80 focus:opacity-80"
|
|
151
|
+
>
|
|
152
|
+
x
|
|
153
|
+
</button>
|
|
154
|
+
</form>
|
|
155
|
+
</div>
|
|
156
|
+
))}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
|
|
162
|
+
<p className="m-0">Get started by editing </p>
|
|
163
|
+
<a
|
|
164
|
+
href={fileURL}
|
|
165
|
+
className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
166
|
+
>
|
|
167
|
+
<code>src/app/page.tsx</code>
|
|
168
|
+
</a>
|
|
169
|
+
</div>
|
|
170
|
+
</main>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
@@ -3,8 +3,6 @@ import config from "@payload-config"
|
|
|
3
3
|
import { headers as getHeaders } from "next/headers.js"
|
|
4
4
|
import { getPayload } from "payload"
|
|
5
5
|
|
|
6
|
-
import "./globals.css"
|
|
7
|
-
|
|
8
6
|
export default async function HomePage() {
|
|
9
7
|
const headers = await getHeaders()
|
|
10
8
|
const payloadConfig = await config
|
|
@@ -19,9 +17,9 @@ export default async function HomePage() {
|
|
|
19
17
|
{/* Logo */}
|
|
20
18
|
<picture className="relative">
|
|
21
19
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
22
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
20
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
23
21
|
<img
|
|
24
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
22
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
25
23
|
alt="Logo"
|
|
26
24
|
width={65}
|
|
27
25
|
height={65}
|
|
@@ -14,9 +14,9 @@ export default async function HomePage() {
|
|
|
14
14
|
{/* Logo */}
|
|
15
15
|
<picture className="relative">
|
|
16
16
|
<div className="absolute inset-0 animate-pulse rounded-xl bg-gradient-to-r from-purple-500 to-cyan-500 opacity-20 blur-xl dark:from-purple-800 dark:to-cyan-800" />
|
|
17
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
17
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
18
18
|
<img
|
|
19
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
19
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
20
20
|
alt="Logo"
|
|
21
21
|
width={65}
|
|
22
22
|
height={65}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DrizzleAdapter } from "@auth/drizzle-adapter"
|
|
2
|
+
import { NextAuthConfig } from "next-auth"
|
|
3
|
+
import Discord from "next-auth/providers/discord"
|
|
4
|
+
|
|
5
|
+
import { env } from "@/env"
|
|
6
|
+
import { db } from "@/server/db"
|
|
7
|
+
import {
|
|
8
|
+
account,
|
|
9
|
+
authenticator,
|
|
10
|
+
session,
|
|
11
|
+
user,
|
|
12
|
+
verificationToken,
|
|
13
|
+
} from "@/server/db/schema"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is the Auth.js configuration for the application.
|
|
17
|
+
*
|
|
18
|
+
* @see https://authjs.dev/getting-started/installation
|
|
19
|
+
*/
|
|
20
|
+
export const authConfig: NextAuthConfig = {
|
|
21
|
+
adapter: DrizzleAdapter(db, {
|
|
22
|
+
/**
|
|
23
|
+
* The Auth.js Drizzle adapter expects plural table names in code and singular in the database.
|
|
24
|
+
* Here, for consistency, we're explicitly mapping to our singular table names.
|
|
25
|
+
* Without this mapping, it would look for tables named "users", "accounts", etc.
|
|
26
|
+
* You do not need to define models here that are not used by Auth.js.
|
|
27
|
+
*
|
|
28
|
+
* @see https://authjs.dev/getting-started/adapters/drizzle#passing-your-own-schemas
|
|
29
|
+
*/
|
|
30
|
+
usersTable: user,
|
|
31
|
+
accountsTable: account,
|
|
32
|
+
sessionsTable: session,
|
|
33
|
+
verificationTokensTable: verificationToken,
|
|
34
|
+
authenticatorsTable: authenticator,
|
|
35
|
+
}),
|
|
36
|
+
providers: [
|
|
37
|
+
Discord({
|
|
38
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
39
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
40
|
+
}),
|
|
41
|
+
/**
|
|
42
|
+
* ...add more providers here.
|
|
43
|
+
*
|
|
44
|
+
* Most other providers require a bit more work than the Discord provider. For example, the
|
|
45
|
+
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
|
|
46
|
+
* model. Refer to the Auth.js docs for the provider you want to use. Example:
|
|
47
|
+
*
|
|
48
|
+
* @see https://authjs.dev/getting-started/providers/github
|
|
49
|
+
*/
|
|
50
|
+
],
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/mysql2"
|
|
2
|
+
import { createPool, type Pool } from "mysql2/promise"
|
|
3
|
+
|
|
4
|
+
import { env } from "@/env"
|
|
5
|
+
|
|
6
|
+
import * as schema from "./schema"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This caches the database connection in development to avoid
|
|
10
|
+
* creating a new connection on every HMR update.
|
|
11
|
+
*/
|
|
12
|
+
const globalForDb = globalThis as unknown as {
|
|
13
|
+
conn: Pool | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const conn = globalForDb.conn ?? createPool({ uri: env.DATABASE_URL })
|
|
17
|
+
if (env.NODE_ENV !== "production") globalForDb.conn = conn
|
|
18
|
+
|
|
19
|
+
export const db = drizzle(conn, { schema, mode: "default" })
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/postgres-js"
|
|
2
|
+
import postgres from "postgres"
|
|
3
|
+
|
|
4
|
+
import { env } from "@/env"
|
|
5
|
+
|
|
6
|
+
import * as schema from "./schema"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This caches the database connection in development to avoid
|
|
10
|
+
* creating a new connection on every HMR update.
|
|
11
|
+
*/
|
|
12
|
+
const globalForDb = globalThis as unknown as {
|
|
13
|
+
conn: postgres.Sql | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const conn = globalForDb.conn ?? postgres(env.DATABASE_URL)
|
|
17
|
+
if (env.NODE_ENV !== "production") globalForDb.conn = conn
|
|
18
|
+
|
|
19
|
+
export const db = drizzle(conn, { schema })
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createClient, type Client } from "@libsql/client"
|
|
2
|
+
import { drizzle } from "drizzle-orm/libsql"
|
|
3
|
+
|
|
4
|
+
import { env } from "@/env"
|
|
5
|
+
|
|
6
|
+
import * as schema from "./schema"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This caches the database connection in development to avoid
|
|
10
|
+
* creating a new connection on every HMR update.
|
|
11
|
+
*/
|
|
12
|
+
const globalForDb = globalThis as unknown as {
|
|
13
|
+
client: Client | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const client =
|
|
17
|
+
globalForDb.client ?? createClient({ url: env.DATABASE_URL })
|
|
18
|
+
if (env.NODE_ENV !== "production") globalForDb.client = client
|
|
19
|
+
|
|
20
|
+
export const db = drizzle(client, { schema })
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This is an example schema for PostgreSQL using Drizzle ORM.
|
|
2
|
+
// Learn more at https://orm.drizzle.team/docs/sql-schema-declaration
|
|
3
|
+
|
|
4
|
+
import { sql } from "drizzle-orm"
|
|
5
|
+
import { index, mysqlTableCreator } from "drizzle-orm/mysql-core"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Below is an example of how to create a table with a prefix.
|
|
9
|
+
* This is useful for multi-tenant applications where you want to separate data by tenant.
|
|
10
|
+
*
|
|
11
|
+
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
|
|
12
|
+
*/
|
|
13
|
+
export const createTable = mysqlTableCreator((name) => `project1_${name}`)
|
|
14
|
+
|
|
15
|
+
export const post = createTable(
|
|
16
|
+
"post",
|
|
17
|
+
(d) => ({
|
|
18
|
+
id: d.bigint({ mode: "number" }).primaryKey().autoincrement(),
|
|
19
|
+
name: d.varchar({ length: 255 }).notNull(),
|
|
20
|
+
createdAt: d
|
|
21
|
+
.timestamp({ mode: "date" })
|
|
22
|
+
.default(sql`CURRENT_TIMESTAMP`)
|
|
23
|
+
.notNull(),
|
|
24
|
+
updatedAt: d.timestamp({ mode: "date" }).$onUpdate(() => new Date()),
|
|
25
|
+
}),
|
|
26
|
+
(t) => [index("post_name_idx").on(t.name)]
|
|
27
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This is an example schema for PostgreSQL using Drizzle ORM.
|
|
2
|
+
// Learn more at https://orm.drizzle.team/docs/sql-schema-declaration
|
|
3
|
+
|
|
4
|
+
import { sql } from "drizzle-orm"
|
|
5
|
+
import { index, pgTableCreator } from "drizzle-orm/pg-core"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Below is an example of how to create a table with a prefix.
|
|
9
|
+
* This is useful for multi-tenant applications where you want to separate data by tenant.
|
|
10
|
+
*
|
|
11
|
+
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
|
|
12
|
+
*/
|
|
13
|
+
export const createTable = pgTableCreator((name) => `project1_${name}`)
|
|
14
|
+
|
|
15
|
+
export const post = createTable(
|
|
16
|
+
"post",
|
|
17
|
+
(d) => ({
|
|
18
|
+
id: d.integer().primaryKey().generatedByDefaultAsIdentity(),
|
|
19
|
+
name: d.varchar({ length: 255 }).notNull(),
|
|
20
|
+
createdAt: d
|
|
21
|
+
.timestamp({ withTimezone: true })
|
|
22
|
+
.default(sql`CURRENT_TIMESTAMP`)
|
|
23
|
+
.notNull(),
|
|
24
|
+
updatedAt: d.timestamp({ withTimezone: true }).$onUpdate(() => new Date()),
|
|
25
|
+
}),
|
|
26
|
+
(t) => [index("post_name_idx").on(t.name)]
|
|
27
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This is an example schema for PostgreSQL using Drizzle ORM.
|
|
2
|
+
// Learn more at https://orm.drizzle.team/docs/sql-schema-declaration
|
|
3
|
+
|
|
4
|
+
import { sql } from "drizzle-orm"
|
|
5
|
+
import { index, sqliteTableCreator } from "drizzle-orm/sqlite-core"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Below is an example of how to create a table with a prefix.
|
|
9
|
+
* This is useful for multi-tenant applications where you want to separate data by tenant.
|
|
10
|
+
*
|
|
11
|
+
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
|
|
12
|
+
*/
|
|
13
|
+
export const createTable = sqliteTableCreator((name) => `project1_${name}`)
|
|
14
|
+
|
|
15
|
+
export const post = createTable(
|
|
16
|
+
"post",
|
|
17
|
+
(d) => ({
|
|
18
|
+
id: d.integer({ mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
19
|
+
name: d.text({ length: 255 }).notNull(),
|
|
20
|
+
createdAt: d
|
|
21
|
+
.integer({ mode: "timestamp" })
|
|
22
|
+
.default(sql`(unixepoch())`)
|
|
23
|
+
.notNull(),
|
|
24
|
+
updatedAt: d.integer({ mode: "timestamp" }).$onUpdate(() => new Date()),
|
|
25
|
+
}),
|
|
26
|
+
(t) => [index("post_name_idx").on(t.name)]
|
|
27
|
+
)
|