Initial commit: MOPC platform with Docker deployment setup
Full Next.js 15 platform with tRPC, Prisma, PostgreSQL, NextAuth. Includes production Dockerfile (multi-stage, port 7600), docker-compose with registry-based image pull, Gitea Actions CI workflow, nginx config for portal.monaco-opc.com, deployment scripts, and DEPLOYMENT.md guide. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
24
src/server/context.ts
Normal file
24
src/server/context.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { inferAsyncReturnType } from '@trpc/server'
|
||||
import type { FetchCreateContextFnOptions } from '@trpc/server/adapters/fetch'
|
||||
import { auth } from '@/lib/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
/**
|
||||
* Create tRPC context for each request
|
||||
*/
|
||||
export async function createContext(opts?: FetchCreateContextFnOptions) {
|
||||
const session = await auth()
|
||||
|
||||
// Extract IP and user agent from headers
|
||||
const ip = opts?.req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ?? 'unknown'
|
||||
const userAgent = opts?.req.headers.get('user-agent') ?? 'unknown'
|
||||
|
||||
return {
|
||||
session,
|
||||
prisma,
|
||||
ip,
|
||||
userAgent,
|
||||
}
|
||||
}
|
||||
|
||||
export type Context = inferAsyncReturnType<typeof createContext>
|
||||
Reference in New Issue
Block a user