mirror of
https://github.com/Lissy93/web-check.git
synced 2025-01-10 00:08:32 +01:00
Update API endpoints to read URL params from either option
This commit is contained in:
parent
e2e16c9439
commit
d03acb8a3c
@ -1,7 +1,7 @@
|
||||
const https = require('https');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const siteURL = event.queryStringParameters.url;
|
||||
const siteURL = (event.queryStringParameters || event.query).url;
|
||||
|
||||
const errorResponse = (message, statusCode = 500) => {
|
||||
return {
|
||||
|
@ -34,7 +34,7 @@ async function checkPort(port, domain) {
|
||||
}
|
||||
|
||||
exports.handler = async (event, context) => {
|
||||
const domain = event.queryStringParameters.url;
|
||||
const domain = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!domain) {
|
||||
return errorResponse('Missing domain parameter.');
|
||||
|
@ -1,7 +1,7 @@
|
||||
const https = require('https');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
let { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return errorResponse('URL query parameter is required.');
|
||||
|
@ -4,7 +4,8 @@ const dnsPromises = dns.promises;
|
||||
const axios = require('axios');
|
||||
|
||||
exports.handler = async (event) => {
|
||||
const domain = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, "");
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
const domain = url.replace(/^(?:https?:\/\/)?/i, "");
|
||||
try {
|
||||
const addresses = await dnsPromises.resolve4(domain);
|
||||
const results = await Promise.all(addresses.map(async (address) => {
|
||||
|
@ -2,7 +2,7 @@ const dns = require('dns');
|
||||
|
||||
/* Lambda function to fetch the IP address of a given URL */
|
||||
exports.handler = function (event, context, callback) {
|
||||
const addressParam = event.queryStringParameters.url;
|
||||
const addressParam = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!addressParam) {
|
||||
callback(null, errorResponse('Address parameter is missing.'));
|
||||
|
@ -1,5 +1,5 @@
|
||||
exports.handler = async (event) => {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
const redirects = [url];
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const https = require('https');
|
||||
|
||||
exports.handler = async (event, context) => {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const axios = require('axios');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return {
|
||||
|
@ -2,7 +2,7 @@ const dns = require('dns');
|
||||
const util = require('util');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
let hostname = event.queryStringParameters.url;
|
||||
let hostname = (event.queryStringParameters || event.query).url;
|
||||
|
||||
// Handle URLs by extracting hostname
|
||||
if (hostname.startsWith('http://') || hostname.startsWith('https://')) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const axios = require('axios');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return {
|
||||
|
@ -1,7 +1,15 @@
|
||||
const dns = require('dns').promises;
|
||||
|
||||
exports.handler = async (event) => {
|
||||
const url = new URL(event.queryStringParameters.url);
|
||||
let url = (event.queryStringParameters || event.query).url;
|
||||
try {
|
||||
url = new URL(url);
|
||||
} catch (error) {
|
||||
return {
|
||||
statusCode: 400,
|
||||
body: JSON.stringify({ error: `Invalid URL ${error}` }),
|
||||
};
|
||||
}
|
||||
try {
|
||||
const txtRecords = await dns.resolveTxt(url.hostname);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
const axios = require('axios');
|
||||
|
||||
exports.handler = function(event, context, callback) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
callback(null, {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const axios = require('axios');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const siteURL = event.queryStringParameters.url;
|
||||
const siteURL = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!siteURL) {
|
||||
return {
|
||||
|
@ -3,7 +3,7 @@ const chromium = require('chrome-aws-lambda');
|
||||
|
||||
exports.handler = async (event, context, callback) => {
|
||||
let browser = null;
|
||||
let targetUrl = event.queryStringParameters.url;
|
||||
let targetUrl = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!targetUrl) {
|
||||
callback(null, {
|
||||
|
@ -38,7 +38,7 @@ const isPgpSigned = (result) => {
|
||||
};
|
||||
|
||||
exports.handler = async (event, context) => {
|
||||
const urlParam = event.queryStringParameters.url;
|
||||
const urlParam = (event.queryStringParameters || event.query).url;
|
||||
if (!urlParam) {
|
||||
return {
|
||||
statusCode: 400,
|
||||
|
@ -2,7 +2,7 @@ const https = require('https');
|
||||
const { performance, PerformanceObserver } = require('perf_hooks');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const https = require('https');
|
||||
|
||||
exports.handler = async function (event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
const apiKey = process.env.BUILT_WITH_API_KEY;
|
||||
|
||||
const errorResponse = (message, statusCode = 500) => {
|
||||
|
@ -2,8 +2,9 @@ const axios = require('axios');
|
||||
const xml2js = require('xml2js');
|
||||
|
||||
exports.handler = async (event) => {
|
||||
const baseUrl = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, "");
|
||||
const url = baseUrl.startsWith('http') ? baseUrl : `http://${baseUrl}`;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
// const baseUrl = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, "");
|
||||
// const url = baseUrl.startsWith('http') ? baseUrl : `http://${baseUrl}`;
|
||||
let sitemapUrl;
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const https = require('https');
|
||||
|
||||
exports.handler = async function (event, context) {
|
||||
const { url } = event.queryStringParameters;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
const errorResponse = (message, statusCode = 500) => {
|
||||
return {
|
||||
|
@ -34,7 +34,7 @@ exports.handler = async (event, context, callback) => {
|
||||
}
|
||||
|
||||
// Get URL from param
|
||||
let url = event.queryStringParameters.url;
|
||||
let url = (event.queryStringParameters || event.query).url;
|
||||
if (!/^https?:\/\//i.test(url)) {
|
||||
url = 'http://' + url;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ const traceroute = require('traceroute');
|
||||
const url = require('url');
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const urlString = event.queryStringParameters.url;
|
||||
const urlString = (event.queryStringParameters || event.query).url;
|
||||
|
||||
try {
|
||||
if (!urlString) {
|
||||
|
@ -24,7 +24,7 @@ const getBaseDomain = (url) => {
|
||||
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
let url = event.queryStringParameters.url;
|
||||
const url = (event.queryStringParameters || event.query).url;
|
||||
|
||||
if (!url) {
|
||||
return errorResponse('URL query parameter is required.', 400);
|
||||
|
Loading…
Reference in New Issue
Block a user