* auth

* Add default user

* setup auth

* add auth to all endpoints

* Add url logging

* Add tomato.gg

* Add analytics

* Add correct url

* fix auth

* log url

* change base url

* replace api

* wip

* Test

* test changes

* bump

* Add trusted origin

* f

* i almost give up

* stop using middleware

* Fix auth

* Fix build
This commit is contained in:
Bill Yang 2025-02-15 15:55:28 -05:00 committed by GitHub
parent 0871ed0ef7
commit 0dc058749d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1515 additions and 128 deletions

27
server/src/lib/auth.ts Normal file
View file

@ -0,0 +1,27 @@
import { betterAuth } from "better-auth";
import pg from "pg";
import { username } from "better-auth/plugins";
import dotenv from "dotenv";
dotenv.config();
export const auth = betterAuth({
basePath: "/auth",
database: new pg.Pool({
host: process.env.POSTGRES_HOST || "postgres",
port: parseInt(process.env.POSTGRES_PORT || "5432", 10),
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
}),
emailAndPassword: {
enabled: true,
},
plugins: [username()],
trustedOrigins: [
"http://localhost:3002",
"http://localhost:3001",
"https://tracking.tomato.gg",
"https://tomato.gg",
],
});