mirror of
https://github.com/Lissy93/web-check.git
synced 2024-11-25 09:43:13 +01:00
Convert all API endpoints into ESM modules
This commit is contained in:
parent
e255c358cb
commit
c9e57400fd
@ -124,4 +124,4 @@ const commonMiddleware = (handler) => {
|
|||||||
return nativeMode ? vercelHandler : netlifyHandler;
|
return nativeMode ? vercelHandler : netlifyHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = commonMiddleware;
|
export default commonMiddleware;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const convertTimestampToDate = (timestamp) => {
|
const convertTimestampToDate = (timestamp) => {
|
||||||
const [year, month, day, hour, minute, second] = [
|
const [year, month, day, hour, minute, second] = [
|
||||||
@ -46,7 +46,7 @@ const getScanFrequency = (firstScan, lastScan, totalScans, changeCount) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWaybackData = async (url) => {
|
const wayBackHandler = async (url) => {
|
||||||
const cdxUrl = `https://web.archive.org/cdx/search/cdx?url=${url}&output=json&fl=timestamp,statuscode,digest,length,offset`;
|
const cdxUrl = `https://web.archive.org/cdx/search/cdx?url=${url}&output=json&fl=timestamp,statuscode,digest,length,offset`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -80,5 +80,5 @@ const getWaybackData = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(getWaybackData);
|
export const handler = middleware(wayBackHandler);
|
||||||
module.exports.handler = middleware(getWaybackData);
|
export default handler;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const dns = require('dns');
|
import dns from 'dns';
|
||||||
const { URL } = require('url');
|
import { URL } from 'url';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const DNS_SERVERS = [
|
const DNS_SERVERS = [
|
||||||
{ name: 'AdGuard', ip: '176.103.130.130' },
|
{ name: 'AdGuard', ip: '176.103.130.130' },
|
||||||
@ -94,12 +94,12 @@ const checkDomainAgainstDnsServers = async (domain) => {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
export const blockListHandler = 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 { blocklists: results };
|
return { blocklists: results };
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(blockListHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
import https from 'https';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const carbonHandler = async (url) => {
|
||||||
|
|
||||||
// First, get the size of the website's HTML
|
// First, get the size of the website's HTML
|
||||||
const getHtmlSize = (url) => new Promise((resolve, reject) => {
|
const getHtmlSize = (url) => new Promise((resolve, reject) => {
|
||||||
@ -48,5 +48,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(carbonHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const puppeteer = require('puppeteer');
|
import puppeteer from 'puppeteer';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const getPuppeteerCookies = async (url) => {
|
const getPuppeteerCookies = async (url) => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
@ -21,7 +21,7 @@ const getPuppeteerCookies = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
const cookieHandler = async (url) => {
|
||||||
let headerCookies = null;
|
let headerCookies = null;
|
||||||
let clientCookies = null;
|
let clientCookies = null;
|
||||||
|
|
||||||
@ -54,5 +54,5 @@ const handler = async (url) => {
|
|||||||
return { headerCookies, clientCookies };
|
return { headerCookies, clientCookies };
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(cookieHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const dns = require('dns');
|
import { promises as dnsPromises, lookup } from 'dns';
|
||||||
const dnsPromises = dns.promises;
|
import axios from 'axios';
|
||||||
const axios = require('axios');
|
import middleware from './_common/middleware.js';
|
||||||
const middleware = require('./_common/middleware');
|
|
||||||
|
|
||||||
const handler = async (url) => {
|
const dnsHandler = async (url) => {
|
||||||
try {
|
try {
|
||||||
const domain = url.replace(/^(?:https?:\/\/)?/i, "");
|
const domain = url.replace(/^(?:https?:\/\/)?/i, "");
|
||||||
const addresses = await dnsPromises.resolve4(domain);
|
const addresses = await dnsPromises.resolve4(domain);
|
||||||
@ -41,5 +40,7 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
|
||||||
module.exports.handler = middleware(handler);
|
export const handler = middleware(dnsHandler);
|
||||||
|
export default handler;
|
||||||
|
|
||||||
|
12
api/dns.js
12
api/dns.js
@ -1,8 +1,8 @@
|
|||||||
const dns = require('dns');
|
import dns from 'dns';
|
||||||
const util = require('util');
|
import util from 'util';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const dnsHandler = async (url) => {
|
||||||
let hostname = url;
|
let hostname = url;
|
||||||
|
|
||||||
// Handle URLs by extracting hostname
|
// Handle URLs by extracting hostname
|
||||||
@ -51,5 +51,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(dnsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
import https from 'https';
|
||||||
const middleware = require('./_common/middleware'); // Make sure this path is correct
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (domain) => {
|
const dnsSecHandler = async (domain) => {
|
||||||
const dnsTypes = ['DNSKEY', 'DS', 'RRSIG'];
|
const dnsTypes = ['DNSKEY', 'DS', 'RRSIG'];
|
||||||
const records = {};
|
const records = {};
|
||||||
|
|
||||||
@ -53,5 +53,5 @@ const handler = async (domain) => {
|
|||||||
return records;
|
return records;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(dnsSecHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
import https from 'https';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const featuresHandler = async (url) => {
|
||||||
const apiKey = process.env.BUILT_WITH_API_KEY;
|
const apiKey = process.env.BUILT_WITH_API_KEY;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
@ -45,5 +45,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(featuresHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const hasWaf = (waf) => {
|
const hasWaf = (waf) => {
|
||||||
return {
|
return {
|
||||||
@ -7,7 +7,7 @@ const hasWaf = (waf) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
const firewallHandler = async (url) => {
|
||||||
const fullUrl = url.startsWith('http') ? url : `http://${url}`;
|
const fullUrl = url.startsWith('http') ? url : `http://${url}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -102,5 +102,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(firewallHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const dns = require('dns');
|
import dns from 'dns';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const lookupAsync = (address) => {
|
const lookupAsync = (address) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -13,11 +13,11 @@ const lookupAsync = (address) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
const ipHandler = async (url) => {
|
||||||
const address = url.replaceAll('https://', '').replaceAll('http://', '');
|
const address = url.replaceAll('https://', '').replaceAll('http://', '');
|
||||||
return await lookupAsync(address);
|
return await lookupAsync(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(ipHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
const headersHandler = async (url, event, context) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url, {
|
const response = await axios.get(url, {
|
||||||
validateStatus: function (status) {
|
validateStatus: function (status) {
|
||||||
@ -15,5 +15,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(headersHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
11
api/hsts.js
11
api/hsts.js
@ -1,7 +1,7 @@
|
|||||||
const https = require('https');
|
import https from 'https';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
const hstsHandler = async (url, event, context) => {
|
||||||
const errorResponse = (message, statusCode = 500) => {
|
const errorResponse = (message, statusCode = 500) => {
|
||||||
return {
|
return {
|
||||||
statusCode: statusCode,
|
statusCode: statusCode,
|
||||||
@ -45,6 +45,5 @@ const handler = async (url, event, context) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(hstsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const httpsSecHandler = async (url) => {
|
||||||
const fullUrl = url.startsWith('http') ? url : `http://${url}`;
|
const fullUrl = url.startsWith('http') ? url : `http://${url}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -22,5 +22,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(httpsSecHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const unzipper = require('unzipper');
|
import unzipper from 'unzipper';
|
||||||
const csv = require('csv-parser');
|
import csv from 'csv-parser';
|
||||||
const fs = require('fs');
|
import fs from 'fs';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
// Should also work with the following sources:
|
// Should also work with the following sources:
|
||||||
// https://www.domcop.com/files/top/top10milliondomains.csv.zip
|
// https://www.domcop.com/files/top/top10milliondomains.csv.zip
|
||||||
@ -14,7 +14,7 @@ const middleware = require('./_common/middleware');
|
|||||||
const FILE_URL = 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip';
|
const FILE_URL = 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip';
|
||||||
const TEMP_FILE_PATH = '/tmp/top-1m.csv';
|
const TEMP_FILE_PATH = '/tmp/top-1m.csv';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const rankHandler = async (url) => {
|
||||||
let domain = null;
|
let domain = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -66,6 +66,5 @@ return new Promise((resolve, reject) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(rankHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const cheerio = require('cheerio');
|
import cheerio from 'cheerio';
|
||||||
const urlLib = require('url');
|
import urlLib from 'url';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const linkedPagesHandler = async (url) => {
|
||||||
const response = await axios.get(url);
|
const response = await axios.get(url);
|
||||||
const html = response.data;
|
const html = response.data;
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
@ -45,5 +45,5 @@ const handler = async (url) => {
|
|||||||
return { internal: internalLinks, external: externalLinks };
|
return { internal: internalLinks, external: externalLinks };
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(linkedPagesHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const middleware = require('./_common/middleware');
|
import dns from 'dns';
|
||||||
|
import URL from 'url-parse';
|
||||||
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const dns = require('dns').promises;
|
const mailConfigHandler = async (url, event, context) => {
|
||||||
const URL = require('url-parse');
|
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
|
||||||
try {
|
try {
|
||||||
const domain = new URL(url).hostname || new URL(url).pathname;
|
const domain = new URL(url).hostname || new URL(url).pathname;
|
||||||
|
|
||||||
@ -77,5 +76,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(mailConfigHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
10
api/ports.js
10
api/ports.js
@ -1,5 +1,5 @@
|
|||||||
const net = require('net');
|
import net from 'net';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
// A list of commonly used ports.
|
// A list of commonly used ports.
|
||||||
const PORTS = [
|
const PORTS = [
|
||||||
@ -34,7 +34,7 @@ async function checkPort(port, domain) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
const portsHandler = async (url, event, context) => {
|
||||||
const domain = url.replace(/(^\w+:|^)\/\//, '');
|
const domain = url.replace(/(^\w+:|^)\/\//, '');
|
||||||
|
|
||||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||||
@ -80,5 +80,5 @@ const errorResponse = (message, statusCode = 444) => {
|
|||||||
return { error: message };
|
return { error: message };
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(portsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
const qualityHandler = async (url, event, context) => {
|
||||||
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
@ -18,5 +18,5 @@ const handler = async (url, event, context) => {
|
|||||||
return (await axios.get(endpoint)).data;
|
return (await axios.get(endpoint)).data;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(qualityHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
10
api/rank.js
10
api/rank.js
@ -1,7 +1,7 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const rankHandler = async (url) => {
|
||||||
const domain = url ? new URL(url).hostname : null;
|
const domain = url ? new URL(url).hostname : null;
|
||||||
if (!domain) throw new Error('Invalid URL');
|
if (!domain) throw new Error('Invalid URL');
|
||||||
|
|
||||||
@ -21,6 +21,6 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(rankHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
const handler = async (url) => {
|
import got from 'got';
|
||||||
const redirects = [url];
|
import middleware from './_common/middleware.js';
|
||||||
const got = await import('got');
|
|
||||||
|
|
||||||
|
const redirectsHandler = async (url) => {
|
||||||
|
const redirects = [url];
|
||||||
try {
|
try {
|
||||||
await got.default(url, {
|
await got(url, {
|
||||||
followRedirect: true,
|
followRedirect: true,
|
||||||
maxRedirects: 12,
|
maxRedirects: 12,
|
||||||
hooks: {
|
hooks: {
|
||||||
@ -23,7 +24,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const middleware = require('./_common/middleware');
|
export const handler = middleware(redirectsHandler);
|
||||||
|
export default handler;
|
||||||
module.exports = middleware(handler);
|
|
||||||
module.exports.handler = middleware(handler);
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const parseRobotsTxt = (content) => {
|
const parseRobotsTxt = (content) => {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
@ -31,7 +31,7 @@ const parseRobotsTxt = (content) => {
|
|||||||
return { robots: rules };
|
return { robots: rules };
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = async function(url) {
|
const robotsHandler = async function(url) {
|
||||||
let parsedURL;
|
let parsedURL;
|
||||||
try {
|
try {
|
||||||
parsedURL = new URL(url);
|
parsedURL = new URL(url);
|
||||||
@ -67,5 +67,5 @@ const handler = async function(url) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(robotsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const puppeteer = require('puppeteer-core');
|
import puppeteer from 'puppeteer-core';
|
||||||
const chromium = require('chrome-aws-lambda');
|
import chromium from 'chrome-aws-lambda';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (targetUrl) => {
|
const screenshotHandler = async (targetUrl) => {
|
||||||
|
|
||||||
if (!targetUrl) {
|
if (!targetUrl) {
|
||||||
throw new Error('URL is missing from queryStringParameters');
|
throw new Error('URL is missing from queryStringParameters');
|
||||||
@ -58,5 +58,5 @@ const handler = async (targetUrl) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(screenshotHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const { https } = require('follow-redirects');
|
import { URL } from 'url';
|
||||||
const { URL } = require('url');
|
import followRedirects from 'follow-redirects';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
|
const { https } = followRedirects;
|
||||||
|
|
||||||
const SECURITY_TXT_PATHS = [
|
const SECURITY_TXT_PATHS = [
|
||||||
'/security.txt',
|
'/security.txt',
|
||||||
@ -38,7 +40,7 @@ const isPgpSigned = (result) => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (urlParam) => {
|
const securityTxtHandler = async (urlParam) => {
|
||||||
|
|
||||||
let url;
|
let url;
|
||||||
try {
|
try {
|
||||||
@ -90,5 +92,5 @@ async function fetchSecurityTxt(baseURL, path) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(securityTxtHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const middleware = require('./_common/middleware');
|
import axios from 'axios';
|
||||||
|
import xml2js from 'xml2js';
|
||||||
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const axios = require('axios');
|
const sitemapHandler = async (url) => {
|
||||||
const xml2js = require('xml2js');
|
|
||||||
|
|
||||||
const handler = async (url) => {
|
|
||||||
let sitemapUrl = `${url}/sitemap.xml`;
|
let sitemapUrl = `${url}/sitemap.xml`;
|
||||||
|
|
||||||
const hardTimeOut = 5000;
|
const hardTimeOut = 5000;
|
||||||
@ -49,6 +48,6 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(sitemapHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const middleware = require('./_common/middleware');
|
import axios from 'axios';
|
||||||
|
import cheerio from 'cheerio';
|
||||||
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const axios = require('axios');
|
const socialTagsHandler = async (url) => {
|
||||||
const cheerio = require('cheerio');
|
|
||||||
|
|
||||||
const handler = async (url) => {
|
|
||||||
|
|
||||||
// Check if url includes protocol
|
// Check if url includes protocol
|
||||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||||
@ -61,5 +60,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(socialTagsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
10
api/ssl.js
10
api/ssl.js
@ -1,7 +1,7 @@
|
|||||||
const tls = require('tls');
|
import tls from 'tls';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (urlString) => {
|
const sslHandler = async (urlString) => {
|
||||||
try {
|
try {
|
||||||
const parsedUrl = new URL(urlString);
|
const parsedUrl = new URL(urlString);
|
||||||
const options = {
|
const options = {
|
||||||
@ -40,5 +40,5 @@ const handler = async (urlString) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(sslHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const https = require('https');
|
import https from 'https';
|
||||||
const { performance, PerformanceObserver } = require('perf_hooks');
|
import { performance, PerformanceObserver } from 'perf_hooks';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const statusHandler = 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,5 +55,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(statusHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const Wappalyzer = require('wappalyzer');
|
import Wappalyzer from 'wappalyzer';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const techStackHandler = async (url) => {
|
||||||
const options = {};
|
const options = {};
|
||||||
|
|
||||||
const wappalyzer = new Wappalyzer(options);
|
const wappalyzer = new Wappalyzer(options);
|
||||||
@ -27,5 +27,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(techStackHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const xml2js = require('xml2js');
|
import xml2js from 'xml2js';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const getGoogleSafeBrowsingResult = async (url) => {
|
const getGoogleSafeBrowsingResult = async (url) => {
|
||||||
try {
|
try {
|
||||||
@ -84,7 +84,7 @@ const getCloudmersiveResult = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
const threatsHandler = async (url) => {
|
||||||
try {
|
try {
|
||||||
const urlHaus = await getUrlHausResult(url);
|
const urlHaus = await getUrlHausResult(url);
|
||||||
const phishTank = await getPhishTankResult(url);
|
const phishTank = await getPhishTankResult(url);
|
||||||
@ -99,5 +99,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(threatsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
10
api/tls.js
10
api/tls.js
@ -1,9 +1,9 @@
|
|||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const MOZILLA_TLS_OBSERVATORY_API = 'https://tls-observatory.services.mozilla.com/api/v1';
|
const MOZILLA_TLS_OBSERVATORY_API = 'https://tls-observatory.services.mozilla.com/api/v1';
|
||||||
|
|
||||||
const handler = async (url) => {
|
const tlsHandler = async (url) => {
|
||||||
try {
|
try {
|
||||||
const domain = new URL(url).hostname;
|
const domain = new URL(url).hostname;
|
||||||
const scanResponse = await axios.post(`${MOZILLA_TLS_OBSERVATORY_API}/scan?target=${domain}`);
|
const scanResponse = await axios.post(`${MOZILLA_TLS_OBSERVATORY_API}/scan?target=${domain}`);
|
||||||
@ -25,5 +25,5 @@ const handler = async (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(tlsHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const traceroute = require('traceroute');
|
import url from 'url';
|
||||||
const url = require('url');
|
import traceroute from 'traceroute';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (urlString, context) => {
|
const traceRouteHandler = 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,5 +28,5 @@ const handler = async (urlString, context) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(traceRouteHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const dns = require('dns').promises;
|
import dns from 'dns/promises';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const handler = async (url, event, context) => {
|
const txtRecordHandler = async (url, event, context) => {
|
||||||
try {
|
try {
|
||||||
const parsedUrl = new URL(url);
|
const parsedUrl = new URL(url);
|
||||||
|
|
||||||
@ -29,5 +29,5 @@ const handler = async (url, event, context) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(txtRecordHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
14
api/whois.js
14
api/whois.js
@ -1,7 +1,7 @@
|
|||||||
const net = require('net');
|
import net from 'net';
|
||||||
const psl = require('psl');
|
import psl from 'psl';
|
||||||
const axios = require('axios');
|
import axios from 'axios';
|
||||||
const middleware = require('./_common/middleware');
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
const getBaseDomain = (url) => {
|
const getBaseDomain = (url) => {
|
||||||
let protocol = '';
|
let protocol = '';
|
||||||
@ -83,7 +83,7 @@ const fetchFromMyAPI = async (hostname) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = async (url) => {
|
const whoisHandler = async (url) => {
|
||||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||||
url = 'http://' + url;
|
url = 'http://' + url;
|
||||||
}
|
}
|
||||||
@ -106,6 +106,6 @@ const handler = async (url) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = middleware(handler);
|
export const handler = middleware(whoisHandler);
|
||||||
module.exports.handler = middleware(handler);
|
export default handler;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user