A modern, fast API built with Hono framework, featuring PostgreSQL database integration with Drizzle ORM, structured logging with Pino, and TypeScript for type safety.
- Runtime: Node.js
- Framework: Hono
- Database: PostgreSQL with Drizzle ORM
- Logging: Pino with pino-http and pino-pretty for development
- Validation: Zod
- Linting/Formatting: Biome
- TypeScript: Full type safety
- Bun installed on your system
- PostgreSQL database running
- Install dependencies with Bun:
bun install- Set up environment variables:
cp .env.example .env
# Edit .env with your database configurationRequired environment variables:
DATABASE_URL: PostgreSQL connection stringLOG_LEVEL: Logging level (fatal/error/warn/info/debug/trace/silent)
- Run database migrations:
bun run db:migrateStart the development server with hot reload:
bun run devThe API will be available at http://localhost:3000
src/
├── app.ts # Main application setup and route mounting
├── index.ts # Application entry point
├── env.ts # Environment configuration and validation
├── database/
│ ├── db.ts # Database connection setup
│ └── schema.ts # Database schema definitions
├── lib/
│ ├── create-app.ts # Application factory with middleware setup
│ └── pino.ts # Pino logger configuration
├── middlewares/
│ ├── not-found.ts # 404 handler
│ ├── on-error.ts # Error handler
│ ├── pino-logger.ts # Request logging middleware
│ └── serve-emoji-favicon.ts # Favicon middleware
├── routers/
│ └── posts.ts # Posts API routes
└── types/
└── app-bindings.ts # TypeScript type definitions
app.ts: Main application file that mounts all routers.index.ts: Application entry point. Allows to easily change the server runtime, without impacting the application code.lib/create-app.ts: Factory function that creates a Hono app with all necessary middlewaredatabase/: Database configuration and schema definitions using Drizzle ORMrouters/: API route handlers organized by featuremiddlewares/: Custom hono middlewaresenv.ts: Environment variable validation using Zod schemas