This is an example project demonstrating how to use @pbinj/pbj with Express and @auth/express for GitHub OAuth authentication.
- Node.js >= 18
- pnpm
- A GitHub account
- SQLite
- Clone the repository and install dependencies:
pnpm install-
Create a GitHub OAuth App:
- Go to GitHub Developer Settings
- Click "New OAuth App"
- Fill in the following:
- Application name:
PBinJ Express Example(or your preferred name) - Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/auth/callback/github
- Application name:
- Click "Register application"
- Copy your Client ID and generate a Client Secret
-
Create a
.env.localfile in the project root:
DATABASE_URL=file:local.db
DATABASE_AUTH_TOKEN=""
AUTH_SECRET=your_random_secret_here
AUTH_GITHUB_ID=your_github_client_id
AUTH_GITHUB_SECRET=your_github_client_secret- Start the development server:
pnpm run dev- Visit
http://localhost:3000in your browser
- GitHub OAuth authentication
- Session management
- SQLite database with Drizzle ORM
- TypeScript support
- Move common code to packages/pbj-express, packages/pbj-authjs, packages/pbj-drizzle.
- Add tests
- Add more providers.
src/index.ts- Express server setupauth.config.ts- Auth configurationauth.route.ts- Auth routes
views/- EJS templates
This is an example project demonstrating @pbinj/pbj features. If you find bugs or have suggestions, please open an issue in the main repository.
ISC