mirror of
https://github.com/Lissy93/web-check.git
synced 2025-05-17 20:50:46 +02:00
JSON parsing in API endpoints
This commit is contained in:
parent
cc510bd281
commit
cb8db0b1f5
@ -33,12 +33,12 @@ const linkedPagesHandler = async (url) => {
|
|||||||
if (internalLinks.length === 0 && externalLinks.length === 0) {
|
if (internalLinks.length === 0 && externalLinks.length === 0) {
|
||||||
return {
|
return {
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
body: JSON.stringify({
|
body: {
|
||||||
skipped: 'No internal or external links found. '
|
skipped: 'No internal or external links found. '
|
||||||
+ 'This may be due to the website being dynamically rendered, using a client-side framework (like React), and without SSR enabled. '
|
+ 'This may be due to the website being dynamically rendered, using a client-side framework (like React), and without SSR enabled. '
|
||||||
+ 'That would mean that the static HTML returned from the HTTP request doesn\'t contain any meaningful content for Web-Check to analyze. '
|
+ 'That would mean that the static HTML returned from the HTTP request doesn\'t contain any meaningful content for Web-Check to analyze. '
|
||||||
+ 'You can rectify this by using a headless browser to render the page instead.',
|
+ 'You can rectify this by using a headless browser to render the page instead.',
|
||||||
}),
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ import dns from 'dns';
|
|||||||
import URL from 'url-parse';
|
import URL from 'url-parse';
|
||||||
import middleware from './_common/middleware.js';
|
import middleware from './_common/middleware.js';
|
||||||
|
|
||||||
|
// TODO: Fix.
|
||||||
|
|
||||||
const mailConfigHandler = async (url, event, context) => {
|
const mailConfigHandler = 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;
|
||||||
@ -70,7 +72,7 @@ const mailConfigHandler = async (url, event, context) => {
|
|||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
body: JSON.stringify({ error: error.message }),
|
body: { error: error.message },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ const tlsHandler = async (url) => {
|
|||||||
if (typeof scanId !== 'number') {
|
if (typeof scanId !== 'number') {
|
||||||
return {
|
return {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
body: JSON.stringify({ error: 'Failed to get scan_id from TLS Observatory' }),
|
body: { error: 'Failed to get scan_id from TLS Observatory' },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const resultResponse = await axios.get(`${MOZILLA_TLS_OBSERVATORY_API}/results?id=${scanId}`);
|
const resultResponse = await axios.get(`${MOZILLA_TLS_OBSERVATORY_API}/results?id=${scanId}`);
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: JSON.stringify(resultResponse.data),
|
body: resultResponse.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { error: error.message };
|
return { error: error.message };
|
||||||
|
Loading…
Reference in New Issue
Block a user