createTRPCContext (src/trpc.ts)

call-me-please · packages/api/src/trpc.ts · typescript · MIT
auth, Auth / Identity

tRPC server setup with context, error formatting, and public/protected procedure helpers for a Next.js/Expo API.

// Source: https://github.com/gianpaj/call-me-please | License: MIT | Copyright 2025 Gianfranco Palumbo
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS:
 * 1. You want to modify request context (see Part 1)
 * 2. You want to create a new middleware or type of procedure (see Part 3)
 *
 * tl;dr - this is where all the tRPC server stuff is created and plugged in.
 * The pieces you will need to use are documented accordingly near the end
 */
import { TRPCError, initTRPC } from "@trpc/server";
import superjson from "superjson";
import { ZodError } from "zod";

import type { Session } from "@acme/auth";
import { auth, validateToken } from "@acme/auth";
import { db } from "@acme/db/client";

/**
 * Isomorphic Session gette

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key