This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from clerkinc/yourtallness/export_resource_types
fix: export resource types so that IDEs can pick up the definitions refactor: restructure resource definitions add test coverage for sub-apis
- Loading branch information
Showing
80 changed files
with
1,666 additions
and
1,366 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
src/examples/express/package.json → examples/express/package.json
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CLERK_API_KEY=test_foo | ||
CLERK_API_URL=https://api.clerk.dev | ||
CLERK_LOGGING=false |
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "clerk-sdk-node-examples", | ||
"license": "MIT", | ||
"type": "module", | ||
"dependencies": { | ||
"@clerk/clerk-sdk-node": "latest", | ||
"dotenv": "^8.2.0", | ||
"log-that-http": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react-dom": "^17.0.1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Usage: | ||
// From examples/node, transpile files by running `tsc` | ||
// To run: | ||
// node --require dotenv/config dist/clients.js | ||
|
||
import { Clerk, setClerkServerApiUrl, clients } from '@clerk/clerk-sdk-node'; | ||
|
||
const serverApiUrl = process.env.CLERK_API_URL || ''; | ||
const clientId = process.env.CLIENT_ID || ''; | ||
const sessionToken = process.env.SESSION_TOKEN || ''; | ||
|
||
setClerkServerApiUrl(serverApiUrl); | ||
|
||
console.log('Get client list'); | ||
let clientList = await clients.getClientList(); | ||
console.log(clientList); | ||
|
||
console.log('Get single client'); | ||
let client = await clients.getClient(clientId); | ||
console.log(client); | ||
|
||
try { | ||
console.log('Verify client'); | ||
let verifiedClient = await clients.verifyClient(sessionToken); | ||
console.log(verifiedClient); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
try { | ||
console.log('Get single client for invalid clientId'); | ||
let invalidClient = await clients.getClient('foobar'); | ||
console.log(invalidClient); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
try { | ||
console.log('Get client list with invalid API key'); | ||
const apiKey = 'snafu'; | ||
const clerk2 = new Clerk({ apiKey, serverApiUrl }); | ||
let invalidClients = await clerk2.clients.getClientList(); | ||
console.log(invalidClients); | ||
} catch (error) { | ||
console.log(error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Usage: | ||
// From examples/node, transpile files by running `tsc` | ||
// To run: | ||
// node --require dotenv/config dist/emails.js | ||
|
||
import { setClerkServerApiUrl, emails } from '@clerk/clerk-sdk-node'; | ||
|
||
const serverApiUrl = process.env.CLERK_API_URL || ''; | ||
|
||
setClerkServerApiUrl(serverApiUrl); | ||
|
||
console.log('Create email'); | ||
|
||
const emailAddressId = process.env.EMAIL_ADDRESS_ID || ''; | ||
const fromEmailName = 'sales'; | ||
const subject = 'Amazing offer!'; | ||
const body = | ||
'Click <a href="https://www.thisiswhyimbroke.com/">here</a> to find out more!'; | ||
|
||
try { | ||
let email = await emails.createEmail({ | ||
emailAddressId, | ||
fromEmailName, | ||
subject, | ||
body, | ||
}); | ||
|
||
console.log(email); | ||
} catch (error) { | ||
console.log(error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Usage: | ||
// From examples/node, transpile files by running `tsc` | ||
// To run: | ||
// node --require dotenv/config dist/sessions.js | ||
|
||
import { setClerkServerApiUrl, sessions } from '@clerk/clerk-sdk-node'; | ||
|
||
const serverApiUrl = process.env.CLERK_API_URL || ''; | ||
const clientId = process.env.CLIENT_ID || ''; | ||
const userId = process.env.USER_ID || ''; | ||
const sessionId = process.env.SESSION_ID || ''; | ||
const sessionIdtoRevoke = process.env.SESSION_ID_TO_REVOKE || ''; | ||
const sessionToken = process.env.SESSION_TOKEN || ''; | ||
|
||
setClerkServerApiUrl(serverApiUrl); | ||
|
||
console.log('Get session list'); | ||
let sessionList = await sessions.getSessionList(); | ||
console.log(sessionList); | ||
|
||
console.log('Get session list filtered by userId'); | ||
let filteredSessions1 = await sessions.getSessionList({ userId }); | ||
console.log(filteredSessions1); | ||
|
||
console.log('Get session list filtered by clientId'); | ||
let filteredSessions2 = await sessions.getSessionList({ clientId }); | ||
console.log(filteredSessions2); | ||
|
||
console.log('Get single session'); | ||
let session = await sessions.getSession(sessionId); | ||
console.log(session); | ||
|
||
try { | ||
console.log('Revoke session'); | ||
let revokedSession = await sessions.revokeSession(sessionIdtoRevoke); | ||
console.log(revokedSession); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
try { | ||
console.log('Verify session'); | ||
let verifiedSession = await sessions.verifySession(sessionId, sessionToken); | ||
console.log(verifiedSession); | ||
} catch (error) { | ||
console.log(error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Usage: | ||
// From examples/node, transpile files by running `tsc` | ||
// To run: | ||
// node --require dotenv/config dist/sms_messages.js | ||
|
||
import { smsMessages, setClerkServerApiUrl } from '@clerk/clerk-sdk-node'; | ||
|
||
const serverApiUrl = process.env.CLERK_API_URL || ''; | ||
const phoneNumberId = process.env.PHONE_NUMBER_ID || ''; | ||
|
||
setClerkServerApiUrl(serverApiUrl); | ||
|
||
try { | ||
console.log('Create SMS message'); | ||
const message = "I'd buy that for a dollar"; | ||
|
||
let smsMessage = await smsMessages.createSMSMessage({ | ||
message, | ||
phoneNumberId, | ||
}); | ||
|
||
console.log(smsMessage); | ||
} catch (error) { | ||
console.log(error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Usage: | ||
// From examples/node, transpile files by running `tsc` | ||
// To run: | ||
// node --require dotenv/config dist/users.js | ||
|
||
import { setClerkServerApiUrl, users } from '@clerk/clerk-sdk-node'; | ||
|
||
const serverApiUrl = process.env.CLERK_API_URL || ''; | ||
const userId = process.env.USER_ID || ''; | ||
const userIdToDelete = process.env.USER_ID_TO_DELETE || ''; | ||
|
||
setClerkServerApiUrl(serverApiUrl); | ||
|
||
console.log('Get user list'); | ||
let userList = await users.getUserList(); | ||
console.log(userList); | ||
|
||
console.log('Get single user'); | ||
let user = await users.getUser(userId); | ||
console.log(user); | ||
|
||
try { | ||
console.log('Update user'); | ||
|
||
let updatedUser = await users.updateUser(userId, { | ||
firstName: 'Kyle', | ||
lastName: 'Reese', | ||
}); | ||
|
||
// let updatedUser = await users.updateUser(userId, { firstName: 'John', lastName: 'Connor' }); | ||
// let updatedUser = await users.updateUser(userId, { firstName: 'Peter', lastName: 'Silberman' }); | ||
|
||
console.log(updatedUser); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
try { | ||
console.log('Delete user'); | ||
let deletedUser = await users.deleteUser(userIdToDelete); | ||
console.log(deletedUser); | ||
} catch (error) { | ||
console.log(error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": false, | ||
"declaration": false, | ||
"moduleResolution": "node", | ||
"target": "es2017", | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.