A TypeScript authentication service that runs on Bun. OpenAuth handles Google OAuth sign-in. PostgreSQL stores users and OpenAuth data through Drizzle ORM. Zod validates configuration and Google user data.
- Bun
1.4.4-canary.1 - A PostgreSQL database
- A Google Cloud project with an OAuth 2.0 web application client
git clone https://github.com/yopem/auth.git
cd auth
bun install --frozen-lockfile-
Copy
.env.exampleto.env. SetDATABASE_URL,GOOGLE_CLIENT_ID, andGOOGLE_CLIENT_SECRET. SetPORT=3999for the examples below. -
In Google Cloud, add
http://localhost:3999/google/callbackas an authorized redirect URI for local development. For production, addhttps://your-domain/google/callbackwith your public domain. -
Apply the existing database migrations:
bun run db:migrate
If you change the database schema, run
bun run db:generateto create a migration before you apply it.
bun run devWith PORT=3999, the service listens at http://localhost:3999.
Set the production environment variables and apply the database migrations before you start the service. To build and run the standalone executable:
bun run build
bun run startBuild the Docker image before you create .env, or build from a clean checkout.
The Dockerfile copies the build directory. Do not include secrets in it.
docker build -t yopem-auth .Run the container from the repository root with your .env file. Set
DATABASE_URL to a database address that the container can reach.
docker run --rm --env-file .env -e PORT=3999 -p 3999:3999 yopem-auth