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 createClient from "openapi-fetch"; | |
import { paths } from "./v1"; | |
export const { GET, POST } = createClient<paths>({ baseUrl: "/fast-api" }); |
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 module defines the FastAPI application and its endpoints. | |
It includes the endpoint for scraping a website and potentially an endpoint for finding contacts. | |
The application is wrapped with a stub function for deployment. | |
""" | |
from typing import Any | |
from common import ENV, image, secret, stub | |
from fastapi import FastAPI |
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 { SScrapingResult, SWebsiteInfoInput, SWebsiteInfoOutput } from '@lib/zod-models'; | |
import { NextResponse } from 'next/server'; | |
import { z } from 'zod'; | |
export const runtime = 'edge' | |
export async function POST(request: Request) { | |
const data = await request.json(); | |
const startTime = Date.now(); |
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 asyncio | |
import os | |
from getpass import getpass | |
from pathlib import Path | |
from typing import Dict, List, Optional | |
import boto3 | |
import requests | |
from dotenv import load_dotenv | |
from playwright.async_api import Page, async_playwright |
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
"use server" | |
import { revalidatePath } from "next/cache"; | |
import { SLemonSqueezyRequest, TLemonSqueezyRequest } from "./zod-lemon-squeezy"; | |
const lemonSqueezyBaseUrl = 'https://api.lemonsqueezy.com/v1'; | |
const lemonSqueezyApiKey = process.env.LEMON_SQUEEZY_API_KEY; | |
if (!lemonSqueezyApiKey) throw new Error("No LEMON_SQUEEZY_API_KEY environment variable set"); |
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 { NextResponse } from 'next/server'; | |
import { z } from 'zod'; | |
import camelcaseKeys from 'camelcase-keys' | |
import { db } from '@lib/db'; | |
import { products } from '@schema'; | |
export const runtime = 'edge' // 'nodejs' is the default | |
const camelize = <T extends readonly unknown[] | Record<string, unknown>>( |
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 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'; |
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
// declaring enum in database for subscription status | |
export const subscriptionStatusEnum = pgEnum('subscription_status', [ | |
'on_trial', | |
'active', | |
'paused', | |
'past_due', | |
'unpaid', | |
'cancelled', | |
'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 { z } from 'zod'; | |
import camelcaseKeys from 'camelcase-keys' | |
const camelize = <T extends readonly unknown[] | Record<string, unknown>>( | |
val: T, | |
) => camelcaseKeys(val) | |
const Urls = z.object({ | |
update_payment_method: z.string(), | |
}).transform(camelize); |
NewerOlder