(server: FastifyInstance)
| 4 | import { PDFRequest, ScrapeRequest, ScreenshotRequest, SearchRequest } from "./actions.schema.js"; |
| 5 | |
| 6 | async function routes(server: FastifyInstance) { |
| 7 | server.post( |
| 8 | "/scrape", |
| 9 | { |
| 10 | schema: { |
| 11 | operationId: "scrape", |
| 12 | description: "Scrape a URL", |
| 13 | tags: ["Browser Actions"], |
| 14 | summary: "Scrape a URL", |
| 15 | body: $ref("ScrapeRequest"), |
| 16 | response: { |
| 17 | 200: $ref("ScrapeResponse"), |
| 18 | }, |
| 19 | }, |
| 20 | }, |
| 21 | async (request: ScrapeRequest, reply: FastifyReply) => |
| 22 | handleScrape(server.sessionService, server.cdpService, request, reply), |
| 23 | ); |
| 24 | |
| 25 | server.post( |
| 26 | "/screenshot", |
| 27 | { |
| 28 | schema: { |
| 29 | operationId: "screenshot", |
| 30 | description: "Take a screenshot", |
| 31 | tags: ["Browser Actions"], |
| 32 | summary: "Take a screenshot", |
| 33 | body: $ref("ScreenshotRequest"), |
| 34 | response: { |
| 35 | 200: $ref("ScreenshotResponse"), |
| 36 | }, |
| 37 | }, |
| 38 | }, |
| 39 | async (request: ScreenshotRequest, reply: FastifyReply) => |
| 40 | handleScreenshot(server.sessionService, server.cdpService, request, reply), |
| 41 | ); |
| 42 | |
| 43 | server.post( |
| 44 | "/pdf", |
| 45 | { |
| 46 | schema: { |
| 47 | operationId: "pdf", |
| 48 | description: "Get the PDF content of a page", |
| 49 | tags: ["Browser Actions"], |
| 50 | summary: "Get the PDF content of a page", |
| 51 | body: $ref("PDFRequest"), |
| 52 | response: { |
| 53 | 200: $ref("PDFResponse"), |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | async (request: PDFRequest, reply: FastifyReply) => |
| 58 | handlePDF(server.sessionService, server.cdpService, request, reply), |
| 59 | ); |
| 60 | |
| 61 | server.post( |
| 62 | "/search", |
| 63 | { |
nothing calls this directly
no test coverage detected