Skip to content

Instantly share code, notes, and snippets.

@vanduc1102
Last active May 26, 2024 05:30
Show Gist options
  • Save vanduc1102/7898ef85279b63bcf8a6038622549010 to your computer and use it in GitHub Desktop.
Save vanduc1102/7898ef85279b63bcf8a6038622549010 to your computer and use it in GitHub Desktop.
Permify typescript nodejs client
import getPermifyClient from "./clients/permify";
getPermifyClient()
.tenancy.list({ pageSize: 10 })
.then((response) => {
console.log(response);
});
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