Skip to content

Instantly share code, notes, and snippets.

View p6l-richard's full-sized avatar

Richard Poelderl p6l-richard

View GitHub Profile
@p6l-richard
p6l-richard / cal-create-idempotent.ts
Last active April 13, 2024 17:19
How to create a user on Cal.com with recovery flow
// Create a new user
/** [@calcom] 1. Create the user in cal */
let calUser: Omit<CalManageUserResponse, "status">["data"] | null =
null;
const url = `${env.NEXT_PUBLIC_CAL_API_URL}/oauth-clients/${env.NEXT_PUBLIC_CAL_OAUTH_CLIENT_ID}/users`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-cal-secret-key": env.CAL_SECRET,
@p6l-richard
p6l-richard / some-recursive-function.ts
Last active April 13, 2024 16:34
Recursively go through a nested object
// add any additional (also optional) values if you want to keep track of something (e.g. object location)
export function someRecursiveFunction(args: { object: any }): any {
// early return
if (!args.object) return args.object;
// UPDATE THIS: The logic you'd like the function to take
if ("id" in args.object && args.object.type === "item") {
delete args.object.id;
}
chrome.runtime.onInstalled.addListener(() => {
await syncUser()
const {tokens, isSignedIn} = chrome.storage.sync.get('authentication')
// initiate signup flow on my web app if user isn't signed in yet
if (!isSignedIn && !tokens) {
chrome.tabs.create({url : "proprietary.web.app/signup"})
}
})
chrome.runtime.onMessage.addListener((message) => {
@p6l-richard
p6l-richard / README.md
Created May 6, 2020 10:24
A template for a readme of an open source project.

README.md

Title

Description

Screenshots with captions

Code Style