Last active
May 26, 2024 05:30
-
-
Save vanduc1102/7898ef85279b63bcf8a6038622549010 to your computer and use it in GitHub Desktop.
Permify typescript nodejs client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getPermifyClient from "./clients/permify"; | |
getPermifyClient() | |
.tenancy.list({ pageSize: 10 }) | |
.then((response) => { | |
console.log(response); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Permify from "@permify/permify-node"; | |
const { PERMIFY_API_ENDPOINT = "http://localhost:3478" } = process.env; | |
export type PermifyClient = ReturnType<typeof Permify.grpc.newClient>; | |
function createInstance() { | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
const client = new (Permify.grpc.newClient as any)({ | |
endpoint: PERMIFY_API_ENDPOINT, | |
}); | |
return client; | |
} | |
let instance: PermifyClient; | |
export default function getInstance(): PermifyClient { | |
if (!instance) { | |
instance = createInstance(); | |
} | |
return instance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment