mirror of
https://github.com/sasjs/server.git
synced 2026-01-10 07:50:05 +00:00
fix: prettier
This commit is contained in:
@@ -41,7 +41,7 @@ export class ExecutionController {
|
|||||||
|
|
||||||
let webout = path.join(session.path, 'webout.txt')
|
let webout = path.join(session.path, 'webout.txt')
|
||||||
await createFile(webout, '')
|
await createFile(webout, '')
|
||||||
|
|
||||||
program = `
|
program = `
|
||||||
%let sasjsprocessmode=Stored Program;
|
%let sasjsprocessmode=Stored Program;
|
||||||
filename _webout "${webout}";
|
filename _webout "${webout}";
|
||||||
@@ -93,7 +93,7 @@ ${program}`
|
|||||||
(key: string) => key.toLowerCase() === '_debug'
|
(key: string) => key.toLowerCase() === '_debug'
|
||||||
)
|
)
|
||||||
|
|
||||||
if (debug && vars[debug] >= 131 || stderr) {
|
if ((debug && vars[debug] >= 131) || stderr) {
|
||||||
webout = `<html><body>
|
webout = `<html><body>
|
||||||
${webout}
|
${webout}
|
||||||
<div style="text-align:left">
|
<div style="text-align:left">
|
||||||
@@ -102,7 +102,7 @@ ${webout}
|
|||||||
</div>
|
</div>
|
||||||
</body></html>`
|
</body></html>`
|
||||||
}
|
}
|
||||||
|
|
||||||
session.inUse = false
|
session.inUse = false
|
||||||
|
|
||||||
sessionController.deleteSession(session)
|
sessionController.deleteSession(session)
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { createFileTree, getSessionController, getTreeExample } from '../controllers'
|
import {
|
||||||
|
createFileTree,
|
||||||
|
getSessionController,
|
||||||
|
getTreeExample
|
||||||
|
} from '../controllers'
|
||||||
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
|
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getTmpFilesFolderPath, getTmpFolderPath, makeFilesNamesMap } from '../utils'
|
import {
|
||||||
|
getTmpFilesFolderPath,
|
||||||
|
getTmpFolderPath,
|
||||||
|
makeFilesNamesMap
|
||||||
|
} from '../utils'
|
||||||
import { ExecutionController } from '../controllers'
|
import { ExecutionController } from '../controllers'
|
||||||
import { uuidv4 } from '@sasjs/utils'
|
import { uuidv4 } from '@sasjs/utils'
|
||||||
|
|
||||||
@@ -30,7 +38,7 @@ const preuploadMiddleware = async (req: any, res: any, next: any) => {
|
|||||||
const sessionController = getSessionController()
|
const sessionController = getSessionController()
|
||||||
session = await sessionController.getSession()
|
session = await sessionController.getSession()
|
||||||
session.inUse = true
|
session.inUse = true
|
||||||
|
|
||||||
req.sasSession = session
|
req.sasSession = session
|
||||||
|
|
||||||
next()
|
next()
|
||||||
@@ -78,7 +86,7 @@ router.get('/SASjsExecutor/do', async (req, res) => {
|
|||||||
let sasCodePath = path
|
let sasCodePath = path
|
||||||
.join(getTmpFilesFolderPath(), req.query._program)
|
.join(getTmpFilesFolderPath(), req.query._program)
|
||||||
.replace(new RegExp('/', 'g'), path.sep)
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
|
||||||
// If no extension provided, add .sas extension
|
// If no extension provided, add .sas extension
|
||||||
sasCodePath += !sasCodePath.includes('.') ? '.sas' : ''
|
sasCodePath += !sasCodePath.includes('.') ? '.sas' : ''
|
||||||
|
|
||||||
@@ -102,39 +110,50 @@ router.get('/SASjsExecutor/do', async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/SASjsExecutor/do', preuploadMiddleware, upload.any(), async (req: any, res: any) => {
|
router.post(
|
||||||
if (isRequestQuery(req.query)) {
|
'/SASjsExecutor/do',
|
||||||
let sasCodePath = path
|
preuploadMiddleware,
|
||||||
.join(getTmpFilesFolderPath(), req.query._program)
|
upload.any(),
|
||||||
.replace(new RegExp('/', 'g'), path.sep)
|
async (req: any, res: any) => {
|
||||||
|
if (isRequestQuery(req.query)) {
|
||||||
|
let sasCodePath = path
|
||||||
|
.join(getTmpFilesFolderPath(), req.query._program)
|
||||||
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
|
||||||
// If no extension provided, add .sas extension
|
// If no extension provided, add .sas extension
|
||||||
sasCodePath += !sasCodePath.includes('.') ? '.sas' : ''
|
sasCodePath += !sasCodePath.includes('.') ? '.sas' : ''
|
||||||
|
|
||||||
let filesNamesMap = null
|
let filesNamesMap = null
|
||||||
|
|
||||||
if (req.files && req.files.length > 0) {
|
if (req.files && req.files.length > 0) {
|
||||||
filesNamesMap = makeFilesNamesMap(req.files)
|
filesNamesMap = makeFilesNamesMap(req.files)
|
||||||
}
|
}
|
||||||
|
|
||||||
await new ExecutionController()
|
await new ExecutionController()
|
||||||
.execute(sasCodePath, undefined, req.sasSession, { ...req.query }, { filesNamesMap: filesNamesMap })
|
.execute(
|
||||||
.then((result: {}) => {
|
sasCodePath,
|
||||||
res.status(200).send(result)
|
undefined,
|
||||||
})
|
req.sasSession,
|
||||||
.catch((err: {} | string) => {
|
{ ...req.query },
|
||||||
res.status(400).send({
|
{ filesNamesMap: filesNamesMap }
|
||||||
status: 'failure',
|
)
|
||||||
message: 'Job execution failed.',
|
.then((result: {}) => {
|
||||||
...(typeof err === 'object' ? err : { details: err })
|
res.status(200).send(result)
|
||||||
})
|
})
|
||||||
|
.catch((err: {} | string) => {
|
||||||
|
res.status(400).send({
|
||||||
|
status: 'failure',
|
||||||
|
message: 'Job execution failed.',
|
||||||
|
...(typeof err === 'object' ? err : { details: err })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
res.status(400).send({
|
||||||
|
status: 'failure',
|
||||||
|
message: `Please provide the location of SAS code`
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
res.status(400).send({
|
|
||||||
status: 'failure',
|
|
||||||
message: `Please provide the location of SAS code`
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
export * from './file'
|
export * from './file'
|
||||||
export * from './sleep'
|
export * from './sleep'
|
||||||
export * from './upload'
|
export * from './upload'
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ import { getTmpSessionsFolderPath } from '.'
|
|||||||
* @returns object
|
* @returns object
|
||||||
*/
|
*/
|
||||||
export const makeFilesNamesMap = (files: any) => {
|
export const makeFilesNamesMap = (files: any) => {
|
||||||
if (!files) return null
|
if (!files) return null
|
||||||
|
|
||||||
const filesNamesMap: any = {}
|
const filesNamesMap: any = {}
|
||||||
|
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
filesNamesMap[file.filename] = file.fieldname
|
filesNamesMap[file.filename] = file.fieldname
|
||||||
}
|
}
|
||||||
|
|
||||||
return filesNamesMap
|
return filesNamesMap
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +25,7 @@ export const makeFilesNamesMap = (files: any) => {
|
|||||||
* @param sasUploadFolder name of the folder that is created for the purpose of files in concurrent request
|
* @param sasUploadFolder name of the folder that is created for the purpose of files in concurrent request
|
||||||
* @returns generated sas code
|
* @returns generated sas code
|
||||||
*/
|
*/
|
||||||
export const generateFileUploadSasCode = (
|
export const generateFileUploadSasCode = (
|
||||||
filesNamesMap: any,
|
filesNamesMap: any,
|
||||||
sasSessionFolder: string
|
sasSessionFolder: string
|
||||||
): string => {
|
): string => {
|
||||||
@@ -83,4 +83,4 @@ export const makeFilesNamesMap = (files: any) => {
|
|||||||
uploadSasCode += `\n`
|
uploadSasCode += `\n`
|
||||||
|
|
||||||
return uploadSasCode
|
return uploadSasCode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user