Once you've created your relation definitions, you can start creating relations between resources and targets. Then, you can finally
add the access control checks to your application. We'll start with looking at the relevant objects used in creation and checking of relations.
When checking to see if a relation exists, one of the options involves the AuthzRelationQuery type which is used to query the service to see if a given relation exists.
The function that takes this object in will return it with the hasRelation boolean field set to true or false depending on whether the relation exists or not.
Other functions include the ability to check what relations exist for a given resource or target.
import DescopeClient from '@descope/node-sdk';const managementKey = "xxxx"try{ // baseUrl="<URL>" // When initializing the Descope clientyou can also configure the baseUrl ex: https://auth.company.com - this is useful when you utilize CNAME within your Descope project. const descopeClient = DescopeClient({ projectId: '__ProjectID__', managementKey: managementKey });} catch (error) { // handle the error console.log("failed to initialize: " + error)}// Note that you can handle async operation failures and capture specific errors to customize errors.// An example can be found here: https://github.com/descope/node-sdk?tab=readme-ov-file#error-handling