{"id":28332176,"url":"https://github.com/luizcurti/serverless-localstack-node","last_synced_at":"2026-05-03T12:35:41.095Z","repository":{"id":290547954,"uuid":"974814251","full_name":"luizcurti/serverless-localstack-node","owner":"luizcurti","description":"A serverless AWS Lambda function to automatically resize images uploaded to an S3 bucket.","archived":false,"fork":false,"pushed_at":"2026-03-31T13:00:24.000Z","size":166,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-31T14:37:52.260Z","etag":null,"topics":["aws","docker-compose","lambda-functions","localstack","serverless-framework"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luizcurti.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-29T10:51:33.000Z","updated_at":"2026-03-31T13:00:43.000Z","dependencies_parsed_at":"2025-10-05T22:19:16.507Z","dependency_job_id":null,"html_url":"https://github.com/luizcurti/serverless-localstack-node","commit_stats":null,"previous_names":["luizcurti/serverless-localstack-node"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luizcurti/serverless-localstack-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fserverless-localstack-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fserverless-localstack-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fserverless-localstack-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fserverless-localstack-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luizcurti","download_url":"https://codeload.github.com/luizcurti/serverless-localstack-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fserverless-localstack-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32569714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","docker-compose","lambda-functions","localstack","serverless-framework"],"created_at":"2025-05-26T19:41:11.789Z","updated_at":"2026-05-03T12:35:41.086Z","avatar_url":"https://github.com/luizcurti.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Image Processing with LocalStack\n\nAn AWS Lambda function that automatically compresses images uploaded to S3. It resizes images to a maximum of **1280x720** pixels and converts them to **JPEG** at 50% quality, saving the result in the `compressed/` prefix of the same bucket.\n\n## Features\n\n- Triggered by S3 `ObjectCreated` events for `.jpg`, `.jpeg`, and `.png` files\n- Resizes images while preserving the original aspect ratio\n- Converts all supported formats to JPEG (50% quality, progressive)\n- Saves compressed images to the `compressed/` folder\n- Processes multiple images concurrently per invocation\n- Local development via LocalStack (no AWS account required)\n\n## Technologies\n\n- **Node.js 20.x**\n- **AWS Lambda + Amazon S3**\n- **Sharp** — high-performance image processing\n- **Serverless Framework v4**\n- **LocalStack** — local AWS emulation via Docker\n- **Jest** — unit and E2E test suite\n- **ESLint** (standard config)\n\n## Project Structure\n\n```\n├── src/index.js          # Lambda handler\n├── serverless.yml        # Serverless Framework configuration\n├── docker-compose.yml    # LocalStack setup\n├── jest.config.json      # Unit test configuration\n├── jest.e2e.config.json  # E2E test configuration\n├── roles/\n│   ├── init-scripts.sh   # Bucket and IAM setup script\n│   ├── policy.json       # S3 IAM policy\n│   └── trust-policy.json # Lambda trust policy\n├── uploads/              # Sample image for local testing\n└── tests/\n    ├── index.test.js     # Unit tests (mocked AWS SDK)\n    └── e2e.test.js       # E2E tests (real LocalStack)\n```\n\n## Prerequisites\n\n- Node.js 20.x or later\n- Docker and Docker Compose\n- AWS CLI (for manual S3 operations)\n- Serverless Framework CLI (`npm install -g serverless`)\n\n## Setup\n\n```sh\n# 1. Install dependencies\nnpm install\n\n# 2. Start LocalStack\ndocker compose up -d\n\n# 3. Create the S3 bucket and IAM resources\n./roles/init-scripts.sh\n```\n\n## Running Tests\n\n### Unit tests (no Docker required)\n\n```sh\nnpm test\n```\n\n### E2E tests (requires LocalStack running)\n\n```sh\ndocker compose up -d\nnpm run test:e2e\n```\n\n### Coverage report\n\n```sh\nnpm run test:coverage\n```\n\n### Watch mode\n\n```sh\nnpm run test:watch\n```\n\n## Local Deployment\n\nDeploy to LocalStack (uses `dev` stage):\n\n```sh\nnpm run deploy\n```\n\nInvoke the function locally with a sample event:\n\n```sh\nnpm run test:offline\n```\n\nUpload a test image to trigger the function:\n\n```sh\naws --endpoint-url=http://localhost:4566 s3 cp uploads/example-image.jpg s3://s3-bucket/uploads/example-image.jpg\n```\n\n## Deploying to AWS\n\n```sh\n# Deploy to the default stage\nnpm run deploy -- --stage prod\n\n# Or use the dedicated script\nnpm run publish:aws\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|---|---|---|\n| `BUCKET_NAME` | S3 bucket name | *(required)* |\n| `AWS_REGION` | AWS region | `eu-west-2` |\n| `AWS_ENDPOINT_URL` | Custom endpoint (LocalStack) | *(unset in production)* |\n\n## Linting\n\n```sh\nnpm run lint        # check\nnpm run lint:fix    # auto-fix\n```\n\n## Code QualityIf you need to remove the service:\n\n```sh\n\nLint your code:npm run remove:aws\n\n```\n\n```bash\n# Check for linting issues\nnpm run lint\n\n# Fix linting issues automatically\nnpm run lint:fix\n```\n\n## Project Structure\n\n```\n├── src/\n│   └── index.js          # Lambda function handler\n├── tests/\n│   ├── setup.js          # Jest test setup\n│   └── index.test.js     # Unit tests for Lambda function\n├── uploads/\n│   └── example-image.jpg # Test image\n├── roles/\n│   ├── init-scripts.sh   # IAM role setup scripts\n│   ├── policy.json       # IAM policy\n│   └── trust-policy.json # IAM trust policy\n├── .github/\n│   └── workflows/\n│       └── ci-cd.yml     # GitHub Actions workflow\n├── docker-compose.yml    # LocalStack configuration\n├── serverless.yml        # Serverless Framework configuration\n├── jest.config.json      # Jest configuration\n├── .eslintrc.json        # ESLint configuration\n├── event.json           # Test event data\n└── package.json         # Node.js dependencies and scripts\n```\n\n## Available Scripts\n\n### Development\n- `npm run deploy` - Deploy to LocalStack\n- `npm run start:local` - Start serverless offline\n- `npm run test:offline` - Test function with local event\n\n### Testing \u0026 Quality\n- `npm test` - Run tests\n- `npm run test:watch` - Run tests in watch mode\n- `npm run test:coverage` - Run tests with coverage report\n- `npm run lint` - Check code style\n- `npm run lint:fix` - Fix code style issues\n\n### Production\n- `npm run publish:aws` - Deploy to AWS (production)\n- `npm run remove:aws` - Remove AWS deployment\n\n## How It Works\n\n1. **Image Upload**: When an image is uploaded to the S3 bucket (uploads/ prefix)\n2. **Trigger**: S3 event triggers the Lambda function\n3. **Processing**: The function downloads the image, compresses it using Sharp\n4. **Storage**: Compressed image is saved to the compressed/ prefix in the same bucket\n\n## Configuration\n\nThe application is configured through environment variables and the `serverless.yml` file:\n\n- **BUCKET_NAME**: S3 bucket name for image storage\n- **AWS_REGION**: AWS region (default: eu-west-2)\n- **LocalStack Endpoint**: http://localhost:4566\n\n## CI/CD Pipeline\n\nThe project includes a GitHub Actions workflow that:\n\n1. **Tests**: Runs on Node.js 18.x and 20.x\n2. **Linting**: Ensures code quality with ESLint\n3. **Security**: Performs npm security audit\n4. **Coverage**: Generates test coverage reports\n5. **Integration Testing**: Tests against LocalStack\n6. **Deployment**: Automatic deployment to dev/prod environments\n\n### Required GitHub Secrets\n\nConfigure these secrets in your GitHub repository:\n\n- `AWS_ACCESS_KEY_ID`: AWS Access Key\n- `AWS_SECRET_ACCESS_KEY`: AWS Secret Key\n\n## Production Deployment\n\nTo deploy to AWS:\n\n```bash\nnpm run publish:aws\n```\n\nMake sure to configure your AWS credentials and update the `accountId` in `serverless.yml`.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Run tests and linting\n5. Submit a pull request\n\nThe CI/CD pipeline will automatically test your changes.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizcurti%2Fserverless-localstack-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizcurti%2Fserverless-localstack-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizcurti%2Fserverless-localstack-node/lists"}