# {{appName}} API

RESTful API server built with Express and TypeScript for the Vibes monorepo.

## Getting Started

### Prerequisites

- Node.js (version 18 or higher)
- pnpm
{{#if includeDatabase}}
- PostgreSQL (or use Docker)
{{/if}}

### Installation

Install dependencies:

```bash
pnpm install
```

### Environment Setup

1. Copy the example environment file:

```bash
cp .env.example .env
```

2. Update the `.env` file with your configuration values.

{{#if includeDatabase}}
### Database Setup

1. Start PostgreSQL (or use Docker):

```bash
docker-compose up -d postgres
```

2. Run migrations:

```bash
pnpm db:migrate
```

3. Generate Prisma client:

```bash
pnpm db:generate
```

4. (Optional) Seed the database:

```bash
pnpm db:seed
```
{{/if}}

### Development

Start the development server:

```bash
pnpm dev
```

The API will be available at `http://localhost:{{port}}`

### Building

Build the project:

```bash
pnpm build
```

### Production

Start the production server:

```bash
pnpm start
```

## Project Structure

```
{{appName}}/
├── src/
│   ├── config/        # Configuration files
│   ├── middleware/    # Express middleware
│   ├── routes/        # API routes
│   ├── services/      # Business logic
│   ├── utils/         # Utility functions
│   ├── types/         # TypeScript type definitions
{{#if includeDatabase}}
│   ├── db/            # Database client and helpers
{{/if}}
{{#if includeGraphQL}}
│   ├── graphql/       # GraphQL schema and resolvers
{{/if}}
│   ├── app.ts         # Express app setup
│   └── index.ts       # Server entry point
{{#if includeDatabase}}
├── prisma/
│   ├── schema.prisma  # Database schema
│   └── seed.ts        # Database seeding
{{/if}}
├── .env.example       # Environment variables example
├── Dockerfile         # Docker configuration
├── tsconfig.json      # TypeScript configuration
└── package.json       # Dependencies and scripts
```

## Features

{{#if includeAuth}}
- 🔐 JWT Authentication
{{/if}}
{{#if includeDatabase}}
- 🗄️ PostgreSQL database with Prisma ORM
{{/if}}
{{#if includeValidation}}
- ✅ Request validation with Zod
{{/if}}
{{#if includeSwagger}}
- 📖 Swagger/OpenAPI documentation
{{/if}}
{{#if includeGraphQL}}
- 🚀 GraphQL support with Apollo Server
{{/if}}
- 🛡️ Security headers with Helmet
- 🚦 Rate limiting
- 📝 Structured logging with Winston
- 🐳 Docker support
- 🧪 Jest testing setup

## API Endpoints

### Health Check

```
GET /health
```

{{#if includeAuth}}
### Authentication

```
POST /auth/register
POST /auth/login
POST /auth/refresh
GET  /auth/me
```
{{/if}}

{{#if includeSwagger}}
### API Documentation

Visit `http://localhost:{{port}}/api-docs` for Swagger documentation.
{{/if}}

{{#if includeGraphQL}}
### GraphQL

Visit `http://localhost:{{port}}/graphql` for GraphQL playground.
{{/if}}

## Scripts

- `pnpm dev` - Start development server with hot reload
- `pnpm build` - Build for production
- `pnpm start` - Start production server
- `pnpm test` - Run tests
- `pnpm lint` - Run ESLint
- `pnpm typecheck` - Run TypeScript type checking
{{#if includeDatabase}}
- `pnpm db:migrate` - Run database migrations
- `pnpm db:generate` - Generate Prisma client
- `pnpm db:push` - Push schema to database
- `pnpm db:seed` - Seed database
{{/if}}
- `pnpm docker:build` - Build Docker image
- `pnpm docker:run` - Run Docker container

## Docker

Build and run with Docker:

```bash
# Build image
docker build -t {{appName}} .

# Run container
docker run -p {{port}}:{{port}} {{appName}}
```

{{#if includeDatabase}}
Or use Docker Compose:

```bash
docker-compose up
```
{{/if}}

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License.