Chat style:
- Act as a mentor, reasoning about the best practices and patterns to use in the project.
Code style:
- Use functional and declarative programming patterns over imperative patterns and OOP.
- For components, use function expressions over function declarations.
- Favor pure functions over impure functions.
Naming conventions:
- For components, use PascalCase.
- For functions, use camelCase.
- For variables, use camelCase.
- Do NOT use kebab-case for anything. Never.
Architecture:
- Favor clean architecture and domain driven design.
- Favor common design patterns that make the code easier to understand, maintain and scale.
Releases:
- Use semantic-release to manage the release process.
- Commit messages should follow the conventional commits specification.
- That is: type(scope?): description
# ABOUT THE PROJECT
# Prisma Hono Generator
## Overview
A Prisma generator for Nextjs that automatically creates type-safe Hono API routes from Prisma schema models, providing seamless integration between your database schema and API endpoints.
## Core Features
### Route Generation
- ✨ Generates complete CRUD routes for each Prisma model
- 🔒 Type-safe request/response handling using Zod schemas
- 🚦 Proper HTTP methods mapping (GET, POST, PUT, DELETE)
- ✅ Automatic parameter validation
- 🔍 Query parameter support for filtering and pagination
### Type Safety
- 🛡️ Leverages Zod for runtime validation
- 🔄 Uses generated Prisma types
- ⚠️ Proper error handling with type information
- 📝 Type-safe request bodies and responses
### Generated Code Features
- 🏗️ Clean code structure with consistent patterns
- 📚 Comprehensive comments and documentation
- 🚨 Robust error handling
- ⚡ Validation middleware
- 🔎 Query parameter parsing
- 📦 Response formatting
- 📘 Swagger/OpenAPI documentation generation
### Integration Features
- ⚡ Works with Vercel/Edge functions
- 🔄 Compatible with Next.js App Router
- 🔌 Support for custom middleware
- ✨ Support for custom validation rules
- 🛠️ Support for custom error handling
## Technical Stack
### Dependencies
- `prisma` (peer dependency)
- `hono`
- `zod`
- `@prisma/generator-helper`
- `ts-morph` for code manipulation and generation
- `zod-prisma-types` for generating Zod schemas from Prisma models
- `@prisma/client` for database operations
- `tsup` for building the project
### Development Environment
- TypeScript
- Vitest for testing
- ESLint + Prettier
- GitHub Actions for CI/CD
## Project Structure
prisma-generator-hono/
├── src/
│ ├── generator/
│ ├── templates/
│ └── utils/
├── examples/
│ ├── basic/
│ └── advanced/
├── tests/
├── docs/
├── package.json
└── README.md
## Error Handling
- 🔄 Prisma errors mapping to HTTP status codes
- ⚠️ Validation error formatting
- 📝 Custom error responses
- 🛡️ Type-safe error handling
## Documentation
- 📚 README with comprehensive examples
- 📘 API documentation
- 🔧 Configuration guide
- 👥 Contributing guide
- 🔄 Migration guide
- ❓ Troubleshooting guide
## Development Roadmap
### Phase 1: Core Functionality
- [ ] Basic CRUD route generation
- [ ] Basic validation
- [ ] Error handling
- [ ] Simple configuration
### Phase 2: Enhanced Features
- [ ] Swagger documentation
- [ ] Advanced filtering
- [ ] Relationship handling
- [ ] Custom validation rules
### Phase 3: Advanced Features
- [ ] Custom middleware support
- [ ] Advanced configuration options
- [ ] Performance optimizations
- [ ] Edge function support
### Phase 4: Documentation & Polish
- [ ] Complete documentation
- [ ] Examples
- [ ] Testing
- [ ] CI/CD setup
## Target Users
- Next.js developers
- Prisma users
- TypeScript developers
- API developers prioritizing type safety
- Developers working with edge functions
## Development Workflow
1. Write code in `src/`
2. Test with `examples/basic`
3. Run tests with `npm test`
4. Publish when ready
---
eslint
express.js
javascript
less
next.js
npm
prettier
prisma
+4 more
First Time Repository
TypeScript
Languages:
JavaScript: 0.2KB
TypeScript: 18.2KB
Created: 11/7/2024
Updated: 11/7/2024