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.
- package/README.md +151 -0
- package/dist/index.js +68 -0
- package/package.json +92 -0
- package/template/base/README.md +57 -0
- package/template/base/_gitignore +41 -0
- package/template/base/next-env.d.ts +5 -0
- package/template/base/next.config.mjs +12 -0
- package/template/base/package.json +20 -0
- package/template/base/postcss.config.mjs +5 -0
- package/template/base/public/favicon.ico +0 -0
- package/template/base/src/env.js +40 -0
- package/template/packages/config/eslint.config.mjs +16 -0
- package/template/packages/config/payload/with-postgres.ts +39 -0
- package/template/packages/config/payload/with-sqlite.ts +42 -0
- package/template/packages/config/prettier.config.mjs +23 -0
- package/template/packages/config/tsconfig/base.json +42 -0
- package/template/packages/config/tsconfig/with-payload.json +43 -0
- package/template/packages/prisma/schema/base.prisma +21 -0
- package/template/packages/prisma/schema/with-authjs.prisma +86 -0
- package/template/packages/prisma/schema/with-better-auth.prisma +85 -0
- package/template/packages/src/app/(payload)/admin/[[...segments]]/not-found.tsx +27 -0
- package/template/packages/src/app/(payload)/admin/[[...segments]]/page.tsx +27 -0
- package/template/packages/src/app/(payload)/admin/importMap.js +1 -0
- package/template/packages/src/app/(payload)/api/[...slug]/route.ts +20 -0
- package/template/packages/src/app/(payload)/api/graphql/route.ts +8 -0
- package/template/packages/src/app/(payload)/api/graphql-playground/route.ts +8 -0
- package/template/packages/src/app/(payload)/custom.scss +0 -0
- package/template/packages/src/app/(payload)/layout.tsx +35 -0
- package/template/packages/src/app/api/auth/[...betterauth]/route.ts +5 -0
- package/template/packages/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/template/packages/src/app/globals/base.css +27 -0
- package/template/packages/src/app/layout/base.tsx +35 -0
- package/template/packages/src/app/page/base.tsx +98 -0
- package/template/packages/src/app/page/with-authjs-prisma.tsx +221 -0
- package/template/packages/src/app/page/with-authjs.tsx +126 -0
- package/template/packages/src/app/page/with-better-auth-prisma.tsx +245 -0
- package/template/packages/src/app/page/with-better-auth.tsx +151 -0
- package/template/packages/src/app/page/with-payload.tsx +136 -0
- package/template/packages/src/app/page/with-prisma.tsx +177 -0
- package/template/packages/src/env/with-authjs-db.js +52 -0
- package/template/packages/src/env/with-authjs.js +51 -0
- package/template/packages/src/env/with-better-auth-db.js +51 -0
- package/template/packages/src/env/with-better-auth.js +48 -0
- package/template/packages/src/env/with-db.js +44 -0
- package/template/packages/src/env/with-payload.js +46 -0
- package/template/packages/src/lib/auth/better-auth-client.ts +9 -0
- package/template/packages/src/payload/collections/Media.ts +16 -0
- package/template/packages/src/payload/collections/Users.ts +13 -0
- package/template/packages/src/server/auth/authjs.ts +5 -0
- package/template/packages/src/server/auth/config/authjs-with-prisma.ts +30 -0
- package/template/packages/src/server/auth/config/authjs.ts +27 -0
- package/template/packages/src/server/auth/config/better-auth-with-prisma.ts +21 -0
- package/template/packages/src/server/auth/config/better-auth.ts +16 -0
- package/template/packages/src/server/db/db-prisma.ts +23 -0
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
DATABASE_URL: z.string().url(),
|
|
11
|
+
NODE_ENV: z
|
|
12
|
+
.enum(["development", "test", "production"])
|
|
13
|
+
.default("development"),
|
|
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
|
+
},
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
27
|
+
* middlewares) or client-side so we need to destruct manually.
|
|
28
|
+
*/
|
|
29
|
+
runtimeEnv: {
|
|
30
|
+
DATABASE_URL: process.env.DATABASE_URL,
|
|
31
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
32
|
+
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
36
|
+
* useful for Docker builds.
|
|
37
|
+
*/
|
|
38
|
+
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
39
|
+
/**
|
|
40
|
+
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
41
|
+
* `SOME_VAR=''` will throw an error.
|
|
42
|
+
*/
|
|
43
|
+
emptyStringAsUndefined: true,
|
|
44
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
PAYLOAD_SECRET: z.string().min(32),
|
|
11
|
+
DATABASE_URL: z.string().url(),
|
|
12
|
+
NODE_ENV: z
|
|
13
|
+
.enum(["development", "test", "production"])
|
|
14
|
+
.default("development"),
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
19
|
+
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
20
|
+
* `NEXT_PUBLIC_`.
|
|
21
|
+
*/
|
|
22
|
+
client: {
|
|
23
|
+
// NEXT_PUBLIC_CLIENTVAR: z.string(),
|
|
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
|
+
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET,
|
|
32
|
+
DATABASE_URL: process.env.DATABASE_URL,
|
|
33
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
34
|
+
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
38
|
+
* useful for Docker builds.
|
|
39
|
+
*/
|
|
40
|
+
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
41
|
+
/**
|
|
42
|
+
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
43
|
+
* `SOME_VAR=''` will throw an error.
|
|
44
|
+
*/
|
|
45
|
+
emptyStringAsUndefined: true,
|
|
46
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PrismaAdapter } from "@auth/prisma-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
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This is the Auth.js configuration for the application.
|
|
10
|
+
*
|
|
11
|
+
* @see https://authjs.dev/getting-started/installation
|
|
12
|
+
*/
|
|
13
|
+
export const authConfig: NextAuthConfig = {
|
|
14
|
+
adapter: PrismaAdapter(db),
|
|
15
|
+
providers: [
|
|
16
|
+
Discord({
|
|
17
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
18
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
19
|
+
}),
|
|
20
|
+
/**
|
|
21
|
+
* ...add more providers here.
|
|
22
|
+
*
|
|
23
|
+
* Most other providers require a bit more work than the Discord provider. For example, the
|
|
24
|
+
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
|
|
25
|
+
* model. Refer to the Auth.js docs for the provider you want to use. Example:
|
|
26
|
+
*
|
|
27
|
+
* @see https://authjs.dev/getting-started/providers/github
|
|
28
|
+
*/
|
|
29
|
+
],
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NextAuthConfig } from "next-auth"
|
|
2
|
+
import Discord from "next-auth/providers/discord"
|
|
3
|
+
|
|
4
|
+
import { env } from "@/env"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is the Auth.js configuration for the application.
|
|
8
|
+
*
|
|
9
|
+
* @see https://authjs.dev/getting-started/installation
|
|
10
|
+
*/
|
|
11
|
+
export const authConfig: NextAuthConfig = {
|
|
12
|
+
providers: [
|
|
13
|
+
Discord({
|
|
14
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
15
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
16
|
+
}),
|
|
17
|
+
/**
|
|
18
|
+
* ...add more providers here.
|
|
19
|
+
*
|
|
20
|
+
* Most other providers require a bit more work than the Discord provider. For example, the
|
|
21
|
+
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
|
|
22
|
+
* model. Refer to the Auth.js docs for the provider you want to use. Example:
|
|
23
|
+
*
|
|
24
|
+
* @see https://authjs.dev/getting-started/providers/github
|
|
25
|
+
*/
|
|
26
|
+
],
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PrismaClient } from "@prisma/client"
|
|
2
|
+
import { betterAuth } from "better-auth"
|
|
3
|
+
import { prismaAdapter } from "better-auth/adapters/prisma"
|
|
4
|
+
import { nextCookies } from "better-auth/next-js"
|
|
5
|
+
|
|
6
|
+
import { env } from "@/env"
|
|
7
|
+
|
|
8
|
+
const prisma = new PrismaClient()
|
|
9
|
+
|
|
10
|
+
export const auth = betterAuth({
|
|
11
|
+
database: prismaAdapter(prisma, {
|
|
12
|
+
provider: "sqlite",
|
|
13
|
+
}),
|
|
14
|
+
socialProviders: {
|
|
15
|
+
discord: {
|
|
16
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
17
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
plugins: [nextCookies()], // make sure nextCookies() is the last plugin in the array
|
|
21
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth"
|
|
2
|
+
import { nextCookies } from "better-auth/next-js"
|
|
3
|
+
import Database from "better-sqlite3"
|
|
4
|
+
|
|
5
|
+
import { env } from "@/env"
|
|
6
|
+
|
|
7
|
+
export const auth = betterAuth({
|
|
8
|
+
database: new Database("./db.sqlite"),
|
|
9
|
+
socialProviders: {
|
|
10
|
+
discord: {
|
|
11
|
+
clientId: env.DISCORD_CLIENT_ID,
|
|
12
|
+
clientSecret: env.DISCORD_CLIENT_SECRET,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
plugins: [nextCookies()], // make sure nextCookies() is the last plugin in the array
|
|
16
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PrismaClient } from "@prisma/client"
|
|
2
|
+
|
|
3
|
+
import { env } from "@/env"
|
|
4
|
+
|
|
5
|
+
const createPrismaClient = () =>
|
|
6
|
+
new PrismaClient({
|
|
7
|
+
log:
|
|
8
|
+
env.NODE_ENV === "development"
|
|
9
|
+
? [
|
|
10
|
+
// "query",
|
|
11
|
+
"error",
|
|
12
|
+
"warn",
|
|
13
|
+
]
|
|
14
|
+
: ["error"],
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const globalForPrisma = globalThis as unknown as {
|
|
18
|
+
prisma: ReturnType<typeof createPrismaClient> | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const db = globalForPrisma.prisma ?? createPrismaClient()
|
|
22
|
+
|
|
23
|
+
if (env.NODE_ENV !== "production") globalForPrisma.prisma = db
|