From 9fc7a132bacde2be0853964e8c384e239eed5461 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 20 Apr 2022 00:06:21 +0500 Subject: [PATCH 1/2] test: fixed unhandled timout --- api/src/app.ts | 2 +- api/src/utils/connectDB.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/app.ts b/api/src/app.ts index 77c3380..100b529 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -59,6 +59,6 @@ export default setProcessVariables().then(async () => { app.use(onError) - connectDB() + await connectDB() return app }) diff --git a/api/src/utils/connectDB.ts b/api/src/utils/connectDB.ts index 7709b49..ea52cbe 100644 --- a/api/src/utils/connectDB.ts +++ b/api/src/utils/connectDB.ts @@ -2,7 +2,7 @@ import mongoose from 'mongoose' import { populateClients } from '../routes/api/auth' import { seedDB } from './seedDB' -export const connectDB = () => { +export const connectDB = async () => { // NOTE: when exporting app.js as agent for supertest // we should exclude connecting to the real database if (process.env.NODE_ENV === 'test') { From c4cea4a12b7eda4daeed995f41c0b10bcea79871 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 20 Apr 2022 05:54:56 +0500 Subject: [PATCH 2/2] fix: drive path in server mode --- api/src/utils/setProcessVariables.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/api/src/utils/setProcessVariables.ts b/api/src/utils/setProcessVariables.ts index 8cb705f..b44f1bd 100644 --- a/api/src/utils/setProcessVariables.ts +++ b/api/src/utils/setProcessVariables.ts @@ -1,5 +1,5 @@ import path from 'path' -import { getRealPath } from '@sasjs/utils' +import { getAbsolutePath, getRealPath } from '@sasjs/utils' import { configuration } from '../../package.json' import { getDesktopFields } from '.' @@ -12,18 +12,17 @@ export const setProcessVariables = async () => { const { MODE } = process.env - if (MODE?.trim() !== 'server') { + if (MODE?.trim() === 'server') { + const { SAS_PATH, DRIVE_PATH } = process.env + + process.sasLoc = SAS_PATH ?? configuration.sasPath + const absPath = getAbsolutePath(DRIVE_PATH ?? 'tmp', process.cwd()) + process.driveLoc = getRealPath(absPath) + } else { const { sasLoc, driveLoc } = await getDesktopFields() process.sasLoc = sasLoc process.driveLoc = driveLoc - } else { - const { SAS_PATH, DRIVE_PATH } = process.env - - process.sasLoc = SAS_PATH ?? configuration.sasPath - process.driveLoc = getRealPath( - path.join(process.cwd(), DRIVE_PATH ?? 'tmp') - ) } console.log('sasLoc: ', process.sasLoc)