Skip to content

Instantly share code, notes, and snippets.

/* Spiderman */
@layer base {
  :root {
    --background: 210 100% 20%;
    --foreground: 0 100% 50%;
    --card: 210 100% 25%;
    --card-foreground: 0 100% 55%;
    --popover: 210 100% 30%;
    --popover-foreground: 0 100% 60%;
@feliche93
feliche93 / route.ts
Created June 26, 2023 09:04
Route Handler for Lemon Squeezy Subscription Webhook
import crypto from 'crypto';
import { NextResponse } from 'next/server';
import { SLemonSqueezyWebhookRequest } from './models';
import { db } from '@lib/db';
import { subscriptions } from '@schema';
import { eq } from 'drizzle-orm';
import camelcaseKeys from 'camelcase-keys'
import { CamelCasedPropertiesDeep } from 'type-fest' // need CamelCasedPropertiesDeep because of https://github.com/sindresorhus/camelcase-keys/issues/77#issuecomment-1339844470
import { ZodEffects, z } from 'zod';
import PostHogClient from '@lib/posthog';
@amosbastian
amosbastian / route.ts
Last active August 6, 2024 20:08
Lemon Squeezy webhook using the new route handler in Next.js 13
import crypto from "crypto";
import { listAllSubscriptions } from "lemonsqueezy.ts";
import { NextRequest } from "next/server";
// Put this in your billing lib and just import the type instead
type LemonsqueezySubscription = Awaited<ReturnType<typeof listAllSubscriptions>>["data"][number];
const isError = (error: unknown): error is Error => {
return error instanceof Error;
};