{"id":19289820,"url":"https://github.com/brefphp/local-api-gateway","last_synced_at":"2025-04-05T04:10:43.598Z","repository":{"id":63686787,"uuid":"569894283","full_name":"brefphp/local-api-gateway","owner":"brefphp","description":"Run API Gateway locally against your HTTP Lambda containers","archived":false,"fork":false,"pushed_at":"2024-10-28T10:09:20.000Z","size":48,"stargazers_count":36,"open_issues_count":2,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T03:06:33.527Z","etag":null,"topics":["api-gateway","aws-lambda","docker"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brefphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"mnapoli","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://bref.sh/#enterprise"}},"created_at":"2022-11-23T21:31:23.000Z","updated_at":"2025-03-02T08:11:08.000Z","dependencies_parsed_at":"2024-12-22T18:11:41.174Z","dependency_job_id":"cbb91cbd-9b26-4968-8860-581e41e6bce9","html_url":"https://github.com/brefphp/local-api-gateway","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"b8c40488dcab93e81efe5efd6838c0ed3a9c8c71"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flocal-api-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flocal-api-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flocal-api-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brefphp%2Flocal-api-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brefphp","download_url":"https://codeload.github.com/brefphp/local-api-gateway/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284949,"owners_count":20913704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api-gateway","aws-lambda","docker"],"created_at":"2024-11-09T22:17:18.176Z","updated_at":"2025-04-05T04:10:43.572Z","avatar_url":"https://github.com/brefphp.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mnapoli","https://bref.sh/#enterprise"],"categories":[],"sub_categories":[],"readme":"This project lets you run HTTP Lambda applications locally.\n\n## Why\n\nAWS Lambda containers (like Bref containers) can run locally, but they must be invoked via the [Runtime Interface Emulator API](https://docs.aws.amazon.com/lambda/latest/dg/images-test.html), which is not practical. Here's an example with `curl`:\n\n```bash\n# Run your Lambda function\ndocker run --rm -it -p 8080:8080 -v $(PWD):/var/task bref/php-80-fpm public/index.php\n\n# Call your function\ncurl -XPOST \"http://localhost:8080/2015-03-31/functions/function/invocations\" -d '{ http event goes here }'\n```\n\nThat sucks 👎\n\nIf you use Lambda + API Gateway, you probably just want **to access your app via HTTP**… like any other HTTP application. This project does that.\n\n## Usage\n\nThis project publishes a `bref/local-api-gateway` Docker image. \n\nThis image creates a local API Gateway (i.e. HTTP server) that forwards HTTP requests to your Lambda function running in Docker.\n\nThe only thing it needs is a `TARGET` environment variable that contains the endpoint of your Lambda function: `\u003chost\u003e:\u003cport\u003e` (the default port of Lambda [RIE](https://docs.aws.amazon.com/lambda/latest/dg/images-test.html) is `8080`).\n\n### Example\n\nExample of `docker-compose.yml`:\n\n```yaml\nversion: \"3.5\"\n\nservices:\n  \n    # This container runs API Gateway locally\n    web:\n        image: bref/local-api-gateway\n        ports: ['8000:8000']\n        environment:\n            # \u003chost\u003e:\u003cport\u003e -\u003e the host here is \"php\" because that's the name of the second container\n            TARGET: 'php:8080'\n            \n    # Example of container running AWS Lambda locally\n    php:\n        image: bref/php-80-fpm\n        # The command should contain the Lambda handler\n        command: public/index.php\n        volumes:\n            - .:/var/task:ro\n```\n\nIf you need to change the default listening port, you can set the `LISTEN_PORT` environment variable value to whatever port you wish to use.\n\n## Static assets\n\nIf you want a quick and easy way to serve static assets, mount your files in the `bref/local-api-gateway` container and set the `DOCUMENT_ROOT` env var to the root of the assets.\n\n`DOCUMENT_ROOT` is relative to `/var/task` (the root of the app), so it can contain `.` if your assets are in the root of the app.\n\nFor example:\n\n```yaml\nservices:\n    web:\n        image: bref/local-api-gateway\n        ports: ['8000:8000']\n        volumes:\n            - .:/var/task:ro\n        environment:\n            TARGET: 'php:8080'\n            DOCUMENT_ROOT: public\n            \n    # ...\n```\n\n## FAQ\n\n### This vs Serverless Offline\n\n[Serverless Offline](https://www.serverless.com/plugins/serverless-offline) doesn't work with Bref, and doesn't work great if you run your Lambda in containers.\n\nThis project will be useful to you if you are in that case, or simply if you don't use Serverless Framework.\n\nHowever, if you use Serverless Framework with JS, Python or another supported language, Serverless Offline is probably a better choice.\n\n### Does this support API Gateway routes?\n\nNo. To discover routes (and how they map to Lambda functions), we would have to parse CloudFormation templates/serverless.yml/CDK files/Terraform files/Pulumi files/etc. That's too much work for now :)\n\nThis project is mostly useful for people running web frameworks (like Laravel, Symfony, etc.) in Lambda, and don't use API Gateway's routing.\n\n### Does this support API Gateway features?\n\nNo, this is a very simple HTTP server. It does not support API Gateway features like CORS, authorizers, etc.\n\n### How are parallel requests handled?\n\nThe Lambda RIE does not support parallel requests. This project handles them by \"queueing\" requests. If a request is already being processed, the next request will be queued and processed when the first request is done.\n\nThis works up to 10 requests in parallel by default. You can change this limit by setting the `DEV_MAX_REQUESTS_IN_PARALLEL` environment variable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrefphp%2Flocal-api-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrefphp%2Flocal-api-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrefphp%2Flocal-api-gateway/lists"}