Skip to content

Instantly share code, notes, and snippets.

@ntotten
Created September 13, 2023 14:26
Show Gist options
  • Save ntotten/1a666fcf6bbc56cc67e36f4252affdca to your computer and use it in GitHub Desktop.
Save ntotten/1a666fcf6bbc56cc67e36f4252affdca to your computer and use it in GitHub Desktop.
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
// {
// "event": "some string",
// "payload": {
// "auth": {
// "email": "email"
// },
// "customFields": {},
// "id": "some string",
// "metaData": {},
// "planConnections": [
// {
// "planConnectionId": "some string",
// "planId": "some string",
// "status": "some string"
// }
// ],
// "verified": true
// },
// "timestamp": 3.14
// }
const BUCKET_URL = "https://dev.zuplo.com/v1/accounts/nate-totten/key-buckets/zprj-zc6yd2gevq3cnqs2fpkxn0nz-working-copy"
export default async function (request: ZuploRequest, context: ZuploContext) {
const event = await request.json();
const email = event.payload.auth.email;
const body = {
managers: [email],
name: `c-${crypto.randomUUID()}`,
tags: {
userId: event.payload.id
}
};
// Create the consumer
const response = await fetch(
`${BUCKET_URL}/consumers?with-api-key=true`,
{
method: "POST",
body: JSON.stringify(body),
headers: {
Authorization: `Bearer ${environment.API_KEY}`,
"content-type": "application/json",
},
}
);
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment