Skip to content

Commit

Permalink
dan/per-10080-node-sdk-local-facts-uploader (#371)
Browse files Browse the repository at this point in the history
* Added Node SDK docs for local facts feature

* Added docs for waitForSync

* add newlines to fix doc

---------

Co-authored-by: Asaf Cohen <asaf@permit.io>
  • Loading branch information
danyi1212 and Asaf Cohen authored Jun 23, 2024
1 parent 07806ab commit 124aa59
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions docs/how-to/manage-data/local-facts-uploader.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ permit = Permit(
)
```

</TabItem>

<TabItem value="nodejs" label="Node.js">

```typescript
import { Permit } from "permit";

const permit = new Permit({
// your secret API KEY
token: "<your-api-key>",
// In production, you might need to change this URL to fit your deployment
// This is the address where you can find the PDP container.
pdp: "http://localhost:7766",
// configure the SDK to upload facts via the PDP
proxyFactsViaPdp: true,
// Add here any more configurations that you usually use
});
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -112,7 +131,40 @@ async with permit.wait_for_sync(timeout=15) as p:
```

</TabItem>
<TabItem value="nodejs" label="Node.js">

```typescript
import { Permit } from "permit";

const permit = new Permit({
// your secret API KEY
token: "<your-api-key>",
// In production, you might need to change this URL to fit your deployment
// This is the address where you can find the PDP container.
pdp: "http://localhost:7766",
// configure the SDK to upload facts via the PDP
proxyFactsViaPdp: true,
// configure the default time to wait for the facts to be synced
factsSyncTimeout: 10,
// Add here any more configurations that you usually use
});

await permit.api.users.sync({
key: "auth0|elon",
email: "elonmusk@tesla.com",
first_name: "Elon",
last_name: "Musk",
attributes: {
age: 50,
favorite_color: "red",
},
});

// or you can use the waitForSync function to customize the timeout for a specific call
await permit.api.users.waitForSync(10).create({ key: "auth0|elon" });
```

</TabItem>
</Tabs>

:::note Supported APIs
Expand Down

0 comments on commit 124aa59

Please sign in to comment.