2024-05-06 22:51:32 +02:00
|
|
|
import Wappalyzer from 'wappalyzer';
|
|
|
|
import middleware from './_common/middleware.js';
|
2023-07-20 23:49:28 +02:00
|
|
|
|
2024-05-06 22:51:32 +02:00
|
|
|
const techStackHandler = 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
|
|
|
|
2024-05-06 22:51:32 +02:00
|
|
|
export const handler = middleware(techStackHandler);
|
|
|
|
export default handler;
|