Skip to content

Instantly share code, notes, and snippets.

View ntotten's full-sized avatar

Nathan Totten ntotten

View GitHub Profile
{
"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"
import { ZuploContext, ZuploRequest } from "@zuplo/runtime";
export default async function (
request: ZuploRequest,
context: ZuploContext,
options: any,
policyName: string
) {
const url = new URL(request.url);
import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";
// {
// "event": "some string",
// "payload": {
// "auth": {
// "email": "email"
// },
// "customFields": {},
// 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;
}
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."
})
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"
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")
}
@ntotten
ntotten / certrenew.sh
Created July 29, 2017 17:12
Script to renew Let's Encrypt certificate and then replace certificate on OpenVPN server
#!/bin/bash
(
DOMAIN="vpn.example.com"
set -eu
certbot renew -q
/usr/local/openvpn_as/scripts/sacli stop
@ntotten
ntotten / chat.js
Created August 2, 2012 20:25
Tankster Command Blog Post
var socket = io.connect();
socket.on('connect', function () {
socket.emit('connect', userInfo);
});
$('#text').keypress(function (e) {
if (e.keyCode == 13) {
$("#send").click();
return false;
@ntotten
ntotten / certrenew.sh
Created July 29, 2017 17:12
Script to renew Let's Encrypt certificate and then replace certificate on OpenVPN server
#!/bin/bash
(
DOMAIN="vpn.example.com"
set -eu
certbot renew -q
/usr/local/openvpn_as/scripts/sacli stop