import express from "express"
const app = express()
app.get("/api/users", async (req, res) => {
const { data } = await db.from("users").select("*")
res.json(data)
app.listen(3000)
from fastapi import FastAPI
app = FastAPI()
@app.get("/products")
def list_products(session: Session):
return session.exec(select(Product)).all()
import Stripe from "stripe"
const stripe = new Stripe(process.env.KEY)
export async function POST(req: Request) {
const session = await stripe.checkout.sessions.create({
mode: "payment",
const { Pool } = require("pg")
const pool = new Pool({ host: process.env.DB_HOST })
async function getMetrics(range: string) {
const { rows } = await pool.query(sql, [range])
import jwt from "jsonwebtoken"
const token = jwt.sign({ userId }, process.env.JWT_SECRET)
import { NextResponse } from "next/server"
return NextResponse.json({ status: "ok" }, { status: 200 })
import { createClient } from "@supabase/supabase-js"
const supabase = createClient(url, key)
const { data } = await supabase.auth.signIn({ email })
await supabase.from("profiles").upsert(payload)
import { Resend } from "resend"
const resend = new Resend(process.env.RESEND_KEY)
await resend.emails.send({ from: "app@domain.com", to: email, subject: "Welcome" })
import { z } from "zod"
const schema = z.object({ name: z.string(), email: z.string().email() })
const parsed = schema.safeParse(body)
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient()
const user = await prisma.user.findUnique({ where: { id } })
await prisma.order.create({ data: { userId, total } })
import bcrypt from "bcryptjs"
const hash = await bcrypt.hash(password, 10)
const match = await bcrypt.compare(password, hash)
export async function generateStaticParams() {
const posts = await fetch("/api/posts").then(r => r.json())
return posts.map(post => ({ slug: post.slug }))
export default async function PostPage({ params }) {
const post = await getPost(params.slug)
export const config = { runtime: "edge" }
const redis = new Redis(process.env.REDIS_URL)
await redis.set("cache:" + key, JSON.stringify(data))
const cached = await redis.get("cache:" + key)
export async function GET(request: Request) {
const url = new URL(request.url)
const q = url.searchParams.get("q")
const results = await searchIndex.search(q)
return new Response(JSON.stringify(results))