2023-07-20 23:49:28 +02:00
|
|
|
const Wappalyzer = require('wappalyzer');
|
2023-08-09 23:33:36 +02:00
|
|
|
const middleware = require('./_common/middleware');
|
2023-07-20 23:49:28 +02:00
|
|
|
|
2023-08-09 23:33:36 +02:00
|
|
|
const analyzeSiteTechnologies = async (url) => {
|
2023-07-20 23:49:28 +02:00
|
|
|
const options = {};
|
|
|
|
|
|
|
|
const wappalyzer = new Wappalyzer(options);
|
|
|
|
|
2023-08-09 23:33:36 +02:00
|
|
|
try {
|
|
|
|
await wappalyzer.init();
|
|
|
|
const headers = {};
|
|
|
|
const storage = {
|
|
|
|
local: {},
|
|
|
|
session: {},
|
2023-07-20 23:49:28 +02:00
|
|
|
};
|
2023-08-09 23:33:36 +02:00
|
|
|
const site = await wappalyzer.open(url, headers, storage);
|
|
|
|
const results = await site.analyze();
|
2023-07-20 23:49:28 +02:00
|
|
|
|
2023-08-09 23:33:36 +02:00
|
|
|
if (!results.technologies || results.technologies.length === 0) {
|
|
|
|
throw new Error('Unable to find any technologies for site');
|
|
|
|
}
|
|
|
|
return results;
|
2023-07-20 23:49:28 +02:00
|
|
|
} catch (error) {
|
2023-08-09 23:33:36 +02:00
|
|
|
throw new Error(error.message);
|
|
|
|
} finally {
|
|
|
|
await wappalyzer.destroy();
|
2023-07-20 23:49:28 +02:00
|
|
|
}
|
|
|
|
};
|
2023-08-09 23:33:36 +02:00
|
|
|
|
|
|
|
exports.handler = middleware(analyzeSiteTechnologies);
|