create-lx2-app 0.7.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.
Files changed (54) hide show
  1. package/README.md +151 -0
  2. package/dist/index.js +68 -0
  3. package/package.json +92 -0
  4. package/template/base/README.md +57 -0
  5. package/template/base/_gitignore +41 -0
  6. package/template/base/next-env.d.ts +5 -0
  7. package/template/base/next.config.mjs +12 -0
  8. package/template/base/package.json +20 -0
  9. package/template/base/postcss.config.mjs +5 -0
  10. package/template/base/public/favicon.ico +0 -0
  11. package/template/base/src/env.js +40 -0
  12. package/template/packages/config/eslint.config.mjs +16 -0
  13. package/template/packages/config/payload/with-postgres.ts +39 -0
  14. package/template/packages/config/payload/with-sqlite.ts +42 -0
  15. package/template/packages/config/prettier.config.mjs +23 -0
  16. package/template/packages/config/tsconfig/base.json +42 -0
  17. package/template/packages/config/tsconfig/with-payload.json +43 -0
  18. package/template/packages/prisma/schema/base.prisma +21 -0
  19. package/template/packages/prisma/schema/with-authjs.prisma +86 -0
  20. package/template/packages/prisma/schema/with-better-auth.prisma +85 -0
  21. package/template/packages/src/app/(payload)/admin/[[...segments]]/not-found.tsx +27 -0
  22. package/template/packages/src/app/(payload)/admin/[[...segments]]/page.tsx +27 -0
  23. package/template/packages/src/app/(payload)/admin/importMap.js +1 -0
  24. package/template/packages/src/app/(payload)/api/[...slug]/route.ts +20 -0
  25. package/template/packages/src/app/(payload)/api/graphql/route.ts +8 -0
  26. package/template/packages/src/app/(payload)/api/graphql-playground/route.ts +8 -0
  27. package/template/packages/src/app/(payload)/custom.scss +0 -0
  28. package/template/packages/src/app/(payload)/layout.tsx +35 -0
  29. package/template/packages/src/app/api/auth/[...betterauth]/route.ts +5 -0
  30. package/template/packages/src/app/api/auth/[...nextauth]/route.ts +3 -0
  31. package/template/packages/src/app/globals/base.css +27 -0
  32. package/template/packages/src/app/layout/base.tsx +35 -0
  33. package/template/packages/src/app/page/base.tsx +98 -0
  34. package/template/packages/src/app/page/with-authjs-prisma.tsx +221 -0
  35. package/template/packages/src/app/page/with-authjs.tsx +126 -0
  36. package/template/packages/src/app/page/with-better-auth-prisma.tsx +245 -0
  37. package/template/packages/src/app/page/with-better-auth.tsx +151 -0
  38. package/template/packages/src/app/page/with-payload.tsx +136 -0
  39. package/template/packages/src/app/page/with-prisma.tsx +177 -0
  40. package/template/packages/src/env/with-authjs-db.js +52 -0
  41. package/template/packages/src/env/with-authjs.js +51 -0
  42. package/template/packages/src/env/with-better-auth-db.js +51 -0
  43. package/template/packages/src/env/with-better-auth.js +48 -0
  44. package/template/packages/src/env/with-db.js +44 -0
  45. package/template/packages/src/env/with-payload.js +46 -0
  46. package/template/packages/src/lib/auth/better-auth-client.ts +9 -0
  47. package/template/packages/src/payload/collections/Media.ts +16 -0
  48. package/template/packages/src/payload/collections/Users.ts +13 -0
  49. package/template/packages/src/server/auth/authjs.ts +5 -0
  50. package/template/packages/src/server/auth/config/authjs-with-prisma.ts +30 -0
  51. package/template/packages/src/server/auth/config/authjs.ts +27 -0
  52. package/template/packages/src/server/auth/config/better-auth-with-prisma.ts +21 -0
  53. package/template/packages/src/server/auth/config/better-auth.ts +16 -0
  54. package/template/packages/src/server/db/db-prisma.ts +23 -0
