mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(api): add generic tool route factory for all image tools
- createToolRoute<T> factory: handles multipart parsing, file validation, Zod settings validation, workspace management, and error handling - Each tool only needs to provide toolId, settingsSchema, and process function - Registers POST /api/v1/tools/:toolId routes automatically - Tool registry stub at routes/tools/index.ts ready for tool implementations - Catches Sharp errors and returns clean API error envelopes (422)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import type { FastifyInstance } from "fastify";
|
||||
|
||||
/**
|
||||
* Registry that imports and registers all tool routes.
|
||||
* Each tool uses the createToolRoute factory from tool-factory.ts.
|
||||
*
|
||||
* Tools will be added here as they are implemented in Phase 2 Tasks 4-10.
|
||||
*/
|
||||
export async function registerToolRoutes(app: FastifyInstance): Promise<void> {
|
||||
// Tool routes will be registered here as they are implemented.
|
||||
// Example:
|
||||
// const { registerResizeTool } = await import("./resize.js");
|
||||
// registerResizeTool(app);
|
||||
app.log.info("Tool routes registered");
|
||||
}
|
||||
Reference in New Issue
Block a user