mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
fix(execute): added atribute indicating stp api
This commit is contained in:
@@ -158,7 +158,7 @@ CORS=
|
|||||||
WHITELIST=
|
WHITELIST=
|
||||||
|
|
||||||
# HELMET Cross Origin Embedder Policy
|
# HELMET Cross Origin Embedder Policy
|
||||||
# Sets the Cross-Origin-Embedder-Policy header to require-corp when `true`
|
# Sets the Cross-Origin-Embedder-Policy header to require-corp when `true`
|
||||||
# options: [true|false] default: true
|
# options: [true|false] default: true
|
||||||
# Docs: https://helmetjs.github.io/#reference (`crossOriginEmbedderPolicy`)
|
# Docs: https://helmetjs.github.io/#reference (`crossOriginEmbedderPolicy`)
|
||||||
HELMET_COEP=
|
HELMET_COEP=
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ interface ExecuteFileParams {
|
|||||||
session?: Session
|
session?: Session
|
||||||
runTime: RunTimeType
|
runTime: RunTimeType
|
||||||
forceStringResult?: boolean
|
forceStringResult?: boolean
|
||||||
|
isStp?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExecuteProgramParams extends Omit<ExecuteFileParams, 'programPath'> {
|
interface ExecuteProgramParams extends Omit<ExecuteFileParams, 'programPath'> {
|
||||||
@@ -44,7 +45,8 @@ export class ExecutionController {
|
|||||||
returnJson,
|
returnJson,
|
||||||
session,
|
session,
|
||||||
runTime,
|
runTime,
|
||||||
forceStringResult
|
forceStringResult,
|
||||||
|
isStp
|
||||||
}: ExecuteFileParams) {
|
}: ExecuteFileParams) {
|
||||||
const program = await readFile(programPath)
|
const program = await readFile(programPath)
|
||||||
|
|
||||||
@@ -56,7 +58,8 @@ export class ExecutionController {
|
|||||||
returnJson,
|
returnJson,
|
||||||
session,
|
session,
|
||||||
runTime,
|
runTime,
|
||||||
forceStringResult
|
forceStringResult,
|
||||||
|
isStp
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +70,8 @@ export class ExecutionController {
|
|||||||
otherArgs,
|
otherArgs,
|
||||||
session: sessionByFileUpload,
|
session: sessionByFileUpload,
|
||||||
runTime,
|
runTime,
|
||||||
forceStringResult
|
forceStringResult,
|
||||||
|
isStp
|
||||||
}: ExecuteProgramParams): Promise<ExecuteReturnRaw> {
|
}: ExecuteProgramParams): Promise<ExecuteReturnRaw> {
|
||||||
const sessionController = getSessionController(runTime)
|
const sessionController = getSessionController(runTime)
|
||||||
|
|
||||||
@@ -77,9 +81,7 @@ export class ExecutionController {
|
|||||||
session.consumed = true
|
session.consumed = true
|
||||||
|
|
||||||
const logPath = path.join(session.path, 'log.log')
|
const logPath = path.join(session.path, 'log.log')
|
||||||
const printOutputPath = path.join(session.path, 'output.lst')
|
|
||||||
const headersPath = path.join(session.path, 'stpsrv_header.txt')
|
const headersPath = path.join(session.path, 'stpsrv_header.txt')
|
||||||
|
|
||||||
const weboutPath = path.join(session.path, 'webout.txt')
|
const weboutPath = path.join(session.path, 'webout.txt')
|
||||||
const tokenFile = path.join(session.path, 'reqHeaders.txt')
|
const tokenFile = path.join(session.path, 'reqHeaders.txt')
|
||||||
|
|
||||||
@@ -103,9 +105,6 @@ export class ExecutionController {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const log = (await fileExists(logPath)) ? await readFile(logPath) : ''
|
const log = (await fileExists(logPath)) ? await readFile(logPath) : ''
|
||||||
const printOutput = (await fileExists(printOutputPath))
|
|
||||||
? await readFile(printOutputPath)
|
|
||||||
: ''
|
|
||||||
const headersContent = (await fileExists(headersPath))
|
const headersContent = (await fileExists(headersPath))
|
||||||
? await readFile(headersPath)
|
? await readFile(headersPath)
|
||||||
: ''
|
: ''
|
||||||
@@ -134,9 +133,16 @@ export class ExecutionController {
|
|||||||
resultParts.push(process.logsUUID)
|
resultParts.push(process.logsUUID)
|
||||||
resultParts.push(log)
|
resultParts.push(log)
|
||||||
|
|
||||||
if (printOutput) {
|
if (!isStp) {
|
||||||
resultParts.push(process.logsUUID)
|
const printOutputPath = path.join(session.path, 'output.lst')
|
||||||
resultParts.push(printOutput)
|
const printOutput = (await fileExists(printOutputPath))
|
||||||
|
? await readFile(printOutputPath)
|
||||||
|
: ''
|
||||||
|
|
||||||
|
if (printOutput) {
|
||||||
|
resultParts.push(process.logsUUID)
|
||||||
|
resultParts.push(printOutput)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import { Request, Security, Route, Tags, Post, Body, Get, Query } from 'tsoa'
|
|||||||
import { ExecutionController, ExecutionVars } from './internal'
|
import { ExecutionController, ExecutionVars } from './internal'
|
||||||
import {
|
import {
|
||||||
getPreProgramVariables,
|
getPreProgramVariables,
|
||||||
HTTPHeaders,
|
|
||||||
LogLine,
|
|
||||||
makeFilesNamesMap,
|
makeFilesNamesMap,
|
||||||
getRunTimeAndFilePath
|
getRunTimeAndFilePath
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
@@ -39,7 +37,8 @@ export class STPController {
|
|||||||
@Query() _program: string
|
@Query() _program: string
|
||||||
): Promise<string | Buffer> {
|
): Promise<string | Buffer> {
|
||||||
const vars = request.query as ExecutionVars
|
const vars = request.query as ExecutionVars
|
||||||
return execute(request, _program, vars)
|
|
||||||
|
return execute(request, _program, vars, undefined, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +66,7 @@ export class STPController {
|
|||||||
: null
|
: null
|
||||||
const otherArgs = { filesNamesMap: filesNamesMap }
|
const otherArgs = { filesNamesMap: filesNamesMap }
|
||||||
|
|
||||||
return execute(request, program!, vars, otherArgs)
|
return execute(request, program!, vars, otherArgs, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +74,8 @@ const execute = async (
|
|||||||
req: express.Request,
|
req: express.Request,
|
||||||
_program: string,
|
_program: string,
|
||||||
vars: ExecutionVars,
|
vars: ExecutionVars,
|
||||||
otherArgs?: any
|
otherArgs?: any,
|
||||||
|
isStp?: boolean
|
||||||
): Promise<string | Buffer> => {
|
): Promise<string | Buffer> => {
|
||||||
try {
|
try {
|
||||||
const { codePath, runTime } = await getRunTimeAndFilePath(_program)
|
const { codePath, runTime } = await getRunTimeAndFilePath(_program)
|
||||||
@@ -87,7 +87,8 @@ const execute = async (
|
|||||||
preProgramVariables: getPreProgramVariables(req),
|
preProgramVariables: getPreProgramVariables(req),
|
||||||
vars,
|
vars,
|
||||||
otherArgs,
|
otherArgs,
|
||||||
session: req.sasjsSession
|
session: req.sasjsSession,
|
||||||
|
isStp
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user