diff --git a/examples/deno/test.rego b/examples/deno/test.rego index e68db09..abea9a3 100644 --- a/examples/deno/test.rego +++ b/examples/deno/test.rego @@ -1,5 +1,5 @@ package test -p { +p if { input.foo == "bar" } \ No newline at end of file diff --git a/examples/nodejs-app/README.md b/examples/nodejs-app/README.md index b432f4f..1d9313d 100644 --- a/examples/nodejs-app/README.md +++ b/examples/nodejs-app/README.md @@ -15,16 +15,15 @@ npm install > The example uses a local path, in "real" use-cases use the standard NPM > module. -## Build the WebAssembly binary for the example policy: - -> The syntax shown below requires OPA v0.20.5+ +## Build the WebAssembly binary for the example policy There is an example policy included with the example, see [example.rego](./example.rego) +> Requires OPA v1.1.0+ + ```bash -opa build -t wasm -e example/hello ./example.rego -tar -xzf ./bundle.tar.gz /policy.wasm +npm run build ``` This will create a bundle tarball with the WASM binary included, and then unpack @@ -33,7 +32,7 @@ just the `policy.wasm` from the bundle. ## Run the example Node JS code that invokes the WASM binary: ```bash -node app.js '{"message": "world"}' +npm start -- '{"message": "world"}' ``` Produces: @@ -47,7 +46,7 @@ Produces: ``` ```bash -node app.js '{"message": "not-world"}' +npm start -- '{"message": "not-world"}' ``` Produces: diff --git a/examples/nodejs-app/example.rego b/examples/nodejs-app/example.rego index 5529856..9d8b452 100644 --- a/examples/nodejs-app/example.rego +++ b/examples/nodejs-app/example.rego @@ -2,7 +2,7 @@ package example default hello = false -hello { +hello if { x := input.message x == data.world } diff --git a/examples/nodejs-app/package.json b/examples/nodejs-app/package.json index 2101df2..2ba6a72 100644 --- a/examples/nodejs-app/package.json +++ b/examples/nodejs-app/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "description": "demo app", "main": "app.js", - "scripts": {}, + "scripts": { + "build": "opa build -t wasm -e example/hello ./example.rego && tar xzf ./bundle.tar.gz /policy.wasm", + "start": "node app.js" + }, "dependencies": { "@open-policy-agent/opa-wasm": "file:../../" }, diff --git a/examples/nodejs-ts-app/README.md b/examples/nodejs-ts-app/README.md index 696e8db..3cac201 100644 --- a/examples/nodejs-ts-app/README.md +++ b/examples/nodejs-ts-app/README.md @@ -14,7 +14,7 @@ npm install There is an example policy included with the example, see [example.rego](./example.rego) -> Requires OPA v0.20.5+ +> Requires OPA v1.1.0+ ```bash npm run build @@ -23,9 +23,9 @@ npm run build ## Run the example Node JS code that invokes the Wasm binary: ```bash -npm start -- '{\"message\": \"world\"}' +npm start -- '{"message": "world"}' ``` ```bash -npm start -- '{\"message\": \"not-world\"}' +npm start -- '{"message": "not-world"}' ``` diff --git a/examples/nodejs-ts-app/example.rego b/examples/nodejs-ts-app/example.rego index 5529856..9d8b452 100644 --- a/examples/nodejs-ts-app/example.rego +++ b/examples/nodejs-ts-app/example.rego @@ -2,7 +2,7 @@ package example default hello = false -hello { +hello if { x := input.message x == data.world } diff --git a/package-lock.json b/package-lock.json index b4188d0..b23f8da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4676,9 +4676,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8318,9 +8318,9 @@ "dev": true }, "typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true }, "unbzip2-stream": {