FRE-592: Implement character database and relationship mapping
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>
This commit is contained in:
41
server/trpc/index.ts
Normal file
41
server/trpc/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user