This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
bandolier-template/api/devtools/info.js

32 lines
1.0 KiB

import devtools from '../../lib/devtools.js';
import fs from 'fs';
export const get = async (req, res) => {
if(process.env.DANGER_ADMIN === "1") {
// the devtools module contains all of the errors from the service/api.js for api and sockets
// but to get at the svelte errors we have to read debug/errors/svelte.json
let svelte_errors = [];
try {
const build_config = JSON.parse(fs.readFileSync("./build.json"));
for(let config of build_config) {
if(config.errorFile) {
const meta = JSON.parse(fs.readFileSync(config.errorFile));
// BUG: probably should just return this raw but let's try only errors/warnings
svelte_errors = svelte_errors.concat(meta.errors);
}
}
} catch(error) {
return res.status(404).json({message: "File not found."});
}
return res.status(200).json({
api: devtools.api,
sockets: devtools.sockets,
errors: devtools.errors.concat(svelte_errors)});
} else {
return res.status(404).json({ message: "Not Found."});
}
}