mirror of
https://github.com/sasjs/server.git
synced 2026-01-15 09:50:06 +00:00
chore(code): updated route to code/execute
This commit is contained in:
@@ -3,7 +3,7 @@ import { Request, Security, Route, Tags, Post, Body } from 'tsoa'
|
|||||||
import { ExecutionController } from './internal'
|
import { ExecutionController } from './internal'
|
||||||
import { PreProgramVars } from '../types'
|
import { PreProgramVars } from '../types'
|
||||||
|
|
||||||
interface RunSASPayload {
|
interface ExecuteSASCodePayload {
|
||||||
/**
|
/**
|
||||||
* Code of SAS program
|
* Code of SAS program
|
||||||
* @example "* SAS Code HERE;"
|
* @example "* SAS Code HERE;"
|
||||||
@@ -12,23 +12,23 @@ interface RunSASPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Security('bearerAuth')
|
@Security('bearerAuth')
|
||||||
@Route('SASjsApi/run')
|
@Route('SASjsApi/code')
|
||||||
@Tags('RUN')
|
@Tags('CODE')
|
||||||
export class RUNController {
|
export class CodeController {
|
||||||
/**
|
/**
|
||||||
* Trigger a SAS program.
|
* Execute SAS code.
|
||||||
* @summary Run SAS Program, return raw content
|
* @summary Run SAS Code and returns log
|
||||||
*/
|
*/
|
||||||
@Post('/code')
|
@Post('/execute')
|
||||||
public async runSAS(
|
public async executeSASCode(
|
||||||
@Request() request: express.Request,
|
@Request() request: express.Request,
|
||||||
@Body() body: RunSASPayload
|
@Body() body: ExecuteSASCodePayload
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return runSAS(request, body)
|
return executeSASCode(request, body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const runSAS = async (req: any, { code }: RunSASPayload) => {
|
const executeSASCode = async (req: any, { code }: ExecuteSASCodePayload) => {
|
||||||
try {
|
try {
|
||||||
const result = await new ExecutionController().executeProgram(
|
const result = await new ExecutionController().executeProgram(
|
||||||
code,
|
code,
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
export * from './auth'
|
export * from './auth'
|
||||||
export * from './client'
|
export * from './client'
|
||||||
|
export * from './code'
|
||||||
export * from './drive'
|
export * from './drive'
|
||||||
export * from './group'
|
export * from './group'
|
||||||
export * from './run'
|
|
||||||
export * from './session'
|
export * from './session'
|
||||||
export * from './stp'
|
export * from './stp'
|
||||||
export * from './user'
|
export * from './user'
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { runSASValidation } from '../../utils'
|
import { runSASValidation } from '../../utils'
|
||||||
import { RUNController } from '../../controllers/'
|
import { CodeController } from '../../controllers/'
|
||||||
|
|
||||||
const runRouter = express.Router()
|
const runRouter = express.Router()
|
||||||
|
|
||||||
const controller = new RUNController()
|
const controller = new CodeController()
|
||||||
|
|
||||||
runRouter.post('/code', async (req, res) => {
|
runRouter.post('/code', async (req, res) => {
|
||||||
const { error, value: body } = runSASValidation(req.body)
|
const { error, value: body } = runSASValidation(req.body)
|
||||||
if (error) return res.status(400).send(error.details[0].message)
|
if (error) return res.status(400).send(error.details[0].message)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await controller.runSAS(req, body)
|
const response = await controller.executeSASCode(req, body)
|
||||||
res.send(response)
|
res.send(response)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const statusCode = err.code
|
const statusCode = err.code
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
|
|
||||||
import driveRouter from './drive'
|
import driveRouter from './drive'
|
||||||
import stpRouter from './stp'
|
import stpRouter from './stp'
|
||||||
import runRouter from './run'
|
import codeRouter from './code'
|
||||||
import userRouter from './user'
|
import userRouter from './user'
|
||||||
import groupRouter from './group'
|
import groupRouter from './group'
|
||||||
import clientRouter from './client'
|
import clientRouter from './client'
|
||||||
@@ -32,7 +32,7 @@ router.use(
|
|||||||
router.use('/drive', authenticateAccessToken, driveRouter)
|
router.use('/drive', authenticateAccessToken, driveRouter)
|
||||||
router.use('/group', desktopRestrict, groupRouter)
|
router.use('/group', desktopRestrict, groupRouter)
|
||||||
router.use('/stp', authenticateAccessToken, stpRouter)
|
router.use('/stp', authenticateAccessToken, stpRouter)
|
||||||
router.use('/run', authenticateAccessToken, runRouter)
|
router.use('/code', authenticateAccessToken, codeRouter)
|
||||||
router.use('/user', desktopRestrict, userRouter)
|
router.use('/user', desktopRestrict, userRouter)
|
||||||
router.use(
|
router.use(
|
||||||
'/',
|
'/',
|
||||||
|
|||||||
@@ -40,8 +40,8 @@
|
|||||||
"description": "Operations about STP"
|
"description": "Operations about STP"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "RUN",
|
"name": "CODE",
|
||||||
"description": "Execute SAS code"
|
"description": "Operations on SAS code"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"yaml": true,
|
"yaml": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user