{"id":23176207,"url":"https://github.com/smartiniongithub/fastify-cloudevents","last_synced_at":"2025-09-10T14:19:00.316Z","repository":{"id":53159917,"uuid":"134916974","full_name":"smartiniOnGitHub/fastify-cloudevents","owner":"smartiniOnGitHub","description":"Fastify Plugin to manage events in the CloudEvents standard format","archived":false,"fork":false,"pushed_at":"2024-07-01T02:42:41.000Z","size":372,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-18T10:37:56.390Z","etag":null,"topics":["cloudevents","fastify","fastify-plugin"],"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/smartiniOnGitHub.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":"2018-05-26T00:39:27.000Z","updated_at":"2024-08-30T16:04:39.000Z","dependencies_parsed_at":"2024-05-02T09:49:51.685Z","dependency_job_id":"d1fd7c14-18bb-44e9-8400-20ba217cbc36","html_url":"https://github.com/smartiniOnGitHub/fastify-cloudevents","commit_stats":{"total_commits":248,"total_committers":4,"mean_commits":62.0,"dds":"0.012096774193548376","last_synced_commit":"0921c1d3b19489217ddb3972d90b36b20c8a3eaa"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/smartiniOnGitHub/fastify-cloudevents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartiniOnGitHub%2Ffastify-cloudevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartiniOnGitHub%2Ffastify-cloudevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartiniOnGitHub%2Ffastify-cloudevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartiniOnGitHub%2Ffastify-cloudevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartiniOnGitHub","download_url":"https://codeload.github.com/smartiniOnGitHub/fastify-cloudevents/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartiniOnGitHub%2Ffastify-cloudevents/sbom","scorecard":{"id":360142,"data":{"date":"2025-08-11","repo":{"name":"github.com/smartiniOnGitHub/fastify-cloudevents","commit":"f2e567c71d2d7efcddeb70251932bca0e34c3e75"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T10:37:57.313Z","repository_id":53159917,"created_at":"2025-08-18T10:37:57.313Z","updated_at":"2025-08-18T10:37:57.313Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274477325,"owners_count":25292857,"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","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cloudevents","fastify","fastify-plugin"],"created_at":"2024-12-18T06:15:52.631Z","updated_at":"2025-09-10T14:19:00.273Z","avatar_url":"https://github.com/smartiniOnGitHub.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-cloudevents\r\n\r\n  [![NPM Version](https://img.shields.io/npm/v/fastify-cloudevents.svg?style=flat)](https://npmjs.org/package/fastify-cloudevents/)\r\n  [![NPM Downloads](https://img.shields.io/npm/dm/fastify-cloudevents.svg?style=flat)](https://npmjs.org/package/fastify-cloudevents/)\r\n  [![Code Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\r\n  [![Known Vulnerabilities](https://snyk.io//test/github/smartiniOnGitHub/fastify-cloudevents/badge.svg?targetFile=package.json)](https://snyk.io//test/github/smartiniOnGitHub/fastify-cloudevents?targetFile=package.json)\r\n  [![license - APACHE-2.0](https://img.shields.io/npm/l/fastify-cloudevents.svg)](http://opensource.org/licenses/APACHE-2.0)\r\n\r\nFastify Plugin to transform events in/from the CloudEvents standard format.\r\n\r\nCurrent release uses the v1.0.2 of the CloudEvents Spec.\r\n\r\nThe purpose of this plugin is to let Fastify web applications create instances of CloudEvents \r\nin a simple way (with some useful defaults), or in a full way (all attributes).\r\nOptionally, it's possible to validate created instances to be sure they are compliant \r\nwith the standard.\r\nThen, created instances can be serialized, for example to be sent (or saved/stored) somewhere.\r\nIt's possible even to deserialize (parse) a string into a CloudEvent instance.\r\n\r\nOther features of the plugin: enable forwarding of Fastify events to given callbacks (using hooks), \r\nand wrapping main data of the original event in a specific CloudEvent instance.\r\n\r\n\r\nNote that all CloudEvents features exposed here are in the the library \r\n[cloudevent](https://npmjs.org/package/cloudevent/).\r\n\r\n\r\n## Usage\r\n\r\n```js\r\nconst fastify = require('fastify')()\r\n\r\n// define functions to use in plugin configuration:\r\n// idExample generator, callbackExample(ce) , etc ...\r\n\r\n// register the plugin with some options, for example:\r\nfastify.register(require('fastify-cloudevents'), {\r\n  serverUrl: 'http://0.0.0.0:3000',\r\n  idGenerator: idExample,\r\n  onRequestCallback: callbackExample,\r\n  onErrorCallback: callbackExample,\r\n  onResponseCallback: callbackExample,\r\n  cloudEventOptions: { }\r\n})\r\n\r\n// implementation ...\r\n\r\nfastify.listen({ port: 3000, host: 'localhost' }, (err, address) =\u003e {\r\n  if (err) throw err\r\n  console.log(`server listening on ${address}`)\r\n})\r\n```\r\n\r\nIn the [example](./example/) folder there are some simple server scripts \r\nthat uses the plugin (inline but it's the same using it from npm registry): \r\n- `example` is a simple one\r\n- `example-enhanced` is a more complex sample \r\n  to show even how to raise own events (normal, errors, and some custom)\r\n\r\n\r\n## Requirements\r\n\r\nFastify ^4.0.1 , Node.js 14 LTS (14.15.0) or later.\r\n\r\nNote that plugin releases 3.x are for Fastify 3.x, 4.x are for Fastify 4.x, etc.\r\n\r\n\r\n## Sources\r\n\r\nSource code is all inside main repo:\r\n[fastify-cloudevents](https://github.com/smartiniOnGitHub/fastify-cloudevents).\r\n\r\nDocumentation generated from source code (library API):\r\n[here](https://smartiniongithub.github.io/fastify-cloudevents/).\r\n\r\n\r\n## Note\r\n\r\nThe plugin decorate Fastify and expose some functions:\r\n- `CloudEvent`, the CloudEvent implementation, as a class\r\n- `CloudEventTransformer`, the CloudEventTransformer utility class\r\n- `JSONBatch`, the class to handle JSONBatch instances\r\n- `cloudEventJSONSchema`, the JSONSchema for a CloudEvent used in the plugin, as an object\r\n- `cloudEventSerializeFast`, a serialize function implemented here using `fast-json-stringify` \r\n  and not standard JSON serialization functions; note that similar features of the underlying library \r\n  has been implemented here (like serialization options)\r\n- `cloudEventValidateFast`, a validation function implemented here using `ajv` \r\n  (which is a dependency of `fast-json-stringify`) that uses a schema compiler\r\n\r\nPlugin options are:\r\n- `baseNamespace`, a base namespace for the `type`; more specific suffix \r\n  should be added to it in any CloudEvent\r\n- `cloudEventExtensions`, CloudEvent extensions to add in all generated events\r\n- `cloudEventOptions`, CloudEvent options common to all generated events; \r\n  anyway objects are copied to not be shared between instances\r\n- `idGenerator`, a generator function that returns the id (if possible, unique) for any CloudEvent\r\n- `includeHeaders`, a boolean flag to add request headers in generated CloudEvents when `true`\r\n  (by default is `false`)\r\n- `includeHttpAttributes`, a boolean flag to add some HTTP attributes in generated CloudEvents when `true`\r\n  (by default is `false`)\r\n- `includeRedundantAttributes`, a boolean flag to add some redundant attributes\r\n  in the data section of generated CloudEvents when `true` (by default is `false`)\r\n- `serverUrl`, the URL (absolute, or relative) of the current webapp, \r\n  to use as a base `source` in generated CloudEvents\r\n- `serverUrlMode`, the mode to build the `source` attribute in generated CloudEvents; \r\n  any not null value will cause this setting to be added to extensions (if set not null in plugin options):\r\n  - null, (default value) same as 'pluginAndRequestSimplified'\r\n    but without arguments (if any)\r\n  - 'pluginAndRequestSimplified', use the given `serverUrl` and add the current request url, \r\n  - 'pluginAndRequestUrl', use the given `serverUrl` and add the current request url\r\n  - 'pluginServerUrl', use only the given `serverUrl`\r\n  - 'requestUrl', use only the request url\r\n  - anything other, will raise an `Error`\r\n- `onCloseCallback`, callback to handle generated CloudEvents in Fastify hook `onClose`, for the plugin\r\n- `onErrorCallback`, callback to handle generated CloudEvents in Fastify hook `onError`\r\n- `onReadyCallback`, callback to handle the generated CloudEvent in Fastify lifecycle function `ready`, \r\n  for the plugin (when the plugin has been loaded)\r\n- `onRegisterCallback`, callback to handle generated CloudEvents in Fastify hook `onRegister`\r\n- `onRequestCallback`, callback to handle generated CloudEvents in Fastify hook `onRequest`\r\n- `onResponseCallback`, callback to handle generated CloudEvents in Fastify hook `onResponse`\r\n- `onRouteCallback`, callback to handle generated CloudEvents in Fastify hook `onRoute`\r\n- `onSendCallback`, callback to handle generated CloudEvents in Fastify hook `onSend`\r\n- `onTimeoutCallback`, callback to handle generated CloudEvents in Fastify hook `onTimeout`\r\n- `preHandlerCallback`, callback to handle generated CloudEvents in Fastify hook `preHandler`\r\n- `preParsingCallback`, callback to handle generated CloudEvents in Fastify hook `preParsing`\r\n- `preSerializationCallback`, callback to handle generated CloudEvents in Fastify hook `preSerialization`\r\n- `preValidationCallback`, callback to handle generated CloudEvents in Fastify hook `preValidation`\r\nall plugin options have a default value, so are optional.\r\n\r\nSee [README - cloudevent.js - GitHub](https://github.com/smartiniOnGitHub/cloudevent.js/blob/master/README.md) for more info on events.\r\nNote that all callbacks given to hooks accepts only a single argument: the generated CloudEvent instance, \r\nand *not* arguments like in error-first callbacks: (error, data), because here is not really needed.\r\nMost callbacks now here are async.\r\nSee [Hooks - Fastify reference - GitHub](https://github.com/fastify/fastify/blob/main/docs/Reference/Hooks.md) for more info on Fastify Hooks.\r\n\r\n\r\nNote that there is even the ability to validate CloudEvent instances \r\nin a stricter way, by setting to true the attribute 'strict' in constructor options; \r\nthat attribute (when set) will be put in the extensions of the instance.\r\nOtherwise you can specify it only during validation, in validation options.\r\n\r\nYou can find Code Documentation for the API of the library \r\n[here](https://smartiniongithub.github.io/cloudevent.js/).\r\n\r\nSince v0.2 of the spec, there is no more a standard attribute to specify the version \r\nof any specific event type, so the best if to follow their recommendations, \r\nand for example add a version in the 'type' attribute \r\n(for example '-v1.0.0' at the end of its base value, or at the end of its full value),\r\nor into the 'schemaurl' attribute but only its major version \r\n(like '-v1' or '/v1/' at the end).\r\nSince v0.3 of the spec, extensions are no more inside a specific attribute; \r\nas recommended even mine (for the 'strict' mode for example) has been moved into a namespaced one;\r\nplugin extensions ('serverUrlMode') has been moved in another (specific) namespace.\r\nSince v1.0 of the spec, some properties has been removed/simplified; \r\nextension properties must be simple (no nested properties) \r\nand must contain only lowercase letters and numbers in the name (and less than 20 chars in total); \r\nso for example my strict extension now is 'strictvalidation' with a boolean value.\r\nEven my plugin extension now is 'fastifyserverurlmode' with a string value.\r\n\r\nFor more info on the standard, see the [CloudEvents Specification](https://github.com/cloudevents/spec).\r\n\r\n\r\n## Contributing\r\n\r\n1. Fork it ( https://github.com/smartiniOnGitHub/fastify-cloudevents/fork )\r\n2. Create your feature branch (git checkout -b my-new-feature)\r\n3. Commit your changes (git commit -am 'Add some feature')\r\n4. Push to the branch (git push origin my-new-feature)\r\n5. Create a new Pull Request\r\n\r\n\r\n## License\r\n\r\nLicensed under [Apache-2.0](./LICENSE).\r\n\r\n----\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartiniongithub%2Ffastify-cloudevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartiniongithub%2Ffastify-cloudevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartiniongithub%2Ffastify-cloudevents/lists"}