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