{"id":20646716,"url":"https://github.com/cbartram/lamb-chop","last_synced_at":"2026-04-14T00:02:40.868Z","repository":{"id":42933097,"uuid":"237712320","full_name":"cbartram/Lamb-Chop","owner":"cbartram","description":"Write serverless routes like traditional server sided code.","archived":false,"fork":false,"pushed_at":"2023-01-06T02:30:29.000Z","size":473,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T10:17:06.206Z","etag":null,"topics":["api","aws","express","gateway","lambda","router","routes","serverless","syntax"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cbartram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-02T03:23:22.000Z","updated_at":"2021-12-01T23:36:53.000Z","dependencies_parsed_at":"2023-02-05T03:00:50.343Z","dependency_job_id":null,"html_url":"https://github.com/cbartram/Lamb-Chop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbartram%2FLamb-Chop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbartram%2FLamb-Chop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbartram%2FLamb-Chop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbartram%2FLamb-Chop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbartram","download_url":"https://codeload.github.com/cbartram/Lamb-Chop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242727201,"owners_count":20175726,"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","aws","express","gateway","lambda","router","routes","serverless","syntax"],"created_at":"2024-11-16T16:26:54.438Z","updated_at":"2026-04-14T00:02:40.836Z","avatar_url":"https://github.com/cbartram.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://i.imgur.com/UJFWYj3.png\" /\u003e\n\u003c/p\u003e\n\n# Lamb Chop\nLamb Chop provides an elegant and expressive syntax for using a single Lambda function as a proxy service for API Gateway routes. Write serverless code \nin a server oriented manner.\n\n## Getting Started\n\nBefore you can use this service make sure you setup your AWS API Gateway as a proxy service. You can create a single route which accepts any http request\nand path using the special `/{path+}`. Please see [this AWS document](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-http.html) for more\ninformation on setting up your lambda function as a proxy service.\n\n### Installing\n\nYou can install this package through NPM with\n\n```\nnpm i --save lambda-api-router\n```\n\nCheck out the following example for using the service in a live system:\n\n```javascript\nconst Api = require('lambda-api-router');\nconst app = new Api();\n\napp.get('/foo/bar', (req, res) =\u003e {\n    res.json({ success: true, test: 'Its working!', response: response.substring(0, 21) });\n});\n\napp.post('/foo/bar', (req, res) =\u003e {\n    // ...\n});\n\napp.put('/users/find', (req, res) =\u003e {\n    // ...\n});\n\napp.delete('/user/:id', (req, res) =\u003e {\n    // ...\n});\n\nexports.handler = async (event, context) =\u003e app.listen(event, context);\n\n```\n\n## Async Actions\n\nYou can also use asynchronous actions and promises within your route handlers:\n\n```javascript\nconst Api = require('lambda-api-router');\nconst request = require('request-promise-native');\n\nconst app = new Api();\n\napp.get('/foo/bar', async (req, res) =\u003e {\n    const response = await request('http://google.com');\n    res.json({ success: true, response: response.substring(0, 21) });\n});\n\nexports.handler = (event, context) =\u003e app.listen(event, context);\n```\n\n## Query \u0026 Request Params\n\nYou can easily access query and request parameters through `req.query` and `req.params` respectively.\n\n```javascript\nconst Api = require('lamb-chop');\n\nconst app = new Api();\n\napp.get('/foo/bar', (req, res) =\u003e {\n    res.json({ query: req.query, params: req.params });\n});\n\nexports.handler = (event, context) =\u003e app.listen(event, context);\n```\n\n## Set Response Status \u0026 Headers\n\nYou can easily access query and request parameters through `req.query` and `req.params` respectively.\n\n```javascript\nconst Api = require('lambda-api-router');\n\nconst app = new Api();\n\napp.get('/foo/bar', (req, res) =\u003e {\n    const headers = { \n        Accept: 'application/json',\n        'Content-Type': 'application/json'\n    };\n   \n    res.headers(headers)\n       .status(200)\n       .json({ query: req.query, params: req.params });\n});\n\nexports.handler = (event, context) =\u003e app.listen(event, context);\n```\n\n## Set Response Status \u0026 Headers\n\nYou can also add middleware to your routes. Middleware is simply a function which has access to the request and response objects\nwhich execute before the actual route handler is executed. Middleware is useful for things like checking authentication, adding headers,\nlogging and other common web tasks.\n\nYou can register middleware using the `use` function like so:\n\n```javascript\nconst Api = require('lambda-api-router');\nconst jwt = require('jsonwebtoken');\n\nconst app = new Api();\n\n// Logging Middleware\napp.use((req, res) =\u003e {\n    console.log(`[${req.httpMethod}] -- ${req.path} --`);\n});\n\n// Custom header Middleware\napp.use((req, res) =\u003e {\n    res.headers({\n       'X-Custom-Header': 'my-custom-value', \n    });\n});\n\n// Authentication Middleware\napp.use((req, res) =\u003e {\n    const token = req.body.token;\n    jwt.verify(token, 'shhhhh', function(err, decoded) {\n        console.log(decoded.foo) // bar\n        // if decoded.foo =\u003e proceed with request\n        // else return res.error({ ... });\n    });\n});\n\napp.get('/foo/bar', (req, res) =\u003e {\n    const headers = { \n        Accept: 'application/json',\n        'Content-Type': 'application/json'\n    };\n   \n    res.headers(headers)\n       .status(200)\n       .json({ query: req.query, params: req.params });\n});\n\nexports.handler = (event, context) =\u003e app.listen(event, context);\n```\n\n## Deployment\n\nThis is deployed through the deployment script called: `./scripts/publish.sh`.\n\n## Built With\n\n* [Node.JS](https://nodejs.org/en/) - The web framework used\n* [NPM](https://www.npmjs.com/) - Dependency Management\n* [Javascript](https://www.javascript.com/) - Programming language used\n* [Lambda](https://aws.amazon.com/lambda/) - Serverless web technology\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). \n\n## Authors\n\n* **Christian Bartram** - *Initial work* - [cbartram](https://github.com/cbartram)\n\nSee also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* Express for creating a great framework\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbartram%2Flamb-chop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbartram%2Flamb-chop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbartram%2Flamb-chop/lists"}