* chore: cleanup handling of a bad read

* chore: configure e2e testing

* chore: version bump
This commit is contained in:
Carlos Valente
2023-04-02 19:07:13 +02:00
committed by GitHub
parent 0e47b5c10c
commit 03e7428348
17 changed files with 140 additions and 303 deletions
-3
View File
@@ -64,9 +64,6 @@ app.use('/playback', playbackRouter);
app.use('/external', express.static(join(currentDirectory, 'external')));
// serve static - react, in test mode we fetch the React app from module
const newpath = join(currentDirectory, resolvedPath());
console.log('serving content at ', newpath);
app.use(express.static(join(currentDirectory, resolvedPath())));
app.get('*', (req, res) => {
+4
View File
@@ -57,6 +57,10 @@ async function loadDb() {
const db = new Low(adapter);
const data = await parseDb(dbInDisk, db);
if (data === null) {
console.log('ERROR: Invalid JSON format');
return;
}
db.data = data;
await db.write();
+5 -2
View File
@@ -46,12 +46,15 @@ const devPath = '../../client/build/';
const dockerPath = 'client/';
export const resolvedPath = (): string => {
if (isProduction) {
return productionPath;
if (isTest) {
return devPath;
}
if (isDocker) {
return dockerPath;
}
if (isProduction) {
return productionPath;
}
return devPath;
};
+2 -3
View File
@@ -258,10 +258,9 @@ export const parseExcel = async (excelData) => {
* @param {boolean} [enforce=false] - flag, tells to create an object anyway
* @returns {object} - parsed object
*/
export const parseJson = async (jsonData, enforce = false): Promise<DatabaseModel | -1> => {
export const parseJson = async (jsonData, enforce = false): Promise<DatabaseModel | null> => {
if (!jsonData || typeof jsonData !== 'object') {
console.log('ERROR: Invalid JSON format');
return -1;
return null;
}
// object containing the parsed data