feat: Add express server for crawling functionality

This commit is contained in:
Harsh Gupta 2024-08-14 19:17:23 +05:30 committed by Harsh Gupta (aider)
parent 1d8b3eae0d
commit 32263c7e9e

View File

@ -0,0 +1,25 @@
import express from 'express';
import { container } from 'tsyringe';
import { CrawlerHost } from './cloud-functions/crawler';
const app = express();
const port = process.env.PORT || 3000;
const crawlerHost = container.resolve(CrawlerHost);
app.use(express.json());
app.post('/crawl', async (req, res) => {
try {
await crawlerHost.crawl(req, res);
} catch (error) {
console.error('Error during crawl:', error);
res.status(500).json({ error: 'An error occurred during the crawl' });
}
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
export default app;