{"id":18573896,"url":"https://github.com/basedwon/picobuf","last_synced_at":"2025-05-15T23:34:14.420Z","repository":{"id":177742276,"uuid":"660838410","full_name":"basedwon/picobuf","owner":"basedwon","description":"Picobuf is a powerful and flexible library for working with Protocol Buffers in JavaScript.","archived":false,"fork":false,"pushed_at":"2023-08-01T00:51:31.000Z","size":661,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T09:41:00.539Z","etag":null,"topics":["data-modeling","encoding","foreign-keys","protobuf","service-oriented"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/basedwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","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}},"created_at":"2023-07-01T01:49:19.000Z","updated_at":"2023-07-20T01:53:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"59acb182-29de-4db3-b71e-773ae08f8066","html_url":"https://github.com/basedwon/picobuf","commit_stats":null,"previous_names":["basedwon/picobuf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fpicobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fpicobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fpicobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fpicobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedwon","download_url":"https://codeload.github.com/basedwon/picobuf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442359,"owners_count":22071863,"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":["data-modeling","encoding","foreign-keys","protobuf","service-oriented"],"created_at":"2024-11-06T23:13:20.316Z","updated_at":"2025-05-15T23:34:14.362Z","avatar_url":"https://github.com/basedwon.png","language":"JavaScript","readme":"# Picobuf\n\n\u003e good things come in small packets\n\n[![npm](https://img.shields.io/npm/v/picobuf?style=flat\u0026logo=npm)](https://www.npmjs.com/package/picobuf)\n[![pipeline](https://gitlab.com/basedwon/picobuf/badges/master/pipeline.svg)](https://gitlab.com/basedwon/picobuf/-/pipelines)\n[![license](https://img.shields.io/npm/l/picobuf)](https://gitlab.com/basedwon/picobuf/-/blob/master/LICENSE)\n[![downloads](https://img.shields.io/npm/dw/picobuf)](https://www.npmjs.com/package/picobuf) \n\n[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab\u0026color=%23383a40)](https://gitlab.com/basedwon/picobuf)\n[![Github](https://img.shields.io/badge/Github%20-%20?logo=github\u0026color=%23383a40)](https://github.com/basedwon/picobuf)\n[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter\u0026color=%23383a40)](https://twitter.com/basdwon)\n[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord\u0026color=%23383a40)](https://discordapp.com/users/basedwon)\n\nPicobuf is a powerful and flexible library for working with Protocol Buffers in JavaScript. It makes it easy to define models, enums, and services, and provides an intuitive API for encoding and decoding messages. Check out the [documentation](#documentation) to learn more.\n\n## Features\n\n- **Versatile Data Modeling**: Define your data structures using simple or composite fields, with support for lists and foreign keys.\n- **Encoding**: Built-in support for MsgPack and JSON, or bring your own encoder.\n- **Object Mode**: Or don't encode the data, rather use Picobuf just for data validation.\n- **Validation**: Rest easy knowing all of your nested data meets the defined model's schema.\n- **Data types as God intended**: String, Boolean, Number, Integer, Float, JSON, Buffer and Foreign relations\n- **Enums**: Tightly manage your data with enumerated fields, ensuring data integrity and simplifying validation.\n- **Service Methods**: Define arbitrary service methods and decouple your data models from the rest of your application.\n- **Isomorphic**: Picobuf works in both Node.js and the browser.\n- **Extendable**: Expand your possibilities with custom field types and validation rules.\n\n## Installation\n\nInstall the package with:\n\n```bash\nnpm install picobuf\n```\n\n## Usage\n\nFirst, import the `Picobuf` library.\n\n```js\nimport Picobuf from 'picobuf'\n```\nor\n```js\nconst Picobuf = require('picobuf')\n```\n\nThen define your models, enums or services.\n\n```js\n// create a picobuf instance\nconst picobuf = new Picobuf({ User: { name: 'string' }})\n\n// or destructure the named model\nconst { User } = new Picobuf({ User: { name: 'string' }})\n\n// create an instance of the model\nconst user = User.create({ name: 'Alice' })\n\n// validate this data (throws an error if invalid)\nUser.validate(user)\n\n// encode\nconst encoded = User.encode(user)\n\n// decode\nconst decoded = User.decode(encoded)\n\n// Enums\nconst { Types } = new Picobuf({ enums: { Types: { values: ['SEN', 'ACK'] }}})\n// or\nconst Types = pb.createEnum('Types', ['SEN', 'ACK'])\n\nconsole.log(Types.SEN) // =\u003e 'SEN'\nconsole.log(Types.getIndex('SEN')) // =\u003e 0\n// incorrect enum will throw an error\nconsole.log(Types.SEND) // =\u003e Invalid enum \"SEND\"\n\n// Services\nconst { echo } = new Picobuf({ services: {\n  echo: {\n    ping: { // echo.ping service method\n      request: 'User', // string reference to model\n      response: User, // direct use of model instance\n    }\n  }\n}})\nconst data = { name: 'Bob' }\nconst encoded = echo.ping.request.encode(data)\nconst decoded = echo.ping.request.decode(encoded)\n```\n\n## Documentation\n\n- [Basic Usage](/docs/basic-usage.md)\n- [Advanced Usage](/docs/advanced-usage.md)\n- [API Reference](/docs/api.md)\n- [Class Diagram](/docs/class-diagram.md)\n\n\u003cimg src=\"/docs/class-diagram.png\" alt=\"Picobuf class diagram\" height=\"260\" /\u003e\n\n## Tests\n\nIn order to run the test suite, simply clone the repository and install its dependencies:\n\n```bash\ngit clone https://gitlab.com/basedwon/picobuf.git\ncd picobuf\nnpm install\n```\n\nTo run the tests:\n\n```bash\nnpm test\n```\n\nTesting in the browser: *coming soon...*\n\n## Contributing\n\nThank you! Please see our [contributing guidelines](/docs/contributing.md) for details.\n\n## Donations\n\nIf you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!\n\n**Bitcoin (BTC):**\n```\n1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF\n```\n\n**Monero (XMR):**\n```\n46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ\n```\n\n## License\n\nPicobuf is [MIT licensed](https://gitlab.com/basedwon/picobuf/-/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fpicobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedwon%2Fpicobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fpicobuf/lists"}