mirror of
https://github.com/sasjs/server.git
synced 2026-01-06 06:10:04 +00:00
feat(certs): ENV variables updated and set CA Root for HTTPS server
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import {
|
||||
SASSessionController,
|
||||
JSSessionController,
|
||||
getSASSessionController,
|
||||
getJSSessionController,
|
||||
processProgram
|
||||
@@ -76,10 +78,19 @@ export class ExecutionController {
|
||||
session: sessionByFileUpload,
|
||||
runTime
|
||||
}: ExecuteProgramParams): Promise<ExecuteReturnRaw | ExecuteReturnJson> {
|
||||
const sessionController =
|
||||
runTime === RunTimeType.SAS
|
||||
? getSASSessionController()
|
||||
: getJSSessionController()
|
||||
let sessionController: SASSessionController | JSSessionController
|
||||
|
||||
switch (runTime) {
|
||||
case RunTimeType.SAS:
|
||||
sessionController = getSASSessionController()
|
||||
break
|
||||
case RunTimeType.JS:
|
||||
sessionController = getJSSessionController()
|
||||
break
|
||||
|
||||
default:
|
||||
throw new Error('No Runtime is configured1')
|
||||
}
|
||||
|
||||
const session =
|
||||
sessionByFileUpload ?? (await sessionController.getSession())
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { Request, RequestHandler } from 'express'
|
||||
import multer from 'multer'
|
||||
import { uuidv4 } from '@sasjs/utils'
|
||||
import { getSASSessionController, getJSSessionController } from '.'
|
||||
import {
|
||||
SASSessionController,
|
||||
JSSessionController,
|
||||
getSASSessionController,
|
||||
getJSSessionController
|
||||
} from '.'
|
||||
import {
|
||||
executeProgramRawValidation,
|
||||
getRunTimeAndFilePath,
|
||||
@@ -44,10 +49,19 @@ export class FileUploadController {
|
||||
})
|
||||
}
|
||||
|
||||
const sessionController =
|
||||
runTime === RunTimeType.SAS
|
||||
? getSASSessionController()
|
||||
: getJSSessionController()
|
||||
let sessionController: SASSessionController | JSSessionController
|
||||
|
||||
switch (runTime) {
|
||||
case RunTimeType.SAS:
|
||||
sessionController = getSASSessionController()
|
||||
break
|
||||
case RunTimeType.JS:
|
||||
sessionController = getJSSessionController()
|
||||
break
|
||||
|
||||
default:
|
||||
return res.status(400).send('No Runtime is configured1')
|
||||
}
|
||||
|
||||
const session = await sessionController.getSession()
|
||||
// marking consumed true, so that it's not available
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
createFile,
|
||||
fileExists,
|
||||
generateTimestamp,
|
||||
readFile
|
||||
readFile,
|
||||
isWindows
|
||||
} from '@sasjs/utils'
|
||||
|
||||
const execFilePromise = promisify(execFile)
|
||||
@@ -88,7 +89,7 @@ ${autoExecContent}`
|
||||
|
||||
// Additional windows specific options to avoid the desktop popups.
|
||||
|
||||
execFilePromise(process.sasLoc, [
|
||||
execFilePromise(process.sasLoc!, [
|
||||
'-SYSIN',
|
||||
codePath,
|
||||
'-LOG',
|
||||
@@ -99,9 +100,9 @@ ${autoExecContent}`
|
||||
session.path,
|
||||
'-AUTOEXEC',
|
||||
autoExecPath,
|
||||
process.platform === 'win32' ? '-nosplash' : '',
|
||||
process.platform === 'win32' ? '-icon' : '',
|
||||
process.platform === 'win32' ? '-nologo' : ''
|
||||
isWindows() ? '-nosplash' : '',
|
||||
isWindows() ? '-icon' : '',
|
||||
isWindows() ? '-nologo' : ''
|
||||
])
|
||||
.then(() => {
|
||||
session.completed = true
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isWindows } from '@sasjs/utils'
|
||||
import { PreProgramVars, Session } from '../../types'
|
||||
import { generateFileUploadJSCode } from '../../utils'
|
||||
import { ExecutionVars } from './'
|
||||
@@ -20,9 +21,7 @@ export const createJSProgram = async (
|
||||
const preProgramVarStatments = `
|
||||
let _webout = '';
|
||||
const weboutPath = '${
|
||||
process.platform === 'win32'
|
||||
? weboutPath.replace(/\\/g, '\\\\')
|
||||
: weboutPath
|
||||
isWindows() ? weboutPath.replace(/\\/g, '\\\\') : weboutPath
|
||||
}';
|
||||
const _sasjs_tokenfile = '${tokenFile}';
|
||||
const _sasjs_username = '${preProgramVariables?.username}';
|
||||
|
||||
@@ -40,7 +40,7 @@ export const processProgram = async (
|
||||
// waiting for the open event so that we can have underlying file descriptor
|
||||
await once(writeStream, 'open')
|
||||
|
||||
execFileSync(process.nodeLoc, [codePath], {
|
||||
execFileSync(process.nodeLoc!, [codePath], {
|
||||
stdio: ['ignore', writeStream, writeStream]
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user