{"id":15755972,"url":"https://github.com/simenandre/pubsub-http-handler","last_synced_at":"2025-07-18T07:05:31.670Z","repository":{"id":36989470,"uuid":"324809243","full_name":"simenandre/pubsub-http-handler","owner":"simenandre","description":"Handle Google PubSub requests with ease ⚙️","archived":false,"fork":false,"pushed_at":"2025-06-22T11:52:52.000Z","size":844,"stargazers_count":2,"open_issues_count":18,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-14T23:23:56.525Z","etag":null,"topics":["fastify","fastify-plugin","google","google-pubsub","google-pubsub-handler","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/simenandre.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,"zenodo":null}},"created_at":"2020-12-27T17:06:08.000Z","updated_at":"2023-04-21T18:22:32.000Z","dependencies_parsed_at":"2024-05-08T23:33:13.071Z","dependency_job_id":"45029022-6014-42c3-b76c-2505044ebd26","html_url":"https://github.com/simenandre/pubsub-http-handler","commit_stats":null,"previous_names":["cobraz/pubsub-http-handler"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/simenandre/pubsub-http-handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simenandre%2Fpubsub-http-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simenandre%2Fpubsub-http-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simenandre%2Fpubsub-http-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simenandre%2Fpubsub-http-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simenandre","download_url":"https://codeload.github.com/simenandre/pubsub-http-handler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simenandre%2Fpubsub-http-handler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265716306,"owners_count":23816354,"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":["fastify","fastify-plugin","google","google-pubsub","google-pubsub-handler","nodejs"],"created_at":"2024-10-04T08:41:21.104Z","updated_at":"2025-07-18T07:05:31.645Z","avatar_url":"https://github.com/simenandre.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PubSub HTTP Handler\n\n![PubSub HTTP Handler](.github/header.jpg)\n\nPubSub HTTP Handler is a simple Typescript/Javascript package that solves\nserving an HTTP endpoint that can consume PubSub messages. To do this task we\nutilize the [Fastify][] framework or Google Cloud Functions.\n\nThis package was built so that when creating microservices that subscribe to a\nPubSub-topic, we don't have to implement a server or validate the request.\n\n## Quickstart\n\n```shell\n▶ yarn add pubsub-http-handler\n```\n\n## Example with Fastify Server\n\n```typescript\nimport Fastify from 'fastify';\nimport { pubSubFastifyPlugin, PubSubHandler } from 'pubsub-http-handler';\n\ninterface MyHandler {\n  hello: string;\n  world: string;\n}\n\nconst server = async () =\u003e {\n  const handler: PubSubHandler\u003cMyHandler\u003e = ({ message, data }) =\u003e {\n    // `message` contains attributes, data (as string), messageId\n    // `data` contains a base64 decoded JSON serialized object (type is MyHandler in the example)\n    // ...\n  };\n\n  const app = Fastify().withTypeProvider\u003cTypeBoxTypeProvider\u003e();\n\n  app.register(pubSubFastifyPlugin, makePubSubConfig({ handler }));\n\n  await app.listen(8000);\n};\n```\n\n## Example with Google Cloud Functions\n\n```typescript\nimport { pubSubCloudFunction, PubSubHandler } from 'pubsub-http-handler';\n\ninterface MyHandler {\n  hello: string;\n  world: string;\n}\n\nexport const helloWorld = createPubSubCloudFunctions\u003cMyHandler\u003e(\n  ({ data, log }) =\u003e {\n    log.info(`Hello, ${data.name}`);\n  },\n);\n```\n\nRead more about [configuration here][configuration] or check out the [API\ndocumentation][docs]\n\n## Options\n\n- `onError` (function, default is undefined). Use to ensure that the function\n  doesn't throw. **Warning:** Using this option will make the function return\n  `204` regardless.\n\n- `parseJson` (boolean, default is `true`). When set to true, uses `JSON.parse`\n  to parse the data sent through PubSub.\n\n- `parser` (function, optional). This option can be used to parse data coming\n  from PubSub. The function must return data (this data is passed to the\n  handler, as `data`). You can optionally throw an exception if the data could\n  not be parsed, which in turn can be caught by `onError` if you'd like.\n\nWe export a function called `makePubSubConfig` to help with type inference. This\nis basicly a function that lets you return a function while using `parser`,\nwhich is returned in `handler`. If you know a way for the types to work without\nusing a function like this, we would love a pull request!\n\n## Contributing\n\nWe love contributions! 🙏 Bug reports and pull requests are welcome on [GitHub].\n\n[banner]: ./assets/banner.jpg\n[npm]: https://www.npmjs.com/package/pubsub-http-handler\n[fastify]: https://www.fastify.io/\n[configuration]: ./docs/interfaces/pubsubconfig.md\n[docs]: ./docs/\n[github]: https://github.com/cobraz/pubsub-http-handler/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimenandre%2Fpubsub-http-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimenandre%2Fpubsub-http-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimenandre%2Fpubsub-http-handler/lists"}