diff --git a/api/src/routes/api/stp.ts b/api/src/routes/api/stp.ts index 3c8e597..18404c4 100644 --- a/api/src/routes/api/stp.ts +++ b/api/src/routes/api/stp.ts @@ -8,6 +8,33 @@ const stpRouter = express.Router() const fileUploadController = new FileUploadController() +stpRouter.get('/execute', async (req, res) => { + if (isExecutionQuery(req.query)) { + let sasCodePath = + path + .join(getTmpFilesFolderPath(), req.query._program) + .replace(new RegExp('/', 'g'), path.sep) + '.sas' + + await new ExecutionController() + .execute(sasCodePath, undefined, undefined, { ...req.query }) + .then((result: {}) => { + res.status(200).send(result) + }) + .catch((err: {} | string) => { + res.status(400).send({ + status: 'failure', + message: 'Job execution failed.', + ...(typeof err === 'object' ? err : { details: err }) + }) + }) + } else { + res.status(400).send({ + status: 'failure', + message: `Please provide the location of SAS code` + }) + } +}) + stpRouter.post( '/execute', fileUploadController.preuploadMiddleware, diff --git a/api/src/routes/web/web.ts b/api/src/routes/web/web.ts index 4671dab..87a87b2 100644 --- a/api/src/routes/web/web.ts +++ b/api/src/routes/web/web.ts @@ -10,31 +10,4 @@ webRouter.get('/', async (_, res) => { res.sendFile(path.join(getWebBuildFolderPath(), 'index.html')) }) -webRouter.get('/SASjsExecutor/do', async (req, res) => { - if (isExecutionQuery(req.query)) { - let sasCodePath = - path - .join(getTmpFilesFolderPath(), req.query._program) - .replace(new RegExp('/', 'g'), path.sep) + '.sas' - - await new ExecutionController() - .execute(sasCodePath, undefined, undefined, { ...req.query }) - .then((result: {}) => { - res.status(200).send(result) - }) - .catch((err: {} | string) => { - res.status(400).send({ - status: 'failure', - message: 'Job execution failed.', - ...(typeof err === 'object' ? err : { details: err }) - }) - }) - } else { - res.status(400).send({ - status: 'failure', - message: `Please provide the location of SAS code` - }) - } -}) - export default webRouter diff --git a/web/src/containers/Drive/main.tsx b/web/src/containers/Drive/main.tsx index 8cfb279..d33e2cc 100644 --- a/web/src/containers/Drive/main.tsx +++ b/web/src/containers/Drive/main.tsx @@ -64,7 +64,7 @@ const Main = (props: any) => { setEditMode(false) } else { window.open( - `${baseUrl}/SASjsExecutor/do?_program=${props.selectedFilePath.replace( + `${baseUrl}/SASjsApi/stp/execute?_program=${props.selectedFilePath.replace( /.sas$/, '' )}`