mirror of
https://github.com/Lissy93/web-check.git
synced 2025-02-10 23:49:38 +01: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) {
|
||||
return {
|
||||
statusCode: 400,
|
||||
body: JSON.stringify({
|
||||
body: {
|
||||
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. '
|
||||
+ '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.',
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ import dns from 'dns';
|
||||
import URL from 'url-parse';
|
||||
import middleware from './_common/middleware.js';
|
||||
|
||||
// TODO: Fix.
|
||||
|
||||
const mailConfigHandler = async (url, event, context) => {
|
||||
try {
|
||||
const domain = new URL(url).hostname || new URL(url).pathname;
|
||||
@ -70,7 +72,7 @@ const mailConfigHandler = async (url, event, context) => {
|
||||
} else {
|
||||
return {
|
||||
statusCode: 500,
|
||||
body: JSON.stringify({ error: error.message }),
|
||||
body: { error: error.message },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ const tlsHandler = async (url) => {
|
||||
if (typeof scanId !== 'number') {
|
||||
return {
|
||||
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}`);
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(resultResponse.data),
|
||||
body: resultResponse.data,
|
||||
};
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
|
Loading…
Reference in New Issue
Block a user