@@ -0,0 +1,151 @@
1
+ import { fileURLToPath } from "url"
2
+ import { headers } from "next/headers"
3
+ import { redirect } from "next/navigation"
4
+
5
+ import { auth } from "@/server/auth"
6
+
7
+ export default async function HomePage() {
8
+ const session = await auth.api.getSession({
9
+ headers: await headers(),
10
+ })
11
+ const user = session?.user
12
+
13
+ const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
14
+
15
+ return (
16
+ <main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
17
+ <header className="ml-auto">
18
+ {user ? (
19
+ <button
20
+ onClick={async () => {
21
+ "use server"
22
+ await auth.api.signOut({
23
+ headers: await headers(),
24
+ })
25
+ }}
26
+ className="cursor-pointer rounded-md bg-rose-400 px-4 py-2"
27
+ >
28
+ Sign Out
29
+ </button>
30
+ ) : (
31
+ <button
32
+ onClick={async () => {
33
+ "use server"
34
+ const response = await auth.api.signInSocial({
35
+ body: {
36
+ provider: "discord",
37
+ },
38
+ })
39
+ if (!response) {
40
+ throw new Error("Failed to sign in")
41
+ }
42
+ if (response.url) {
43
+ redirect(response.url)
44
+ }
45
+ }}
46
+ className="cursor-pointer rounded-md bg-purple-400 px-4 py-2"
47
+ >
48
+ Sign In
49
+ </button>
50
+ )}
51
+ </header>
52
+
53
+ <div className="flex grow flex-col items-center justify-center">
54
+ {/* Logo */}
55
+ <picture className="relative">
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" />
58
+ <img
59
+ src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
60
+ alt="Logo"
61
+ width={65}
62
+ height={65}
63
+ className="block h-auto max-w-full"
64
+ />
65
+ </picture>
66
+
67
+ {user ? (
68
+ <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">
69
+ Welcome, <span className="capitalize">{user.name}</span>!
70
+ </h1>
71
+ ) : (
72
+ <>
73
+ <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">
74
+ Lx2 Next.js App
75
+ </h1>
76
+ <p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
77
+ Build modern web applications with today&apos;s most popular tools
78
+ </p>
79
+ </>
80
+ )}
81
+
82
+ <div className="mt-12 flex items-center gap-3">
83
+ <a
84
+ href="https://create.lx2.dev"
85
+ target="_blank"
86
+ rel="noopener noreferrer"
87
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
88
+ >
89
+ Website
90
+ <svg
91
+ xmlns="http://www.w3.org/2000/svg"
92
+ viewBox="0 0 24 24"
93
+ strokeLinecap="round"
94
+ strokeLinejoin="round"
95
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
96
+ >
97
+ <path d="M7 7h10v10" />
98
+ <path d="M7 17 17 7" />
99
+ </svg>
100
+ </a>
101
+ <a
102
+ href="https://create.lx2.dev/docs"
103
+ target="_blank"
104
+ rel="noopener noreferrer"
105
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
106
+ >
107
+ Docs
108
+ <svg
109
+ xmlns="http://www.w3.org/2000/svg"
110
+ viewBox="0 0 24 24"
111
+ strokeLinecap="round"
112
+ strokeLinejoin="round"
113
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
114
+ >
115
+ <path d="M7 7h10v10" />
116
+ <path d="M7 17 17 7" />
117
+ </svg>
118
+ </a>
119
+ <a
120
+ href="https://github.com/SlickYeet/create-lx2-app"
121
+ target="_blank"
122
+ rel="noopener noreferrer"
123
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
124
+ >
125
+ GitHub
126
+ <svg
127
+ xmlns="http://www.w3.org/2000/svg"
128
+ viewBox="0 0 24 24"
129
+ strokeLinecap="round"
130
+ strokeLinejoin="round"
131
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
132
+ >
133
+ <path d="M7 7h10v10" />
134
+ <path d="M7 17 17 7" />
135
+ </svg>
136
+ </a>
137
+ </div>
138
+ </div>
139
+
140
+ <div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
141
+ <p className="m-0">Get started by editing </p>
142
+ <a
143
+ href={fileURL}
144
+ className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
145
+ >
146
+ <code>src/app/page.tsx</code>
147
+ </a>
148
+ </div>
149
+ </main>
150
+ )
151
+ }
@@ -0,0 +1,136 @@
1
+ import { fileURLToPath } from "url"
2
+ import config from "@payload-config"
3
+ import { headers as getHeaders } from "next/headers.js"
4
+ import { getPayload } from "payload"
5
+
6
+ import "./globals.css"
7
+
8
+ export default async function HomePage() {
9
+ const headers = await getHeaders()
10
+ const payloadConfig = await config
11
+ const payload = await getPayload({ config: payloadConfig })
12
+ const { user } = await payload.auth({ headers })
13
+
14
+ const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
15
+
16
+ return (
17
+ <main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
18
+ <div className="flex grow flex-col items-center justify-center">
19
+ {/* Logo */}
20
+ <picture className="relative">
21
+ <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" />
23
+ <img
24
+ src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
25
+ alt="Logo"
26
+ width={65}
27
+ height={65}
28
+ className="block h-auto max-w-full"
29
+ />
30
+ </picture>
31
+
32
+ {!user && (
33
+ <>
34
+ <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">
35
+ Lx2 Next.js App
36
+ </h1>
37
+ <p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
38
+ Build modern web applications with today&apos;s most popular tools
39
+ </p>
40
+ </>
41
+ )}
42
+ {user && (
43
+ <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">
44
+ Welcome back, {user.email}
45
+ </h1>
46
+ )}
47
+
48
+ <div className="mt-12 flex items-center gap-3">
49
+ <a
50
+ href={payloadConfig.routes.admin}
51
+ rel="noopener noreferrer"
52
+ target="_blank"
53
+ className="rounded-md bg-white px-2 py-1 text-black focus:opacity-80 focus:outline-none active:opacity-70 active:outline-none"
54
+ >
55
+ Go to admin panel
56
+ </a>
57
+ <a
58
+ href="https://payloadcms.com/docs"
59
+ rel="noopener noreferrer"
60
+ target="_blank"
61
+ className="rounded-md border border-white px-2 py-1 text-white focus:opacity-80 focus:outline-none active:opacity-70 active:outline-none"
62
+ >
63
+ Payload Docs
64
+ </a>
65
+ </div>
66
+
67
+ <div className="mt-12 flex items-center gap-3">
68
+ <a
69
+ href="https://create.lx2.dev"
70
+ target="_blank"
71
+ rel="noopener noreferrer"
72
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
73
+ >
74
+ Website
75
+ <svg
76
+ xmlns="http://www.w3.org/2000/svg"
77
+ viewBox="0 0 24 24"
78
+ strokeLinecap="round"
79
+ strokeLinejoin="round"
80
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
81
+ >
82
+ <path d="M7 7h10v10" />
83
+ <path d="M7 17 17 7" />
84
+ </svg>
85
+ </a>
86
+ <a
87
+ href="https://create.lx2.dev/docs"
88
+ target="_blank"
89
+ rel="noopener noreferrer"
90
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
91
+ >
92
+ Docs
93
+ <svg
94
+ xmlns="http://www.w3.org/2000/svg"
95
+ viewBox="0 0 24 24"
96
+ strokeLinecap="round"
97
+ strokeLinejoin="round"
98
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
99
+ >
100
+ <path d="M7 7h10v10" />
101
+ <path d="M7 17 17 7" />
102
+ </svg>
103
+ </a>
104
+ <a
105
+ href="https://github.com/SlickYeet/create-lx2-app"
106
+ target="_blank"
107
+ rel="noopener noreferrer"
108
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
109
+ >
110
+ GitHub
111
+ <svg
112
+ xmlns="http://www.w3.org/2000/svg"
113
+ viewBox="0 0 24 24"
114
+ strokeLinecap="round"
115
+ strokeLinejoin="round"
116
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
117
+ >
118
+ <path d="M7 7h10v10" />
119
+ <path d="M7 17 17 7" />
120
+ </svg>
121
+ </a>
122
+ </div>
123
+ </div>
124
+
125
+ <div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
126
+ <p className="m-0">Get started by editing </p>
127
+ <a
128
+ href={fileURL}
129
+ className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
130
+ >
131
+ <code>src/app/(frontend)/page.tsx</code>
132
+ </a>
133
+ </div>
134
+ </main>
135
+ )
136
+ }
@@ -0,0 +1,177 @@
1
+ import { fileURLToPath } from "url"
2
+ import { revalidatePath } from "next/cache"
3
+
4
+ import { db } from "@/server/db"
5
+
6
+ export default async function HomePage() {
7
+ const posts = await db.post.findMany()
8
+
9
+ const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
10
+
11
+ return (
12
+ <main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
13
+ <div className="flex grow flex-col items-center justify-center">
14
+ {/* Logo */}
15
+ <picture className="relative">
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" />
18
+ <img
19
+ src="https://github.com/SlickYeet/create-lx2-app/blob/main/docs/public/logo.light.png?raw=true"
20
+ alt="Logo"
21
+ width={65}
22
+ height={65}
23
+ className="block h-auto max-w-full"
24
+ />
25
+ </picture>
26
+
27
+ <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">
28
+ Lx2 Next.js App
29
+ </h1>
30
+ <p className="mt-4 text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
31
+ Build modern web applications with today&apos;s most popular tools
32
+ </p>
33
+
34
+ <div className="mt-12 flex items-center gap-3">
35
+ <a
36
+ href="https://create.lx2.dev"
37
+ target="_blank"
38
+ rel="noopener noreferrer"
39
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
40
+ >
41
+ Website
42
+ <svg
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ viewBox="0 0 24 24"
45
+ strokeLinecap="round"
46
+ strokeLinejoin="round"
47
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
48
+ >
49
+ <path d="M7 7h10v10" />
50
+ <path d="M7 17 17 7" />
51
+ </svg>
52
+ </a>
53
+ <a
54
+ href="https://create.lx2.dev/docs"
55
+ target="_blank"
56
+ rel="noopener noreferrer"
57
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
58
+ >
59
+ Docs
60
+ <svg
61
+ xmlns="http://www.w3.org/2000/svg"
62
+ viewBox="0 0 24 24"
63
+ strokeLinecap="round"
64
+ strokeLinejoin="round"
65
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
66
+ >
67
+ <path d="M7 7h10v10" />
68
+ <path d="M7 17 17 7" />
69
+ </svg>
70
+ </a>
71
+ <a
72
+ href="https://github.com/SlickYeet/create-lx2-app"
73
+ target="_blank"
74
+ rel="noopener noreferrer"
75
+ className="flex items-center rounded-md border border-white px-2 py-1 outline-none focus:opacity-80 active:opacity-70"
76
+ >
77
+ GitHub
78
+ <svg
79
+ xmlns="http://www.w3.org/2000/svg"
80
+ viewBox="0 0 24 24"
81
+ strokeLinecap="round"
82
+ strokeLinejoin="round"
83
+ className="mb-1.5 size-4 fill-none stroke-current stroke-2"
84
+ >
85
+ <path d="M7 7h10v10" />
86
+ <path d="M7 17 17 7" />
87
+ </svg>
88
+ </a>
89
+ </div>
90
+
91
+ <div className="mt-12 flex flex-col items-center gap-3">
92
+ <div className="mb-4">
93
+ <h1 className="mb-4 text-center">
94
+ <span className="text-2xl text-neutral-700 dark:text-neutral-300">
95
+ Posts {posts.length}
96
+ </span>
97
+ </h1>
98
+
99
+ <form
100
+ action={async (formData: FormData) => {
101
+ "use server"
102
+
103
+ const name =
104
+ formData.get("name")?.toString() ||
105
+ `New Post ${posts.length + 1}`
106
+
107
+ await db.post.create({
108
+ data: {
109
+ id: crypto.randomUUID(),
110
+ name,
111
+ },
112
+ })
113
+
114
+ revalidatePath("/")
115
+ }}
116
+ >
117
+ <input
118
+ type="text"
119
+ name="name"
120
+ placeholder="New Post"
121
+ className="h-8 rounded-md border border-neutral-300 px-2 outline-none dark:border-neutral-700 dark:bg-neutral-800"
122
+ />
123
+ <button
124
+ type="submit"
125
+ className="ml-2 size-8 cursor-pointer rounded-md bg-neutral-200 outline-none hover:opacity-80 focus:opacity-80 dark:bg-neutral-800"
126
+ >
127
+ +
128
+ </button>
129
+ </form>
130
+ </div>
131
+
132
+ <div className="grid w-full grid-cols-1 gap-2 space-y-2 sm:grid-cols-2">
133
+ {posts.map((post) => (
134
+ <div
135
+ key={post.id}
136
+ className="flex h-10 max-w-40 items-center rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
137
+ >
138
+ <span className="truncate text-sm text-neutral-700 dark:text-neutral-300">
139
+ {post.name}
140
+ </span>
141
+ <form
142
+ action={async () => {
143
+ "use server"
144
+
145
+ await db.post.delete({
146
+ where: { id: post.id },
147
+ })
148
+
149
+ revalidatePath("/")
150
+ }}
151
+ className="ml-auto"
152
+ >
153
+ <button
154
+ type="submit"
155
+ className="ml-2 cursor-pointer rounded-md text-rose-500 outline-none hover:opacity-80 focus:opacity-80"
156
+ >
157
+ x
158
+ </button>
159
+ </form>
160
+ </div>
161
+ ))}
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
167
+ <p className="m-0">Get started by editing </p>
168
+ <a
169
+ href={fileURL}
170
+ className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
171
+ >
172
+ <code>src/app/page.tsx</code>
173
+ </a>
174
+ </div>
175
+ </main>
176
+ )
177
+ }
@@ -0,0 +1,52 @@
1
+ import { createEnv } from "@t3-oss/env-nextjs"
2
+ import { z } from "zod"
3
+
4
+ export const env = createEnv({
5
+ /**
6
+ * Specify your server-side environment variables schema here. This way you can ensure the app
7
+ * isn't built with invalid env vars.
8
+ */
9
+ server: {
10
+ AUTH_SECRET:
11
+ process.env.NODE_ENV === "production"
12
+ ? z.string()
13
+ : z.string().optional(),
14
+ DISCORD_CLIENT_ID: z.string(),
15
+ DISCORD_CLIENT_SECRET: z.string(),
16
+ DATABASE_URL: z.string().url(),
17
+ NODE_ENV: z
18
+ .enum(["development", "test", "production"])
19
+ .default("development"),
20
+ },
21
+
22
+ /**
23
+ * Specify your client-side environment variables schema here. This way you can ensure the app
24
+ * isn't built with invalid env vars. To expose them to the client, prefix them with
25
+ * `NEXT_PUBLIC_`.
26
+ */
27
+ client: {
28
+ // NEXT_PUBLIC_CLIENTVAR: z.string(),
29
+ },
30
+
31
+ /**
32
+ * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
33
+ * middlewares) or client-side so we need to destruct manually.
34
+ */
35
+ runtimeEnv: {
36
+ AUTH_SECRET: process.env.AUTH_SECRET,
37
+ DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
38
+ DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
39
+ DATABASE_URL: process.env.DATABASE_URL,
40
+ NODE_ENV: process.env.NODE_ENV,
41
+ },
42
+ /**
43
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
44
+ * useful for Docker builds.
45
+ */
46
+ skipValidation: !!process.env.SKIP_ENV_VALIDATION,
47
+ /**
48
+ * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
49
+ * `SOME_VAR=''` will throw an error.
50
+ */
51
+ emptyStringAsUndefined: true,
52
+ })
@@ -0,0 +1,51 @@
1
+ import { createEnv } from "@t3-oss/env-nextjs"
2
+ import { z } from "zod"
3
+
4
+ export const env = createEnv({
5
+ /**
6
+ * Specify your server-side environment variables schema here. This way you can ensure the app
7
+ * isn't built with invalid env vars.
8
+ */
9
+ server: {
10
+ AUTH_SECRET:
11
+ process.env.NODE_ENV === "production"
12
+ ? z.string()
13
+ : z.string().optional(),
14
+ DISCORD_CLIENT_ID: z.string(),
15
+ DISCORD_CLIENT_SECRET: z.string(),
16
+ NODE_ENV: z
17
+ .enum(["development", "test", "production"])
18
+ .default("development"),
19
+ },
20
+
21
+ /**
22
+ * Specify your client-side environment variables schema here. This way you can ensure the app
23
+ * isn't built with invalid env vars. To expose them to the client, prefix them with
24
+ * `NEXT_PUBLIC_`.
25
+ */
26
+ client: {
27
+ // NEXT_PUBLIC_CLIENTVAR: z.string(),
28
+ },
29
+
30
+ /**
31
+ * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
32
+ * middlewares) or client-side so we need to destruct manually.
33
+ */
34
+ runtimeEnv: {
35
+ AUTH_SECRET: process.env.AUTH_SECRET,
36
+ DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
37
+ DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
38
+ NODE_ENV: process.env.NODE_ENV,
39
+ // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
40
+ },
41
+ /**
42
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
43
+ * useful for Docker builds.
44
+ */
45
+ skipValidation: !!process.env.SKIP_ENV_VALIDATION,
46
+ /**
47
+ * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
48
+ * `SOME_VAR=''` will throw an error.
49
+ */
50
+ emptyStringAsUndefined: true,
51
+ })
@@ -0,0 +1,51 @@
1
+ import { createEnv } from "@t3-oss/env-nextjs"
2
+ import { z } from "zod"
3
+
4
+ export const env = createEnv({
5
+ /**
6
+ * Specify your server-side environment variables schema here. This way you can ensure the app
7
+ * isn't built with invalid env vars.
8
+ */
9
+ server: {
10
+ NODE_ENV: z
11
+ .enum(["development", "test", "production"])
12
+ .default("development"),
13
+ DATABASE_URL: z.string().url(),
14
+ BETTER_AUTH_SECRET: z.string(),
15
+ DISCORD_CLIENT_ID: z.string(),
16
+ DISCORD_CLIENT_SECRET: z.string(),
17
+ },
18
+
19
+ /**
20
+ * Specify your client-side environment variables schema here. This way you can ensure the app
21
+ * isn't built with invalid env vars. To expose them to the client, prefix them with
22
+ * `NEXT_PUBLIC_`.
23
+ */
24
+ client: {
25
+ // NEXT_PUBLIC_CLIENTVAR: z.string(),
26
+ NEXT_PUBLIC_BETTER_AUTH_URL: z.string().url(),
27
+ },
28
+
29
+ /**
30
+ * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
31
+ * middlewares) or client-side so we need to destruct manually.
32
+ */
33
+ runtimeEnv: {
34
+ NODE_ENV: process.env.NODE_ENV,
35
+ DATABASE_URL: process.env.DATABASE_URL,
36
+ BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
37
+ NEXT_PUBLIC_BETTER_AUTH_URL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
38
+ DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
39
+ DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
40
+ },
41
+ /**
42
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
43
+ * useful for Docker builds.
44
+ */
45
+ skipValidation: !!process.env.SKIP_ENV_VALIDATION,
46
+ /**
47
+ * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
48
+ * `SOME_VAR=''` will throw an error.
49
+ */
50
+ emptyStringAsUndefined: true,
51
+ })
@@ -0,0 +1,48 @@
1
+ import { createEnv } from "@t3-oss/env-nextjs"
2
+ import { z } from "zod"
3
+
4
+ export const env = createEnv({
5
+ /**
6
+ * Specify your server-side environment variables schema here. This way you can ensure the app
7
+ * isn't built with invalid env vars.
8
+ */
9
+ server: {
10
+ NODE_ENV: z.enum(["development", "test", "production"]),
11
+ BETTER_AUTH_SECRET: z.string(),
12
+ DISCORD_CLIENT_ID: z.string(),
13
+ DISCORD_CLIENT_SECRET: z.string(),
14
+ },
15
+
16
+ /**
17
+ * Specify your client-side environment variables schema here. This way you can ensure the app
18
+ * isn't built with invalid env vars. To expose them to the client, prefix them with
19
+ * `NEXT_PUBLIC_`.
20
+ */
21
+ client: {
22
+ // NEXT_PUBLIC_CLIENTVAR: z.string(),
23
+ NEXT_PUBLIC_BETTER_AUTH_URL: z.string().url(),
24
+ },
25
+
26
+ /**
27
+ * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
28
+ * middlewares) or client-side so we need to destruct manually.
29
+ */
30
+ runtimeEnv: {
31
+ NODE_ENV: process.env.NODE_ENV,
32
+ // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
33
+ BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
34
+ NEXT_PUBLIC_BETTER_AUTH_URL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
35
+ DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
36
+ DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
37
+ },
38
+ /**
39
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
40
+ * useful for Docker builds.
41
+ */
42
+ skipValidation: !!process.env.SKIP_ENV_VALIDATION,
43
+ /**
44
+ * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
45
+ * `SOME_VAR=''` will throw an error.
46
+ */
47
+ emptyStringAsUndefined: true,
48
+ })