{"id":17835072,"url":"https://github.com/namesmt/lambda-voie","last_synced_at":"2026-01-26T09:32:45.568Z","repository":{"id":62355076,"uuid":"527254717","full_name":"NamesMT/lambda-voie","owner":"NamesMT","description":"A very opinionated AWS Lambda router","archived":false,"fork":false,"pushed_at":"2024-06-15T15:26:37.000Z","size":768,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T16:37:54.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/NamesMT.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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":["NamesMT"]}},"created_at":"2022-08-21T15:57:59.000Z","updated_at":"2024-06-15T15:26:40.000Z","dependencies_parsed_at":"2022-10-31T10:49:14.360Z","dependency_job_id":"e108e7db-9b8f-46ab-9f16-97bd4cced23d","html_url":"https://github.com/NamesMT/lambda-voie","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"d0aa0fb0ef52aa52f5bc78576b08d71fdad3e08b"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Flambda-voie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Flambda-voie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Flambda-voie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Flambda-voie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NamesMT","download_url":"https://codeload.github.com/NamesMT/lambda-voie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246923839,"owners_count":20855630,"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":[],"created_at":"2024-10-27T20:16:44.971Z","updated_at":"2026-01-26T09:32:45.524Z","avatar_url":"https://github.com/NamesMT.png","language":"TypeScript","funding_links":["https://github.com/sponsors/NamesMT"],"categories":[],"sub_categories":[],"readme":"# Lambda Voie\n\n![TypeScript](https://img.shields.io/badge/TYPESCRIPT-%23007ACC.svg?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\n![AWS](https://img.shields.io/badge/AWS-%23FF9900.svg?style=for-the-badge\u0026logo=amazon-aws\u0026logoColor=white)\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Codecov][codecov-src]][codecov-href]\n[![License][license-src]][license-href]\n\n## Project archived  \n**Voie** was initially created to migrate some old projects to Typescript and a more modern router engine, aiming to be as effortlessly as possible, as well as a personal experience development *(also because there was no known good existing package that meets the needs at the time)*.  \nFor newer projects, I recommend moving to `Hono` or Unjs's `Nitro`/`H3`.  \nWhile a fan of Unjs, currently I would prefer `Hono` because their documentation covers a lot more things, and their middleware + generics binding + RPC is really good, also things like lambda response stream + compression just work!\n\n---\n\n**Voie** (French word for \"way/path/lane/route\", English for... \"Very Opinionated Itinerary Editor\"?)  \nNah, just a random word I came up for this package, haha.  \n\n**Voie** is a simple router + middleware wrapper/engine for AWS Lambda with the main purpose of making things easier.\n\n## Features\n\n- [**find-my-way:**](https://github.com/delvedor/find-my-way) A **crazy fast** (used by [Fastify](https://fastify.dev/benchmarks)) HTTP router, internally uses an highly performant Radix Tree (aka compact Prefix Tree), supports route params, wildcards.\n- **Clean syntax:** `app.route(method, path, handler)`, chainable to add middlewares easily: [Example](#deployed-indexmjs-example)\n- **Packed to relieve headache:**\n  - **event.route:** easy access object that contains:\n    - **{** **method**, **path**, **params:** *postBody*+searchParams+[parametricRoute](https://github.com/delvedor/find-my-way#supported-path-formats), ***cookies*** **}**\n      - *postBody*: event.body is automatically parsed and added to params if is object type\n      - ***cookies***: event.cookies will be parsed to Record type if exists, can be undefined.\n  - **response(statusCode, body, options):** with support for `compress`\n  - **plugins**:\n    - **cors**: app.use(cors, { routes: ['/corsEnabledPath/*', 'someAPI'] })\n\n## Usage\n\n### Install package:\n\n```sh\n# npm\nnpm install lambda-voie\n\n# yarn\nyarn add lambda-voie\n\n# pnpm (recommended)\npnpm install lambda-voie\n```\n\n### Import:\n\n```ts\n// This package exports as ESM only (index.mjs)\nimport { Voie } from 'lambda-voie'\n```\n\n### Deployed `index.mjs` example:\n```ts\nimport {\n  Voie,\n  // Built-in cors plugin:\n  cors,\n  // Lambda-configured pino-logger:\n  logger,\n} from 'lambda-voie'\n\nconst app = new Voie({\n  // You can pass in your own logger:\n  // logger: console\n})\n\n// Using plugins:\napp.use(cors, {\n  // paths: ['*'] // default enable for all paths\n})\n// Its actually just a simple wrapper for:\n// app.route('OPTIONS', '*')\n\napp.setDefaultRoute((event, context) =\u003e app.respone(400, {\n  message: 'Route not found',\n  // Voie by default adds a route object to event for easy access: { method, path, params, cookies }\n  routeInfo: event.route\n}))\n\n// You can access the current instance's logger this way\napp.logger.info('hi')\n\n// Register the route (GET /test)\napp.route('GET', '/test', (event, context) =\u003e ({\n  statusCode: 200,\n  body: 'Success',\n  before: event.addedByBefore,\n  willBeAddedChangedByAfter: 4,\n\n  alsoAddedByAnotherBefore: event.addedByBefore2,\n}))\n  .before((event, context) =\u003e { event.addedByBefore = 'Hi' })\n  // Note that in \"after\" middlewares, when using the app.response() function,\n  // The res body is already stringified/compressed.\n  .after((event, context, res) =\u003e { res.willBeChangedByAfter = res.willBeChangedByAfter * 4 })\n\n// You can get registered route by calling the same function (omit the handler):\napp.route('GET', '/test')\n  // Registering more middlewares:\n  .before((event, context) =\u003e { event.addedByBefore2 = 'Hi' })\n  .after((event, context, res) =\u003e { res.addedByAfter = 'This wasnt defined' })\n\n// Expected response of GET /test:\n// {\n//   statusCode: 200,\n//   body: 'Success',\n//   before: 'Hi',\n//   willBeChangedByAfter: 160,\n//   alsoAddedByAnotherBefore: 'Hi',\n//   addedByAfter: 'This wasnt defined',\n// }\n\n// Voie also supports handling trigger events:\napp.eventRoute('aws:s3', 'log S3 PutObject', (Record, context) =\u003e {\n  if (Record.eventName === 'ObjectCreated:Put')\n    logger.info(`S3 Put: ${Record.s3.bucket.name}/${Record.s3.object.key}`)\n})\n\n// Export the handler from handle() function and we're ready for Lambda!\nexport const handler = app.handle()\n```\n\nFor advanced use cases, you can extend the class and modify Voie's behavior:\n```ts\n// Override the makeOnHandler to no longer adds route object to event, and instead adds a tracking ID\nclass MyVoie extends Voie {\n  makeOnHandler(route: Route) {\n    return this._lookupTransform(({ method, url, event, context, params, store, searchParams }) =\u003e {\n      // const requestParams = { ...searchParams, ...params }\n\n      // event.route = { method, url, params: requestParams }\n\n      event._trackingId = '🦄'\n\n      return this.routeHandler(route, event, context)\n    })\n  }\n}\n```\n\n## Roadmap\n\n- [x] Refactor autoCors option\n  \u003e (currently we have to both set the autoCors option and register the OPTIONS route with autoCors)  \n  \u003e **Updated**: use the included 'cors' plugin.\n- [ ] Split the base router class to another repo?\n- [ ] Creates a template (boiler-plate) repo\n- [ ] Includes some advanced examples\n- [x] Make it easy to test routes locally\n  \u003e You could do: `app._lookupShims(fakeEvent(method, path, eventSpread))`\n- [ ] Find a way to supports?: [**response streaming**](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/)\n  - [Referrence Resource 1](https://github.com/astuyve/lambda-stream)\n  - [Referrence Resource 2](https://advancedweb.hu/how-to-use-the-aws-lambda-streaming-response-type/)\n  - [Referrence Resource 3](https://github.com/dherault/serverless-offline/issues/1681)\n\n## License\n\n[MIT](./LICENSE) License © 2023 [NamesMT](https://github.com/NamesMT)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/lambda-voie?style=flat\u0026colorA=18181B\u0026colorB=F0DB4F\n[npm-version-href]: https://npmjs.com/package/lambda-voie\n[npm-downloads-src]: https://img.shields.io/npm/dm/lambda-voie?style=flat\u0026colorA=18181B\u0026colorB=F0DB4F\n[npm-downloads-href]: https://npmjs.com/package/lambda-voie\n[codecov-src]: https://img.shields.io/codecov/c/gh/namesmt/lambda-voie/main?style=flat\u0026colorA=18181B\u0026colorB=F0DB4F\n[codecov-href]: https://codecov.io/gh/namesmt/lambda-voie\n[license-src]: https://img.shields.io/github/license/namesmt/lambda-voie.svg?style=flat\u0026colorA=18181B\u0026colorB=F0DB4F\n[license-href]: https://github.com/namesmt/lambda-voie/blob/main/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Flambda-voie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamesmt%2Flambda-voie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Flambda-voie/lists"}