# Slack to ntfy Middleware

A lightweight Go service that acts as a middleware between Slack webhooks and ntfy servers, with Bearer token authentication and basic authentication support.

## Features

- ✅ Parses Slack webhook format
- ✅ Forwards alerts to self-hosted ntfy servers
- ✅ Bearer token authentication support
- ✅ Health check endpoint
- ✅ Lightweight Docker container (~8.8MB)
- ✅ High performance and low resource usage

## Quick Start

1. **Configure the service**:
   ```bash
   # Edit docker-compose.yml and set:
   # - NTFY_BASE_URL=https://your-ntfy-server.com
   # - NTFY_TOKEN=tk_your_bearer_token
   # OR
   # - NTFY_USERNAME=your_username
   # - NTFY_PASSWORD=your_password
   ```

2. **Run the service**:
   ```bash
   docker compose up -d
   ```

3. **Configure Slack**:
   - Go to Slack Integrations → Incoming Webhooks
   - Add new webhook
   - Webhook URL: `http://your-server-ip:8080/your-topic-name`

4. **Test the service**:
   ```bash
   # Test webhook
   curl -X POST http://localhost:8080/test-topic \
        -H 'Content-Type: application/json' \
        -d '{"text": "Test alert from Slack to ntfy"}'
   
   # Check health
   curl http://localhost:8080/health
   ```

## Configuration

| Environment Variable | Default | Description |
|---------------------|---------|-------------|
| `NTFY_BASE_URL` | `https://ntfy.sh` | Your ntfy server URL (without topic) |
| `NTFY_TOKEN` | `""` | Bearer token for ntfy authentication |
| `NTFY_USERNAME` | `""` | Username for ntfy basic authentication |
| `NTFY_PASSWORD` | `""` | Password for ntfy basic authentication |
| `BIND_ADDRESS` | `0.0.0.0` | Interface to bind to |
| `BIND_PORT` | `8080` | Port to listen on |

## Development

### Build locally
```bash
make build
make run
```

### Build Docker image
```bash
make docker-build
```

### Run tests
```bash
make test
```

## License

MIT License
