Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/deno/test.rego
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package test

p {
p if {
input.foo == "bar"
}
13 changes: 6 additions & 7 deletions examples/nodejs-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -47,7 +46,7 @@ Produces:
```

```bash
node app.js '{"message": "not-world"}'
npm start -- '{"message": "not-world"}'
```

Produces:
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs-app/example.rego
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package example

default hello = false

hello {
hello if {
x := input.message
x == data.world
}
5 changes: 4 additions & 1 deletion examples/nodejs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:../../"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/nodejs-ts-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}'
```
2 changes: 1 addition & 1 deletion examples/nodejs-ts-app/example.rego
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package example

default hello = false

hello {
hello if {
x := input.message
x == data.world
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading