Add full character management system with enriched profiles (bio, traits, arcs, motivation, conflict, secrets), relationship mapping between characters with types and strength, character search/filter by role and arc type, and character statistics (scene count, dialogue, screen time). Includes database schema, tRPC router procedures, SolidJS components, API hooks, and unit tests. Co-Authored-By: Paperclip <noreply@paperclip.ing>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { initHTTPServer } from '@trpc/server/adapters/http';
|
|
import { projectRouter } from './project-router';
|
|
import type { TRPCContext } from './types';
|
|
import type { TRPCError } from '@trpc/server';
|
|
|
|
// App router combining all routers
|
|
export const appRouter = {
|
|
project: projectRouter,
|
|
};
|
|
|
|
export type AppRouter = typeof appRouter;
|
|
|
|
// Create tRPC HTTP server
|
|
export function createTRPCServer(port: number = 8080) {
|
|
const server = initHTTPServer({
|
|
router: appRouter,
|
|
createContext: async ({ req }: { req: Request }): Promise<TRPCContext> => {
|
|
// Extract auth from headers
|
|
const authHeader = req.headers.get('authorization');
|
|
const userId = authHeader?.split(' ')[1]; // Bearer token
|
|
|
|
return {
|
|
userId,
|
|
};
|
|
},
|
|
onError: ({ error, path, input }: { error: TRPCError; path: string; input: unknown }) => {
|
|
console.error(`tRPC error on ${path}:`, {
|
|
input,
|
|
error: error.message,
|
|
});
|
|
},
|
|
});
|
|
|
|
server.listen(port, () => {
|
|
console.log(`tRPC server listening on port ${port}`);
|
|
});
|
|
|
|
return server;
|
|
}
|
|
|
|
export default appRouter;
|