@g-1/example
v0.1.3
Published
Example application demonstrating the `@g-1/core` framework
Maintainers
Readme
@g-1/example
A complete example application demonstrating how to build production-ready APIs with the @g-1/core framework.the @g-1/core framework.
Features
- 🚀 Built on Cloudflare Workers for edge performance
- 🔐 Authentication with better-auth
- 📊 Database integration with Drizzle ORM
- 🛡️ Comprehensive security middleware
- 📝 OpenAPI documentation with Scalar
- ⚡ Rate limiting and request validation
- 🧪 Testing setup with Vitest
- 📦 Modular architecture with @g-1/templates
Quick Start
Install dependencies:
bun installSet up environment variables:
cp .env.example .env # Edit .env with your configurationGenerate authentication secret:
bun run auth:generateSet up database:
bun run db:generate bun run db:migrateStart development server:
bun run dev
Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| BETTER_AUTH_SECRET | Secret key for authentication (min 32 chars) | Yes |
| BETTER_AUTH_URL | Base URL for auth callbacks | Yes |
| RESEND_API_KEY | API key for email service | No |
| FROM_EMAIL | Email address for outgoing emails | No |
Scripts
bun run dev- Start development serverbun run build- Build for productionbun run deploy- Deploy to Cloudflare Workersbun run test- Run testsbun run lint- Lint codebun run db:generate- Generate database migrationsbun run db:migrate- Apply database migrations
Architecture
This boilerplate uses the @g-1/core framework which provides:
- Core Framework (
@g-1/core): Router, middleware, utilities - Templates (
@g-1/templates): Pre-built auth, database, and API routes - Utilities (
@g-1/util): Shared utility functions
Deployment
Configure Cloudflare:
bun run cf:loginSet up D1 database:
wrangler d1 create g1-api-db # Update wrangler.toml with database_idSet up KV namespace:
wrangler kv:namespace create "MY_API_PROJECT_KV_AUTH" # Update wrangler.toml with namespace idDeploy:
bun run deploy
License
MIT
