From 75291f939770de963d48c2ff1c967da9493bd668 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 16 Mar 2022 19:20:38 +0500 Subject: [PATCH 1/3] fix: desktop mode web index.html js script included --- api/src/app.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/app.ts b/api/src/app.ts index b711fab..cc8bff2 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -31,7 +31,6 @@ app.use(cookieParser()) app.use(morgan('tiny')) app.use(express.json({ limit: '50mb' })) app.use(express.static(path.join(__dirname, '../public'))) -app.use(express.static(getWebBuildFolderPath())) const onError: ErrorRequestHandler = (err, req, res, next) => { console.error(err.stack) @@ -44,6 +43,10 @@ export default setProcessVariables().then(async () => { const { setupRoutes } = await import('./routes/setupRoutes') setupRoutes(app) + // should be served after setting up web route + // index.html needs to be injected with some js script. + app.use(express.static(getWebBuildFolderPath())) + console.log('sasJSCoreMacros', sasJSCoreMacros) app.use(onError) From fd2629862f10ec16e2266d68420499e715b5d58c Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 16 Mar 2022 19:21:39 +0500 Subject: [PATCH 2/3] fix: preferred to show param errors from query --- api/src/routes/api/drive.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/routes/api/drive.ts b/api/src/routes/api/drive.ts index 0bfb6b5..0725696 100644 --- a/api/src/routes/api/drive.ts +++ b/api/src/routes/api/drive.ts @@ -40,7 +40,7 @@ driveRouter.get('/file', async (req, res) => { const { error: errQ, value: query } = fileParamValidation(req.query) const { error: errB, value: body } = fileBodyValidation(req.body) - if (errQ && errB) return res.status(400).send(errB.details[0].message) + if (errQ && errB) return res.status(400).send(errQ.details[0].message) try { await controller.getFile(req, query._filePath, body.filePath) @@ -53,7 +53,7 @@ driveRouter.delete('/file', async (req, res) => { const { error: errQ, value: query } = fileParamValidation(req.query) const { error: errB, value: body } = fileBodyValidation(req.body) - if (errQ && errB) return res.status(400).send(errB.details[0].message) + if (errQ && errB) return res.status(400).send(errQ.details[0].message) try { const response = await controller.deleteFile(query._filePath, body.filePath) @@ -72,7 +72,7 @@ driveRouter.post( if (errQ && errB) { if (req.file) await deleteFile(req.file.path) - return res.status(400).send(errB.details[0].message) + return res.status(400).send(errQ.details[0].message) } if (!req.file) return res.status(400).send('"file" is not present.') @@ -100,7 +100,7 @@ driveRouter.patch( if (errQ && errB) { if (req.file) await deleteFile(req.file.path) - return res.status(400).send(errB.details[0].message) + return res.status(400).send(errQ.details[0].message) } if (!req.file) return res.status(400).send('"file" is not present.') From a45b42107eba97e4caeedb89d304551b85807fae Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Thu, 17 Mar 2022 07:22:53 +0500 Subject: [PATCH 3/3] chore: fixed specs --- api/src/routes/api/spec/drive.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/routes/api/spec/drive.spec.ts b/api/src/routes/api/spec/drive.spec.ts index 7740f92..ef6cdd5 100644 --- a/api/src/routes/api/spec/drive.spec.ts +++ b/api/src/routes/api/spec/drive.spec.ts @@ -260,7 +260,7 @@ describe('files', () => { .attach('file', fileToAttachPath) .expect(400) - expect(res.text).toEqual(`"filePath" is required`) + expect(res.text).toEqual(`"_filePath" is required`) expect(res.body).toEqual({}) }) @@ -269,9 +269,9 @@ describe('files', () => { const pathToUpload = '/my/path/code.oth' const res = await request(app) - .post('/SASjsApi/drive/file') + .post(`/SASjsApi/drive/file?_filePath=${pathToUpload}`) .auth(accessToken, { type: 'bearer' }) - .field('filePath', pathToUpload) + // .field('filePath', pathToUpload) .attach('file', fileToAttachPath) .expect(400) @@ -420,7 +420,7 @@ describe('files', () => { .attach('file', fileToAttachPath) .expect(400) - expect(res.text).toEqual(`"filePath" is required`) + expect(res.text).toEqual(`"_filePath" is required`) expect(res.body).toEqual({}) }) @@ -429,9 +429,9 @@ describe('files', () => { const pathToUpload = '/my/path/code.oth' const res = await request(app) - .patch('/SASjsApi/drive/file') + .patch(`/SASjsApi/drive/file?_filePath=${pathToUpload}`) .auth(accessToken, { type: 'bearer' }) - .field('filePath', pathToUpload) + // .field('filePath', pathToUpload) .attach('file', fileToAttachPath) .expect(400)