CampgroundTickets/backend/src/context.ts
Hank 3397e3e3ec Initial Camp Scan ticketing system
Backend (Fastify + TS): FluentForms webhook -> NocoDB row + QR + MailerSend
email; PIN auth; scan/lookup/redeem with per-code serialization; reusable QR
codes with count-based check-in; admin search.

App (Expo, one codebase): Android APK + iPhone PWA. Login, camera scanner
(native + web barcode-detector split), green/red overlay with sound + haptics,
admin lookup/redeem. Session token persisted per device.

Ops: multi-stage Dockerfile serving API + PWA same-origin, compose bound to
127.0.0.1; Forgejo Actions runner + tag-triggered signed APK build for Obtainium.
Docs in README.md and INSTALL.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 03:47:59 +00:00

35 lines
873 B
TypeScript

import type { Config } from "./config.js";
import { NocoDBClient } from "./services/nocodb.js";
import { Mailer } from "./services/mailer.js";
import { RedeemQueue } from "./services/redeemQueue.js";
/** Shared services wired once at startup and hung off the Fastify instance. */
export interface AppContext {
config: Config;
nocodb: NocoDBClient;
mailer: Mailer;
queue: RedeemQueue;
}
export function buildContext(config: Config): AppContext {
return {
config,
nocodb: new NocoDBClient(config),
mailer: new Mailer(config),
queue: new RedeemQueue(),
};
}
// Ambient module augmentation so `fastify.ctx` and `request.user` are typed.
declare module "fastify" {
interface FastifyInstance {
ctx: AppContext;
}
}
declare module "@fastify/jwt" {
interface FastifyJWT {
payload: { role: "staff" };
user: { role: "staff" };
}
}