routes
in my project and then construct export const router
in index.ts
file by adding all my handlers from different files?// Many imports... export const router = createPlaywrightRouter(); router.addDefaultHandler(defaultHandler); router.addHandler('catalog-page', catalogHandler); router.addHandler('review-page', reviewsHandler);
handler: (ctx: Omit<Context, 'request'> & { request: Request<UserData> }) => Awaitable<void>
Context
is defined as a type parameter of the Router
classtype Handler = (ctx: Omit<PlaywrightCrawlingContext<Dictionary>, 'request'> & { request: Request<Dictionary>; }) => Awaitable<void> const handleRoute: Handler = async ({ page }) => { console.log(await page.title()); }; const router = createPlaywrightRouter(); router.addHandler('handler', handleRoute);