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
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime"; | |
interface UserEvent { | |
object: "event"; | |
type: "user.created"; | |
data: UserData; | |
} | |
interface UserData { |
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
const fileStream = request.body; // Stream of the file content | |
const reader = fileStream.getReader(); | |
const decoder = new TextDecoder(); | |
let firstColumnValues = []; | |
let leftover = ''; // Store any partial lines | |
const processChunk = async ({ done, value }) => { | |
if (done) { | |
// Process any remaining line in leftover |
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
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime"; | |
type MyPolicyOptionsType = { | |
bucketName: string; | |
accountName: string; | |
}; | |
export default async function policy( | |
request: ZuploRequest, | |
context: ZuploContext, |
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
{ | |
"name": "my-request-validation-inbound-policy", | |
"policyType": "request-validation-inbound", | |
"handler": { | |
"export": "RequestValidationInboundPolicy", | |
"module": "$import(@zuplo/runtime)", | |
"options": { | |
"includeRequestInLogs": false, | |
"logLevel": "info", | |
"validateBody": "reject-and-log" |
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
import { ZuploContext, ZuploRequest } from "@zuplo/runtime"; | |
export default async function ( | |
request: ZuploRequest, | |
context: ZuploContext, | |
options: any, | |
policyName: string | |
) { | |
const url = new URL(request.url); |
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
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime"; | |
// { | |
// "event": "some string", | |
// "payload": { | |
// "auth": { | |
// "email": "email" | |
// }, | |
// "customFields": {}, |
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 was generated with ChatGTP as an expiriment. If you find this, don't trust that the | |
// code works. I didn't test this or anything. See: https://twitter.com/ntotten/status/1657012479942066177 | |
class HubspotSDK { | |
private apiKey: string; | |
private baseUrl: string = 'https://api.hubapi.com'; | |
constructor(apiKey: string) { | |
this.apiKey = apiKey; | |
} |
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
import { ZuploContext, ZuploRequest, HttpProblems } from "@zuplo/runtime"; | |
export default async function ( | |
request: ZuploRequest, | |
context: ZuploContext | |
) { | |
if (request.user.data.isExpired === true) { | |
return HttpProblems.forbidden(request, context, { | |
detail: "This account is expired." | |
}) |
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
import { ZuploContext, ZuploRequest, ZoneCache, environment } from "@zuplo/runtime"; | |
// Get environment variables | |
// AZURE_AD_TENENT_ID: The tenant ID of your Azure AD (UUID) | |
// AZURE_AD_CLIENT_ID: The client ID of the "zuplo" Azure AD application (UUID) | |
// AZURE_AD_CLIENT_SECRET: The secret for the "zuplo" Azure AD application | |
// API_HOST: The url of your Azure App service i.e. https://zup-demo1.azurewebsites.net/ | |
const { AZURE_AD_TENENT_ID, AZURE_AD_CLIENT_ID, AZURE_AD_CLIENT_SECRET, API_HOST } = environment; | |
const TOKEN_CACHE_KEY = "ad-token" |
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
import { ZuploRequest, ZuploContext, ResponseFactory, environment } from "@zuplo/runtime"; | |
import { SegmentClient } from "./segment"; | |
export async function postLogin( | |
request: ZuploRequest, | |
context: ZuploContext | |
): Promise<Response> { | |
if (!environment.SEGMENT_WRITE_KEY) { | |
throw new Error("SEGMENT_WRITE_KEY environment variable not set") | |
} |
NewerOlder