mirror of
https://github.com/Lissy93/web-check.git
synced 2025-05-13 02:34:30 +02:00
Updates all API functions, to work on both Vercel & Netlify
This commit is contained in:
parent
3695c82472
commit
1a95a42853
@ -80,4 +80,5 @@ const getWaybackData = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(getWaybackData);
|
module.exports = middleware(getWaybackData);
|
||||||
|
module.exports.handler = middleware(getWaybackData);
|
||||||
|
@ -94,7 +94,7 @@ const checkDomainAgainstDnsServers = async (domain) => {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(async (url) => {
|
const handler = middleware(async (url) => {
|
||||||
const domain = new URL(url).hostname;
|
const domain = new URL(url).hostname;
|
||||||
const results = await checkDomainAgainstDnsServers(domain);
|
const results = await checkDomainAgainstDnsServers(domain);
|
||||||
return {
|
return {
|
||||||
@ -103,3 +103,6 @@ exports.handler = middleware(async (url) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -48,4 +48,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -54,4 +54,5 @@ const handler = async (url) => {
|
|||||||
return { headerCookies, clientCookies };
|
return { headerCookies, clientCookies };
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const commonMiddleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const handler = async (url) => {
|
const handler = async (url) => {
|
||||||
try {
|
try {
|
||||||
@ -41,4 +41,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = commonMiddleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -51,4 +51,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
const https = require('https');
|
||||||
const commonMiddleware = require('./_common/middleware'); // Make sure this path is correct
|
const middleware = require('./_common/middleware'); // Make sure this path is correct
|
||||||
|
|
||||||
const fetchDNSRecords = async (domain, event, context) => {
|
const handler = async (domain) => {
|
||||||
const dnsTypes = ['DNSKEY', 'DS', 'RRSIG'];
|
const dnsTypes = ['DNSKEY', 'DS', 'RRSIG'];
|
||||||
const records = {};
|
const records = {};
|
||||||
|
|
||||||
@ -49,4 +49,6 @@ const fetchDNSRecords = async (domain, event, context) => {
|
|||||||
return records;
|
return records;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = commonMiddleware(fetchDNSRecords);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
const https = require('https');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const builtWithHandler = async (url) => {
|
const handler = async (url) => {
|
||||||
const apiKey = process.env.BUILT_WITH_API_KEY;
|
const apiKey = process.env.BUILT_WITH_API_KEY;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
@ -45,4 +45,5 @@ const builtWithHandler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(builtWithHandler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -102,4 +102,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -18,4 +18,6 @@ const handler = async (url) => {
|
|||||||
return await lookupAsync(address);
|
return await lookupAsync(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
|
||||||
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -15,4 +15,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
const https = require('https');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
exports.handler = middleware(async (url, event, context) => {
|
const handler = async (url, event, context) => {
|
||||||
const errorResponse = (message, statusCode = 500) => {
|
const errorResponse = (message, statusCode = 500) => {
|
||||||
return {
|
return {
|
||||||
statusCode: statusCode,
|
statusCode: statusCode,
|
||||||
@ -53,5 +53,8 @@ exports.handler = middleware(async (url, event, context) => {
|
|||||||
|
|
||||||
req.end();
|
req.end();
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -22,4 +22,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -66,5 +66,6 @@ return new Promise((resolve, reject) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const urlLib = require('url');
|
const urlLib = require('url');
|
||||||
const commonMiddleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const handler = async (url) => {
|
const handler = async (url) => {
|
||||||
const response = await axios.get(url);
|
const response = await axios.get(url);
|
||||||
@ -45,4 +45,5 @@ const handler = async (url) => {
|
|||||||
return { internal: internalLinks, external: externalLinks };
|
return { internal: internalLinks, external: externalLinks };
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = commonMiddleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const commonMiddleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const dns = require('dns').promises;
|
const dns = require('dns').promises;
|
||||||
const URL = require('url-parse');
|
const URL = require('url-parse');
|
||||||
@ -72,4 +72,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.handler = commonMiddleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -86,4 +86,5 @@ const errorResponse = (message, statusCode = 444) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -4,10 +4,6 @@ const middleware = require('./_common/middleware');
|
|||||||
const handler = async (url, event, context) => {
|
const handler = async (url, event, context) => {
|
||||||
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
||||||
|
|
||||||
if (!url) {
|
|
||||||
throw new Error('URL param is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
throw new Error('API key (GOOGLE_CLOUD_API_KEY) not set');
|
throw new Error('API key (GOOGLE_CLOUD_API_KEY) not set');
|
||||||
}
|
}
|
||||||
@ -19,4 +15,5 @@ const handler = async (url, event, context) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -21,4 +21,6 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -24,4 +24,6 @@ const handler = async (url) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
exports.handler = middleware(handler);
|
|
||||||
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -67,4 +67,5 @@ const handler = async function(url) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -2,7 +2,7 @@ const puppeteer = require('puppeteer-core');
|
|||||||
const chromium = require('chrome-aws-lambda');
|
const chromium = require('chrome-aws-lambda');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const screenshotHandler = async (targetUrl) => {
|
const handler = async (targetUrl) => {
|
||||||
|
|
||||||
if (!targetUrl) {
|
if (!targetUrl) {
|
||||||
throw new Error('URL is missing from queryStringParameters');
|
throw new Error('URL is missing from queryStringParameters');
|
||||||
@ -58,4 +58,5 @@ const screenshotHandler = async (targetUrl) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(screenshotHandler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -38,7 +38,7 @@ const isPgpSigned = (result) => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const securityTxtHandler = async (urlParam) => {
|
const handler = async (urlParam) => {
|
||||||
|
|
||||||
let url;
|
let url;
|
||||||
try {
|
try {
|
||||||
@ -69,8 +69,6 @@ const securityTxtHandler = async (urlParam) => {
|
|||||||
return { isPresent: false };
|
return { isPresent: false };
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(securityTxtHandler);
|
|
||||||
|
|
||||||
async function fetchSecurityTxt(baseURL, path) {
|
async function fetchSecurityTxt(baseURL, path) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const url = new URL(path, baseURL);
|
const url = new URL(path, baseURL);
|
||||||
@ -91,3 +89,6 @@ async function fetchSecurityTxt(baseURL, path) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const commonMiddleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const xml2js = require('xml2js');
|
const xml2js = require('xml2js');
|
||||||
@ -61,4 +61,6 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = commonMiddleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const commonMiddleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
@ -68,4 +68,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = commonMiddleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const fetchSiteCertificateHandler = async (urlString) => {
|
const handler = async (urlString) => {
|
||||||
try {
|
try {
|
||||||
const parsedUrl = new URL(urlString);
|
const parsedUrl = new URL(urlString);
|
||||||
const options = {
|
const options = {
|
||||||
@ -40,4 +40,5 @@ const fetchSiteCertificateHandler = async (urlString) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(fetchSiteCertificateHandler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -2,7 +2,7 @@ const https = require('https');
|
|||||||
const { performance, PerformanceObserver } = require('perf_hooks');
|
const { performance, PerformanceObserver } = require('perf_hooks');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const checkURLHandler = async (url) => {
|
const handler = async (url) => {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new Error('You must provide a URL query parameter!');
|
throw new Error('You must provide a URL query parameter!');
|
||||||
}
|
}
|
||||||
@ -55,4 +55,5 @@ const checkURLHandler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(checkURLHandler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const Wappalyzer = require('wappalyzer');
|
const Wappalyzer = require('wappalyzer');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const analyzeSiteTechnologies = async (url) => {
|
const handler = async (url) => {
|
||||||
const options = {};
|
const options = {};
|
||||||
|
|
||||||
const wappalyzer = new Wappalyzer(options);
|
const wappalyzer = new Wappalyzer(options);
|
||||||
@ -27,4 +27,5 @@ const analyzeSiteTechnologies = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(analyzeSiteTechnologies);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -5,6 +5,9 @@ const middleware = require('./_common/middleware');
|
|||||||
const getGoogleSafeBrowsingResult = async (url) => {
|
const getGoogleSafeBrowsingResult = async (url) => {
|
||||||
try {
|
try {
|
||||||
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
||||||
|
if (!apiKey) {
|
||||||
|
return { error: 'GOOGLE_CLOUD_API_KEY is required for the Google Safe Browsing check' };
|
||||||
|
}
|
||||||
const apiEndpoint = `https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${apiKey}`;
|
const apiEndpoint = `https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${apiKey}`;
|
||||||
|
|
||||||
const requestBody = {
|
const requestBody = {
|
||||||
@ -63,11 +66,15 @@ const getPhishTankResult = async (url) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCloudmersiveResult = async (url) => {
|
const getCloudmersiveResult = async (url) => {
|
||||||
|
const apiKey = process.env.CLOUDMERSIVE_API_KEY;
|
||||||
|
if (!apiKey) {
|
||||||
|
return { error: 'CLOUDMERSIVE_API_KEY is required for the Cloudmersive check' };
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const endpoint = 'https://api.cloudmersive.com/virus/scan/website';
|
const endpoint = 'https://api.cloudmersive.com/virus/scan/website';
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Apikey': process.env.CLOUDMERSIVE_API_KEY,
|
'Apikey': apiKey,
|
||||||
};
|
};
|
||||||
const data = `Url=${encodeURIComponent(url)}`;
|
const data = `Url=${encodeURIComponent(url)}`;
|
||||||
const response = await axios.post(endpoint, data, { headers });
|
const response = await axios.post(endpoint, data, { headers });
|
||||||
@ -92,4 +99,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -25,4 +25,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -2,7 +2,7 @@ const traceroute = require('traceroute');
|
|||||||
const url = require('url');
|
const url = require('url');
|
||||||
const middleware = require('./_common/middleware');
|
const middleware = require('./_common/middleware');
|
||||||
|
|
||||||
const executeTraceroute = async (urlString, context) => {
|
const handler = async (urlString, context) => {
|
||||||
// Parse the URL and get the hostname
|
// Parse the URL and get the hostname
|
||||||
const urlObject = url.parse(urlString);
|
const urlObject = url.parse(urlString);
|
||||||
const host = urlObject.hostname;
|
const host = urlObject.hostname;
|
||||||
@ -28,4 +28,5 @@ const executeTraceroute = async (urlString, context) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(executeTraceroute);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -29,4 +29,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(handler);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
@ -83,7 +83,7 @@ const fetchFromMyAPI = async (hostname) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchWhoisData = async (url) => {
|
const handler = async (url) => {
|
||||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||||
url = 'http://' + url;
|
url = 'http://' + url;
|
||||||
}
|
}
|
||||||
@ -106,4 +106,6 @@ const fetchWhoisData = async (url) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler = middleware(fetchWhoisData);
|
module.exports = middleware(handler);
|
||||||
|
module.exports.handler = middleware(handler);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user