create-lx2-app 0.7.2 → 0.8.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/dist/index.js +28 -24
- package/package.json +23 -17
- 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/api/auth/[...betterauth]/route.ts +1 -1
- package/template/packages/src/app/page/with-authjs-drizzle.tsx +222 -0
- package/template/packages/src/app/page/with-authjs-prisma.tsx +21 -9
- package/template/packages/src/app/page/with-authjs.tsx +16 -8
- package/template/packages/src/app/page/with-better-auth-drizzle.tsx +234 -0
- package/template/packages/src/app/page/with-better-auth-prisma.tsx +7 -3
- 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-drizzle.ts +20 -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
- package/LICENSE.md +0 -20
|
@@ -42,9 +42,9 @@ export default async function HomePage() {
|
|
|
42
42
|
{/* Logo */}
|
|
43
43
|
<picture className="relative">
|
|
44
44
|
<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" />
|
|
45
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
45
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
46
46
|
<img
|
|
47
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
47
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
48
48
|
alt="Logo"
|
|
49
49
|
width={65}
|
|
50
50
|
height={65}
|
|
@@ -52,12 +52,20 @@ export default async function HomePage() {
|
|
|
52
52
|
/>
|
|
53
53
|
</picture>
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
{user ? (
|
|
56
|
+
<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">
|
|
57
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
58
|
+
</h1>
|
|
59
|
+
) : (
|
|
60
|
+
<>
|
|
61
|
+
<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">
|
|
62
|
+
Lx2 Next.js App
|
|
63
|
+
</h1>
|
|
64
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
65
|
+
Build modern web applications with today's most popular tools
|
|
66
|
+
</p>
|
|
67
|
+
</>
|
|
68
|
+
)}
|
|
61
69
|
|
|
62
70
|
<div className="mt-12 flex items-center gap-3">
|
|
63
71
|
<a
|
|
@@ -124,7 +132,7 @@ export default async function HomePage() {
|
|
|
124
132
|
</span>
|
|
125
133
|
</h1>
|
|
126
134
|
|
|
127
|
-
{user
|
|
135
|
+
{user ? (
|
|
128
136
|
<form
|
|
129
137
|
action={async (formData: FormData) => {
|
|
130
138
|
"use server"
|
|
@@ -163,6 +171,10 @@ export default async function HomePage() {
|
|
|
163
171
|
+
|
|
164
172
|
</button>
|
|
165
173
|
</form>
|
|
174
|
+
) : (
|
|
175
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
176
|
+
Sign in to create posts
|
|
177
|
+
</p>
|
|
166
178
|
)}
|
|
167
179
|
</div>
|
|
168
180
|
|
|
@@ -38,9 +38,9 @@ export default async function HomePage() {
|
|
|
38
38
|
{/* Logo */}
|
|
39
39
|
<picture className="relative">
|
|
40
40
|
<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" />
|
|
41
|
-
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true" />
|
|
41
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true" />
|
|
42
42
|
<img
|
|
43
|
-
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
|
|
43
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/v1/public/logo.light.png?raw=true"
|
|
44
44
|
alt="Logo"
|
|
45
45
|
width={65}
|
|
46
46
|
height={65}
|
|
@@ -48,12 +48,20 @@ export default async function HomePage() {
|
|
|
48
48
|
/>
|
|
49
49
|
</picture>
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
{user ? (
|
|
52
|
+
<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">
|
|
53
|
+
Welcome, <span className="capitalize">{user.name}</span>!
|
|
54
|
+
</h1>
|
|
55
|
+
) : (
|
|
56
|
+
<>
|
|
57
|
+
<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">
|
|
58
|
+
Lx2 Next.js App
|
|
59
|
+
</h1>
|
|
60
|
+
<p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
61
|
+
Build modern web applications with today's most popular tools
|
|
62
|
+
</p>
|
|
63
|
+
</>
|
|
64
|
+
)}
|
|
57
65
|
|
|
58
66
|
<div className="mt-12 flex items-center gap-3">
|
|
59
67
|
<a
|
|
@@ -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}
|
|
@@ -148,7 +148,7 @@ export default async function HomePage() {
|
|
|
148
148
|
</span>
|
|
149
149
|
</h1>
|
|
150
150
|
|
|
151
|
-
{user
|
|
151
|
+
{user ? (
|
|
152
152
|
<form
|
|
153
153
|
action={async (formData: FormData) => {
|
|
154
154
|
"use server"
|
|
@@ -187,6 +187,10 @@ export default async function HomePage() {
|
|
|
187
187
|
+
|
|
188
188
|
</button>
|
|
189
189
|
</form>
|
|
190
|
+
) : (
|
|
191
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
192
|
+
Sign in to create posts
|
|
193
|
+
</p>
|
|
190
194
|
)}
|
|
191
195
|
</div>
|
|
192
196
|
|
|
@@ -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,20 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth"
|
|
2
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle"
|
|
3
|
+
import { nextCookies } from "better-auth/next-js"
|
|
4
|
+
|
|
5
|
+
import { env } from "@/env"
|
|
6
|
+
import { db } from "@/server/db"
|
|
7
|
+
|
|
8
|
+
export const auth = betterAuth({
|
|
9
|
+
database: drizzleAdapter(db, {
|
|
10
|
+
provider: "sqlite",
|
|
11
|
+
}),
|
|
12
|
+
baseURL: env.NEXT_PUBLIC_BETTER_AUTH_URL,
|
|
13
|
+
socialProviders: {
|
|
14
|
+
discord: {
|
|
15
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
16
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: [nextCookies()], // make sure nextCookies() is the last plugin in the array
|
|
20
|
+
})
|