<!-- Source: https://www.wappi.dev/deployment -->

# Deployment

Wappi applications can be deployed to various platforms, both as serverless functions and traditional servers.

## Serverless Deployment

### Vercel

```bash
# Install Vercel CLI
npm i -g vercel

# Deploy
vercel
```

Create `vercel.json`:

```json
{
  "version": 2,
  "builds": [
    {
      "src": "src/index.ts",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "src/index.ts"
    }
  ]
}
```

### AWS Lambda

```bash
# Build for production
npm run build

# Deploy with Serverless Framework
serverless deploy
```

## Traditional Server Deployment

### Docker

Create `Dockerfile`:

```dockerfile
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .
RUN npm run build

EXPOSE 3000

CMD ["npm", "start"]
```

### PM2

```bash
# Install PM2
npm install -g pm2

# Start application
pm2 start ecosystem.config.js

# Monitor
pm2 monit
```

Create `ecosystem.config.js`:

```typescript
module.exports = {
  apps: [{
    name: 'wappi-api',
    script: 'dist/index.js',
    instances: 'max',
    exec_mode: 'cluster',
    env: {
      NODE_ENV: 'production',
      PORT: 3000
    }
  }]
}
```

## Environment Setup

### Production Environment Variables

```bash
NODE_ENV=production
DATABASE_URL=your-production-database-url
JWT_SECRET=your-production-secret
PORT=3000
```

### Health Checks

Wappi includes built-in health check endpoints:

- `GET /health` - Basic health check
- `GET /health/detailed` - Detailed system status

URL: https://www.wappi.dev/deployment
