@alepha/protobuf 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +34 -0
  2. package/package.json +5 -8
package/README.md CHANGED
@@ -1 +1,35 @@
1
1
  # @alepha/protobuf
2
+
3
+ Alepha Protobuf is a simple protobuf adapter for Alepha.
4
+ It uses TypeBox Schema to define the protobuf schema and serialize/deserialize the data.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @alepha/protobuf
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import { Alepha, t } from "@alepha/core";
16
+ import { ProtobufProvider } from "@alepha/protobuf";
17
+
18
+ const protobuf = Alepha.create().get(ProtobufProvider);
19
+
20
+ const userSchema = t.object({
21
+ username: t.string(),
22
+ createdAt: t.datetime(),
23
+ age: t.int(),
24
+ isActive: t.boolean()
25
+ });
26
+
27
+ const buffer = protobuf.encode(userSchema, {
28
+ username: "John Doe",
29
+ createdAt: new Date().toISOString(),
30
+ age: 30,
31
+ isActive: true
32
+ });
33
+
34
+ const user = protobuf.decode(userSchema, buffer);
35
+ ```
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@alepha/protobuf",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
6
+ "main": "./dist/index.js",
8
7
  "types": "./dist/index.d.ts",
9
8
  "dependencies": {
10
- "@alepha/core": "0.5.2",
9
+ "@alepha/core": "0.6.0",
11
10
  "protobufjs": "^7.4.0"
12
11
  },
13
12
  "devDependencies": {
@@ -18,11 +17,9 @@
18
17
  "build": "pkgroll --clean-dist"
19
18
  },
20
19
  "exports": {
21
- "default": "./dist/index.js",
22
- "node": {
23
- "require": "./dist/index.cjs",
20
+ ".": {
24
21
  "import": "./dist/index.js",
25
- "module": "./dist/index.js",
22
+ "require": "./dist/index.cjs",
26
23
  "types": "./dist/index.d.ts"
27
24
  }
28
25
  }