# Lambda SQS Handler

AWS Lambda function that receives fix data and writes it to an SQS queue.

## Overview

This Lambda function:
1. Receives HTTP POST requests with fix data
2. Validates the payload structure
3. Writes the data to an SQS queue
4. Handles both single and batch messages efficiently

## Payload Format

```json
{
  "fixes": [
    {
      "accuracy": 0,
      "speed": 0,
      "source": "Test",
      "battery": 100,
      "hole": "1",
      "section": "2",
      "number": 2,
      "lat": -34.069763333333,
      "lng": 18.428193333333,
      "date": "2023-05-29T09:54:32.514Z"
    }
  ]
}
```

## AWS Setup Requirements

1. Create an SQS queue
2. Create a Lambda function with:
   - Runtime: Node.js 18.x
   - Handler: index.handler
   - Memory: 128 MB (adjustable based on load)
   - Timeout: 30 seconds
   - Environment variable: QUEUE_URL

3. IAM Role Permissions:
   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Action": [
           "sqs:SendMessage",
           "sqs:SendMessageBatch"
         ],
         "Resource": "arn:aws:sqs:region:account-id:queue-name"
       }
     ]
   }
   ```

## Deployment

1. Install dependencies:
```bash
npm install
```

2. Create a ZIP file containing:
   - index.js
   - node_modules/
   - package.json

3. Upload to AWS Lambda

## Error Handling

The function returns:
- 200: Success
- 400: Invalid payload format
- 500: Internal server error

## Monitoring

Monitor the function using CloudWatch:
- Invocation metrics
- Error logs
- SQS message metrics
