RicSala prisma-hono-generator .cursorrules file for TypeScript

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

All Repositories (1)