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