Created
October 5, 2020 16:59
-
-
Save ryancharris/ed6dfd96d3a9f64052b22a63fb531de6 to your computer and use it in GitHub Desktop.
API v4 demo code
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
const faunadb = require("faunadb"); | |
const q = faunadb.query; | |
// Instantiate client | |
const client = new faunadb.Client({ | |
secret: FAUNA_KEY, | |
domain: "localhost", | |
scheme: "http", | |
port: 8443 | |
}); | |
function createProvider(name) { | |
return client.query( | |
q.CreateAccessProvider({ | |
name: name, | |
issuer: name, | |
jwks_uri: "https://my-provider-url.auth0.com", | |
membership: [q.Role("MyCustomRole")] | |
}) | |
); | |
} | |
function getAllProviders() { | |
return client.query(q.Paginate(q.AccessProviders())); | |
} | |
function getProviderById(name) { | |
return client.query(q.Get(q.AccessProvider(name))); | |
} | |
async function main() { | |
const newProviderName = "good-morning"; | |
const provider = await createProvider(newProviderName); | |
console.log("provider", provider); | |
const allProviders = await getAllProviders(); | |
console.log("allProviders", allProviders); | |
const providerById = await getProviderById(newProviderName); | |
console.log("providerById", providerById); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment