- Rename local-proxy to mcplocal with HTTP server, LLM pipeline, mcpd discovery - Add LLM pre-processing: token estimation, filter cache, metrics, Gemini CLI + DeepSeek providers - Add mcpd auth (login/logout) and MCP proxy endpoints - Update CLI: dual URLs (mcplocalUrl/mcpdUrl), auth commands, --direct flag - Add tiered health monitoring, shell completions, e2e integration tests - 57 test files, 597 tests passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { FastifyInstance } from 'fastify';
|
|
import type { AuthService } from '../services/auth.service.js';
|
|
import { createAuthMiddleware } from '../middleware/auth.js';
|
|
|
|
export interface AuthRouteDeps {
|
|
authService: AuthService;
|
|
}
|
|
|
|
export function registerAuthRoutes(app: FastifyInstance, deps: AuthRouteDeps): void {
|
|
const authMiddleware = createAuthMiddleware({
|
|
findSession: (token) => deps.authService.findSession(token),
|
|
});
|
|
|
|
// POST /api/v1/auth/login — no auth required
|
|
app.post<{
|
|
Body: { email: string; password: string };
|
|
}>('/api/v1/auth/login', async (request) => {
|
|
const { email, password } = request.body;
|
|
const result = await deps.authService.login(email, password);
|
|
return result;
|
|
});
|
|
|
|
// POST /api/v1/auth/logout — auth required
|
|
app.post('/api/v1/auth/logout', { preHandler: [authMiddleware] }, async (request) => {
|
|
const header = request.headers.authorization;
|
|
// Auth middleware already validated the header; extract the token
|
|
const token = header!.slice(7);
|
|
await deps.authService.logout(token);
|
|
return { success: true };
|
|
});
|
|
}
|