{"id":13521959,"url":"https://github.com/fredericbarthelet/typebridge","last_synced_at":"2026-03-05T16:02:41.223Z","repository":{"id":42122444,"uuid":"311653946","full_name":"fredericbarthelet/typebridge","owner":"fredericbarthelet","description":"Typescript toolbox for AWS EventBridge","archived":false,"fork":false,"pushed_at":"2022-11-01T13:51:14.000Z","size":45,"stargazers_count":77,"open_issues_count":7,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-27T12:00:53.336Z","etag":null,"topics":["aws","eventbridge","hacktoberfest","serverless","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/fredericbarthelet.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}},"created_at":"2020-11-10T12:39:10.000Z","updated_at":"2024-12-13T04:11:23.000Z","dependencies_parsed_at":"2022-08-30T22:40:30.822Z","dependency_job_id":null,"html_url":"https://github.com/fredericbarthelet/typebridge","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/fredericbarthelet/typebridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbarthelet%2Ftypebridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbarthelet%2Ftypebridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbarthelet%2Ftypebridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbarthelet%2Ftypebridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredericbarthelet","download_url":"https://codeload.github.com/fredericbarthelet/typebridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbarthelet%2Ftypebridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30134574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T15:35:27.018Z","status":"ssl_error","status_checked_at":"2026-03-05T15:35:23.768Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","eventbridge","hacktoberfest","serverless","typescript"],"created_at":"2024-08-01T06:00:40.242Z","updated_at":"2026-03-05T16:02:41.193Z","avatar_url":"https://github.com/fredericbarthelet.png","language":"TypeScript","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"# TypeBridge\n\nTypescript toolbox for AWS EventBridge\n\n## Advantages\n\n- Programmatical definition of your application events\n- Typed publish and consume APIs\n- Automatically batches `putEvents` call when publishing more than 10 events at a time\n- Check for event payload size before publishing\n\n## Quick install\n\n### Add typebridge dependency\n\n`npm i typebridge --save`\n\n\u003e Typebridge `v1` and above is meant to be used with [AWS SDK v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-eventbridge/index.html). If you want  to use Typebridge with AWS SDK v2, you should install `v0` versions of this package `npm i typebridge@^0`\n\n### Define your bus and events\n\n```ts\nimport { EventBridgeClient } from '@aws-sdk/client-eventbridge';\nimport { Bus, Event } from 'typebridge';\n\nexport const MyBus = new Bus({\n  name: 'applicationBus',\n  EventBridge: new EventBridgeClient({}),\n});\n\nexport const MyEventPayloadSchema = {\n  type: 'object',\n  properties: {\n    stringAttribute: { type: 'string' },\n    numberAttribute: { type: 'integer' },\n  },\n  required: ['stringAttribute'],\n  additionalProperties: false\n} as const;\n\nexport const MyEvent = new Event({\n  name: 'MyEvent',\n  bus: MyBus,\n  schema: MyEventPayloadSchema,\n  source: 'mySource'\n});\n```\n\n### Use the Event class to publish\n\n```ts\nimport { MyEvent } from './events.ts';\n\nexport const handler = async (event) =\u003e {\n  await MyEvent.publish({\n    stringAttribute: 'string',\n    numberAttribute: 12,\n  })\n\n  return 'Event published !'\n};\n```\n\nTypechecking is automatically enabled:\n\n```ts\n  await MyEvent.publish({\n    stringAttribute: 'string',\n    numberAttribute: 12,\n    // the following line will trigger a Typescript error\n    anotherAttribute: 'wrong'\n  })\n```\n### Use the Event class to create an event\n\n```ts\nimport { MyBus, MyEvent } from './events.ts';\n\nexport const handler = async (event) =\u003e {\n  const events = event.details.map(detail =\u003e MyEvent.create({\n    stringAttribute: detail.stringAttribute,\n    numberAttribute: detail.numberAttribute,\n  })\n  await MyBus.put(events);\n\n  return 'Event published !'\n};\n```\n\n### Use the Event class to generate trigger rules\n\nUsing the serverless framework with `serverless.ts` service file:\n\n\n```ts\nimport type { Serverless } from 'serverless/aws';\n\nconst serverlessConfiguration: Serverless = {\n  service: 'typebridge-test',\n  provider: {\n    name: 'aws',\n    runtime: 'nodejs12.x',\n  },\n  functions: {\n    hello: {\n      handler: 'MyEventHandler.handler',\n      events: [\n        {\n          eventBridge: {\n            eventBus: 'applicationBus',\n            pattern: NewUserConnectedEvent.pattern,\n          },\n        },\n      ],\n    }\n  }\n}\n\nmodule.exports = serverlessConfiguration;\n```\n\n### Use the Event class to type input event\n\n```ts\nimport { PublishedEvent } from 'typebridge';\nimport { MyEvent } from './events.ts';\n\nexport const handler = (event: PublishedEvent\u003ctypeof MyEvent\u003e) =\u003e {\n  // Typed as string\n  return event.detail.stringAttribute;\n}\n```\n\n### Use the Event class to validate the input event\n\nUsing [middy](https://github.com/middyjs/middy) middleware stack in your lambda's handler, you can throw an error before your handler's code being executed if the input event `source` or `detail-type` were not expected, or if the `detail` property does not satisfy the JSON-schema used in `MyEvent` constructor.\n\n```ts\nimport middy from '@middy/core';\nimport jsonValidator from '@middy/validator';\nimport { MyEvent } from './events.ts';\n\nconst handler = (event) =\u003e {\n  return 'Validation succeeded';\n};\n\n// If event.detail does not match the JSON-schema supplied to MyEvent constructor, the middleware will throw an error\nexport const main = middy(handler).use(\n  jsonValidator({ inputSchema: MyEvent.publishedEventSchema }),\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbarthelet%2Ftypebridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredericbarthelet%2Ftypebridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbarthelet%2Ftypebridge/lists"}