- Replace Bun with pnpm 9 + Turborepo + tsx; apps/api renamed to apps/backend - Split backend into http/, modules/, lib/ layers mirroring tai-specguard - Add use-case + Result pattern, Problem Details RFC 7807, basePath /api/v1 - Mount Better Auth at /api/v1/auth, keep session-auth whitelist - Split Prisma schema into prisma/models/*, generate into generated/ - Rework packages/shared into lib/ + schemas/ with pagination DTOs - Implement health, groups, students, payments, waitlist modules - Add vitest suite with prisma mocks (21 tests), biome lint - Point web client to /api/v1/auth and /api/v1/groups/from-organization
22 lines
531 B
TypeScript
22 lines
531 B
TypeScript
import type { MiddlewareHandler } from 'hono';
|
|
import { logger } from '@/logger';
|
|
import type { BackendEnv } from './env';
|
|
|
|
export const requestLoggerMiddleware: MiddlewareHandler<BackendEnv> = async (c, next) => {
|
|
const startedAt = Date.now();
|
|
|
|
try {
|
|
await next();
|
|
} finally {
|
|
logger.info(
|
|
{
|
|
method: c.req.method,
|
|
path: c.req.path,
|
|
requestId: c.get('requestId'),
|
|
status: c.res.status,
|
|
durationMs: Date.now() - startedAt,
|
|
},
|
|
'Request completed',
|
|
);
|
|
}
|
|
}; |