mirror of
https://github.com/sasjs/server.git
synced 2025-12-08 02:42:44 +00:00
fix(execute): added atribute indicating stp api
This commit is contained in:
@@ -158,7 +158,7 @@ CORS=
|
||||
WHITELIST=
|
||||
|
||||
# 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
|
||||
# Docs: https://helmetjs.github.io/#reference (`crossOriginEmbedderPolicy`)
|
||||
HELMET_COEP=
|
||||
|
||||
@@ -29,6 +29,7 @@ interface ExecuteFileParams {
|
||||
session?: Session
|
||||
runTime: RunTimeType
|
||||
forceStringResult?: boolean
|
||||
isStp?: boolean
|
||||
}
|
||||
|
||||
interface ExecuteProgramParams extends Omit<ExecuteFileParams, 'programPath'> {
|
||||
@@ -44,7 +45,8 @@ export class ExecutionController {
|
||||
returnJson,
|
||||
session,
|
||||
runTime,
|
||||
forceStringResult
|
||||
forceStringResult,
|
||||
isStp
|
||||
}: ExecuteFileParams) {
|
||||
const program = await readFile(programPath)
|
||||
|
||||
@@ -56,7 +58,8 @@ export class ExecutionController {
|
||||
returnJson,
|
||||
session,
|
||||
runTime,
|
||||
forceStringResult
|
||||
forceStringResult,
|
||||
isStp
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,7 +70,8 @@ export class ExecutionController {
|
||||
otherArgs,
|
||||
session: sessionByFileUpload,
|
||||
runTime,
|
||||
forceStringResult
|
||||
forceStringResult,
|
||||
isStp
|
||||
}: ExecuteProgramParams): Promise<ExecuteReturnRaw> {
|
||||
const sessionController = getSessionController(runTime)
|
||||
|
||||
@@ -77,9 +81,7 @@ export class ExecutionController {
|
||||
session.consumed = true
|
||||
|
||||
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 weboutPath = path.join(session.path, 'webout.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 printOutput = (await fileExists(printOutputPath))
|
||||
? await readFile(printOutputPath)
|
||||
: ''
|
||||
const headersContent = (await fileExists(headersPath))
|
||||
? await readFile(headersPath)
|
||||
: ''
|
||||
@@ -134,9 +133,16 @@ export class ExecutionController {
|
||||
resultParts.push(process.logsUUID)
|
||||
resultParts.push(log)
|
||||
|
||||
if (printOutput) {
|
||||
resultParts.push(process.logsUUID)
|
||||
resultParts.push(printOutput)
|
||||
if (!isStp) {
|
||||
const printOutputPath = path.join(session.path, 'output.lst')
|
||||
const printOutput = (await fileExists(printOutputPath))
|
||||
? await readFile(printOutputPath)
|
||||
: ''
|
||||
|
||||
if (printOutput) {
|
||||
resultParts.push(process.logsUUID)
|
||||
resultParts.push(printOutput)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,8 +3,6 @@ import { Request, Security, Route, Tags, Post, Body, Get, Query } from 'tsoa'
|
||||
import { ExecutionController, ExecutionVars } from './internal'
|
||||
import {
|
||||
getPreProgramVariables,
|
||||
HTTPHeaders,
|
||||
LogLine,
|
||||
makeFilesNamesMap,
|
||||
getRunTimeAndFilePath
|
||||
} from '../utils'
|
||||
@@ -39,7 +37,8 @@ export class STPController {
|
||||
@Query() _program: string
|
||||
): Promise<string | Buffer> {
|
||||
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
|
||||
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,
|
||||
_program: string,
|
||||
vars: ExecutionVars,
|
||||
otherArgs?: any
|
||||
otherArgs?: any,
|
||||
isStp?: boolean
|
||||
): Promise<string | Buffer> => {
|
||||
try {
|
||||
const { codePath, runTime } = await getRunTimeAndFilePath(_program)
|
||||
@@ -87,7 +87,8 @@ const execute = async (
|
||||
preProgramVariables: getPreProgramVariables(req),
|
||||
vars,
|
||||
otherArgs,
|
||||
session: req.sasjsSession
|
||||
session: req.sasjsSession,
|
||||
isStp
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user