main.ts

From the guide Fastify authentication in TypeScript with Supabase: a full example. Placeholder values only: put your own keys in environment variables, never in the code.

main.tsTypeScriptRawExternal
// main.ts: starts the server. Run it with: node --env-file=.env main.ts
// package.json needs "type": "module": this file uses a top-level await.
import { buildApp } from './server.ts';
import { myProvider } from './provider.ts'; // your OAuthProvider: see the general guide, step 5
const app = buildApp({ provider: myProvider });
// 127.0.0.1 keeps the server on this machine. In a container, use host '0.0.0.0' so the container can reach it.
await app.listen({ port: 3000, host: '127.0.0.1' });

Back to the guide