mirror of
https://github.com/sasjs/server.git
synced 2026-01-03 21:10:05 +00:00
chore: modify the implementation files and executor api
This commit is contained in:
@@ -22,7 +22,7 @@ const Main = (props: any) => {
|
|||||||
if (props.selectedFilePath !== '') {
|
if (props.selectedFilePath !== '') {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
axios
|
axios
|
||||||
.get(`${baseUrl}/SASjsApi/files?filepath=${props.selectedFilePath}`)
|
.get(`${baseUrl}/SASjsApi/files?filePath=${props.selectedFilePath}`)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
setFileContent(res.data.fileContent)
|
setFileContent(res.data.fileContent)
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import {
|
|||||||
sasjsDrive,
|
sasjsDrive,
|
||||||
ExecutionController
|
ExecutionController
|
||||||
} from '../controllers'
|
} from '../controllers'
|
||||||
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
|
import {
|
||||||
|
ExecutionResult,
|
||||||
|
isExecutionQuery,
|
||||||
|
isFileQuery,
|
||||||
|
isFileTree
|
||||||
|
} from '../types'
|
||||||
import { getTmpFilesFolderPath } from '../utils'
|
import { getTmpFilesFolderPath } from '../utils'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
@@ -45,11 +50,17 @@ router.post('/deploy', async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.get('/SASjsApi/files', async (req, res) => {
|
router.get('/SASjsApi/files', async (req, res) => {
|
||||||
if (req.query.filepath) {
|
if (isFileQuery(req.query)) {
|
||||||
const fileContent = await sasjsDrive(req.query.filepath as string, 'read')
|
const filePath = path
|
||||||
|
.join(getTmpFilesFolderPath(), req.query.filePath)
|
||||||
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
const fileContent = await sasjsDrive(filePath as string, 'read')
|
||||||
res.status(200).send({ status: 'success', fileContent: fileContent })
|
res.status(200).send({ status: 'success', fileContent: fileContent })
|
||||||
} else {
|
} else {
|
||||||
throw 'Invalid Request: File path is not provided.'
|
res.status(400).send({
|
||||||
|
status: 'failure',
|
||||||
|
message: 'please provide valid file path'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -64,7 +75,7 @@ router.get('/SASjsApi/executor', async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.get('/SASjsExecutor/do', async (req, res) => {
|
router.get('/SASjsExecutor/do', async (req, res) => {
|
||||||
if (isRequestQuery(req.query)) {
|
if (isExecutionQuery(req.query)) {
|
||||||
const sasCodePath = path
|
const sasCodePath = path
|
||||||
.join(getTmpFilesFolderPath(), req.query._program)
|
.join(getTmpFilesFolderPath(), req.query._program)
|
||||||
.replace(new RegExp('/', 'g'), path.sep)
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
|||||||
@@ -6,5 +6,12 @@ export interface ExecutionQuery {
|
|||||||
_debug?: boolean
|
_debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isRequestQuery = (arg: any): arg is ExecutionQuery =>
|
export interface FileQuery {
|
||||||
|
filePath: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isExecutionQuery = (arg: any): arg is ExecutionQuery =>
|
||||||
arg && !Array.isArray(arg) && typeof arg._program === 'string'
|
arg && !Array.isArray(arg) && typeof arg._program === 'string'
|
||||||
|
|
||||||
|
export const isFileQuery = (arg: any): arg is FileQuery =>
|
||||||
|
arg && !Array.isArray(arg) && typeof arg.filePath === 'string'
|
||||||
|
|||||||
Reference in New Issue
Block a user