diff --git a/backend/functions/src/index.ts b/backend/functions/src/index.ts index aa47c66..f8d159c 100644 --- a/backend/functions/src/index.ts +++ b/backend/functions/src/index.ts @@ -1,7 +1,7 @@ import 'reflect-metadata'; import { initializeApp } from 'firebase-admin/app'; import { CrawlerHost } from './cloud-functions/crawler'; -import { https, HttpsFunction } from 'firebase-functions'; +import { runWith, https, HttpsFunction } from 'firebase-functions'; import { Logger } from './shared/logger'; import { container } from 'tsyringe'; import { PuppeteerControl } from './services/puppeteer'; @@ -19,25 +19,17 @@ container.registerSingleton(AsyncContext); container.registerSingleton(CrawlerHost); const crawlerHost = container.resolve(CrawlerHost); -export const crawler = https.onRequest(async (req, res) => { +export const crawler = runWith({ + memory: '4GB', + timeoutSeconds: 540, + }).https.onRequest(async (req, res) => { await crawlerHost.crawl(req, res); }); export const helloWorld: HttpsFunction = https.onRequest((req, res) => { res.send('Hello World!'); }); -// import { loadModulesDynamically, registry } from './shared'; -// import path from 'path'; -// loadModulesDynamically(path.resolve(__dirname, 'cloud-functions')); -// Object.assign(exports, registry.exportAll()); -// Object.assign(exports, registry.exportGrouped({ -// memory: '4GiB', -// timeoutSeconds: 540, -// })); -// registry.allHandsOnDeck().catch(() => void 0); -// registry.title = 'reader'; -// registry.version = '0.1.0'; process.on('unhandledRejection', (reason, promise) => { console.error('Unhandled Rejection at:', promise, 'reason:', reason);