mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
142 lines
4.4 KiB
Handlebars
142 lines
4.4 KiB
Handlebars
{{#if (eq orm "prisma")}}
|
|
import { betterAuth } from "better-auth";
|
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
import { expo } from "@better-auth/expo";
|
|
{{/if}}
|
|
import prisma from "../../prisma";
|
|
|
|
export const auth = betterAuth({
|
|
database: prismaAdapter(prisma, {
|
|
{{#if (eq database "postgres")}}provider: "postgresql"{{/if}}
|
|
{{#if (eq database "sqlite")}}provider: "sqlite"{{/if}}
|
|
{{#if (eq database "mysql")}}provider: "mysql"{{/if}}
|
|
{{#if (eq database "mongodb")}}provider: "mongodb"{{/if}}
|
|
}),
|
|
trustedOrigins: [
|
|
process.env.CORS_ORIGIN || "",
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
"my-better-t-app://",
|
|
{{/if}}
|
|
],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
}
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
, plugins: [expo()]
|
|
{{/if}}
|
|
});
|
|
{{/if}}
|
|
|
|
{{#if (eq orm "drizzle")}}
|
|
{{#if (or (eq runtime "bun") (eq runtime "node"))}}
|
|
import { betterAuth } from "better-auth";
|
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
import { expo } from "@better-auth/expo";
|
|
{{/if}}
|
|
import { db } from "../db";
|
|
import * as schema from "../db/schema/auth";
|
|
|
|
export const auth = betterAuth({
|
|
database: drizzleAdapter(db, {
|
|
{{#if (eq database "postgres")}}provider: "pg",{{/if}}
|
|
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
|
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
|
schema: schema,
|
|
}),
|
|
trustedOrigins: [
|
|
process.env.CORS_ORIGIN || "",
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
"my-better-t-app://",
|
|
{{/if}}
|
|
],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
},
|
|
secret: process.env.BETTER_AUTH_SECRET,
|
|
baseURL: process.env.BETTER_AUTH_URL,
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
plugins: [expo()],
|
|
{{/if}}
|
|
});
|
|
{{/if}}
|
|
|
|
{{#if (eq runtime "workers")}}
|
|
import { betterAuth } from "better-auth";
|
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
import { expo } from "@better-auth/expo";
|
|
{{/if}}
|
|
import { db } from "../db";
|
|
import * as schema from "../db/schema/auth";
|
|
import { env } from "cloudflare:workers";
|
|
|
|
export const auth = betterAuth({
|
|
database: drizzleAdapter(db, {
|
|
{{#if (eq database "postgres")}}provider: "pg",{{/if}}
|
|
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
|
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
|
schema: schema,
|
|
}),
|
|
trustedOrigins: [env.CORS_ORIGIN],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
},
|
|
secret: env.BETTER_AUTH_SECRET,
|
|
baseURL: env.BETTER_AUTH_URL,
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
plugins: [expo()],
|
|
{{/if}}
|
|
});
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
{{#if (eq orm "mongoose")}}
|
|
import { betterAuth } from "better-auth";
|
|
import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
import { expo } from "@better-auth/expo";
|
|
{{/if}}
|
|
import { client } from "../db";
|
|
|
|
export const auth = betterAuth({
|
|
database: mongodbAdapter(client),
|
|
trustedOrigins: [
|
|
process.env.CORS_ORIGIN || "",
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
"my-better-t-app://",
|
|
{{/if}}
|
|
],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
}
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
, plugins: [expo()]
|
|
{{/if}}
|
|
});
|
|
{{/if}}
|
|
|
|
{{#if (eq orm "none")}}
|
|
import { betterAuth } from "better-auth";
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
import { expo } from "@better-auth/expo";
|
|
{{/if}}
|
|
|
|
export const auth = betterAuth({
|
|
database: "", // Invalid configuration
|
|
trustedOrigins: [
|
|
process.env.CORS_ORIGIN || "",
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
"my-better-t-app://",
|
|
{{/if}}
|
|
],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
}
|
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
, plugins: [expo()]
|
|
{{/if}}
|
|
});
|
|
{{/if}}
|