web-check/api/tech-stack.js
2024-05-06 21:51:32 +01:00

32 lines
782 B
JavaScript

import Wappalyzer from 'wappalyzer';
import middleware from './_common/middleware.js';
const techStackHandler = async (url) => {
const options = {};
const wappalyzer = new Wappalyzer(options);
try {
await wappalyzer.init();
const headers = {};
const storage = {
local: {},
session: {},
};
const site = await wappalyzer.open(url, headers, storage);
const results = await site.analyze();
if (!results.technologies || results.technologies.length === 0) {
throw new Error('Unable to find any technologies for site');
}
return results;
} catch (error) {
throw new Error(error.message);
} finally {
await wappalyzer.destroy();
}
};
export const handler = middleware(techStackHandler);
export default handler;