Skip to content

Commit

Permalink
Update example.js
Browse files Browse the repository at this point in the history
Added a code snippet for the LookupResources API
  • Loading branch information
sohanmaheshwar authored Nov 15, 2024
1 parent 2a65c3a commit ec283f7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/v1/example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { v1 } from '@authzed/authzed-node';
const { promises: promiseClient } = client; // access client.promises
// set up it on localhost like this:
// const client = v1.NewClient('mytokenhere', 'localhost:50051', 1);
const client = v1.NewClient('mytokenhere');
Expand Down Expand Up @@ -82,3 +83,26 @@ console.log(
checkResult.permissionship ===
v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION
);

// Lookup Resources

const lookupResourcesRequest = v1.LookupResourcesRequest.create({
consistency: v1.Consistency.create({
requirement: {
oneofKind: 'fullyConsistent',
fullyConsistent: true,
},
}),
resourceObjectType: 'test/document',
permission: 'view',
subject: v1.SubjectReference.create({
object: v1.ObjectReference.create({
objectType: 'test/user',
objectId: 'fred',
}),
}),
});

const results = await promiseClient.lookupResources(lookupResourcesRequest)

console.log(results);

0 comments on commit ec283f7

Please sign in to comment.