other routes
Build and Push Docker Images / build-and-push (push) Successful in 45s

This commit is contained in:
2025-11-20 14:57:58 +01:00
parent 8ef3848f6f
commit b126c08c27
3 changed files with 434 additions and 1 deletions
+75 -1
View File
@@ -1,5 +1,5 @@
const express = require('express');
const { fetchHtml, extractSeo, extractMetaTags } = require('./scraper');
const { fetchHtml, extractSeo, extractMetaTags, extractOutgoingCalls, extractResultingUrl } = require('./scraper');
const dbOps = require('./database');
const { authenticateApiKey } = require('./middleware');
const { isBrowserConnected } = require('./browser');
@@ -155,4 +155,78 @@ router.get('/meta', authenticateApiKey, async (req, res) => {
}
});
// Outgoing calls capture endpoint
router.get('/outgoing-calls', authenticateApiKey, async (req, res) => {
const { url, skipCache } = req.query;
// Validate URL parameter
if (!url) {
return res.status(400).json({
error: 'Missing required parameter: url',
});
}
// Validate URL format
let urlObj;
try {
urlObj = new URL(url);
} catch (error) {
return res.status(400).json({
error: 'Invalid URL format',
});
}
// Parse skipCache (accept 'true', '1', 'yes', etc.)
const shouldSkipCache = skipCache === 'true' || skipCache === '1' || skipCache === 'yes';
try {
const callsData = await extractOutgoingCalls(url, shouldSkipCache);
res.json(callsData);
} catch (error) {
console.error('Outgoing calls capture error:', error);
res.status(500).json({
status: 'error',
url: url,
error: error.message,
});
}
});
// Resulting URL endpoint
router.get('/resulting-url', authenticateApiKey, async (req, res) => {
const { url, skipCache } = req.query;
// Validate URL parameter
if (!url) {
return res.status(400).json({
error: 'Missing required parameter: url',
});
}
// Validate URL format
let urlObj;
try {
urlObj = new URL(url);
} catch (error) {
return res.status(400).json({
error: 'Invalid URL format',
});
}
// Parse skipCache (accept 'true', '1', 'yes', etc.)
const shouldSkipCache = skipCache === 'true' || skipCache === '1' || skipCache === 'yes';
try {
const resultingUrlData = await extractResultingUrl(url, shouldSkipCache);
res.json(resultingUrlData);
} catch (error) {
console.error('Resulting URL error:', error);
res.status(500).json({
status: 'error',
original_url: url,
error: error.message,
});
}
});
module.exports = router;