Skip to content

Commit

Permalink
server crash if config file missing
Browse files Browse the repository at this point in the history
  • Loading branch information
TarradeMarc committed Mar 22, 2024
1 parent 0441572 commit 51b1fb3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions configmanager/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ app.get('/:namespace/:application', (req, res) => {
} else {
// If the file exists, read its contents and return as JSON object
fs.readFile(defaultFilePath, 'utf8', (err, data) => {
if (err) throw err;
if (err) {
console.warn("Default decoy config file is missing !");
return res.json([]);
}
if(!data) return res.json([])
const json = JSON.parse(data);
res.json(json);
Expand All @@ -38,7 +41,10 @@ app.get('/:namespace/:application', (req, res) => {
} else {
// If the file exists, read its contents and return as JSON object
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) throw err;
if (err) {
console.warn("Decoy config file is missing !");
return res.json([]);
}
if(!data) return res.json([])
const json = JSON.parse(data);
res.json(json);
Expand Down

0 comments on commit 51b1fb3

Please sign in to comment.