* 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
+4 -4
View File
@@ -2,7 +2,7 @@
"name": "ontime-server",
"type": "module",
"main": "src/index.ts",
"version": "2.0.0-alpha",
"version": "2.0.0-beta1",
"exports": "./src/index.js",
"dependencies": {
"@sentry/node": "^7.24.1",
@@ -42,10 +42,10 @@
},
"scripts": {
"addversion": "node -p \"'export const ONTIME_VERSION = ' + JSON.stringify(require('../../package.json').version) + ';'\" > src/ONTIME_VERSION.js",
"postinstall": "pnpm addversion",
"dev": "set NODE_ENV=development && nodemon --exec \"ts-node-esm\" ./src/index.ts",
"dev:test": "set IS_TEST=true && nodemon --exec \"ts-node-esm\" ./src/index.ts",
"setdb": "shx cp ../../demo-db/db.json src/preloaded-db/db.json",
"postinstall": "pnpm addversion && pnpm setdb",
"dev": "cross-env NODE_ENV=development nodemon --exec \"ts-node-esm\" ./src/index.ts",
"dev:test": "cross-env IS_TEST=true nodemon --exec \"ts-node-esm\" ./src/index.ts",
"prebuild": "pnpm setdb",
"build": "pnpm prebuild && esbuild src/app.ts --log-level=error --platform=node --format=cjs --bundle --minify --outfile=dist/index.cjs",
"build:docker": "pnpm prebuild && esbuild src/index.ts --log-level=error --platform=node --format=cjs --minify --bundle --outfile=dist/docker.cjs",
-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