Currently SASjs Server only supports a SAS runtime for backend services.
This ticket is to enable support for a JS runtime also (and in the future we may also support Python and R).
Why do this?
The number one reason right now is to enable mocked services. By providing a servicename.js alongside a servicename.sas in a solution or application, we can perform integration testing in a non-SAS environment such as a GIT pipeline or on a developer laptop.
From a customer perspective there is also the benefit that a single application may derive inputs from services written in multiple languages. So Python, R, SAS and JS developers can work together on project on the same platform.
How will it be achieved - User Perspective.
Currently, SAS programs are called by reference to a URL parameter (_program) that contains the full path / filename but NOT the extension, eg ?_program=/some/app/services/common/appinit
The proposal is to add a new .env variable (SASJS_RUNTIMES) that will dictate which runtimes are available, and in which order. For instance, if SASJS_RUNTIMES=[SAS,JS] then the executor will first look for appinit.sas and if not found, will run appinit.js.
The developer therefore just needs to add servicename.js files alongside (in the same folder as) their SAS services, to provide the necessary (mocked) response.
How it will be achieved - Technical Perspective
If a .js file is picked up, then - similar to the .sas file - it will be placed in a session folder (code.js) with any URL and session variables inserted, eg:
The appinit.js file will contain any logic, update the sasjs_stpsrv_header_loc and return the output to the _webout file.
The NodeJS server will generate the LOG file and package the _webout into the final API response.
Other points
If a program is called with the suffix (eg _program=/some/app/service.js) then it will always run in the runtime of the suffix. Otherwise, where there are multiple files (eg appinit.js, appinit.py) in the same folder, the file chosen will be as per the SASJS_RUNTIMES array.
Currently sasjs compile doesn't support other languages. The workaround is to add the JS files to the sasjsbuild folder after compile and before build.
Nice to haves
Being able to run JS programs from Studio or Drive
Capturing console output and writing that to the LOG
Currently SASjs Server only supports a SAS runtime for backend services.
This ticket is to enable support for a JS runtime also (and in the future we may also support Python and R).
Why do this?
The number one reason right now is to enable mocked services. By providing a
servicename.js
alongside aservicename.sas
in a solution or application, we can perform integration testing in a non-SAS environment such as a GIT pipeline or on a developer laptop.From a customer perspective there is also the benefit that a single application may derive inputs from services written in multiple languages. So Python, R, SAS and JS developers can work together on project on the same platform.
How will it be achieved - User Perspective.
Currently, SAS programs are called by reference to a URL parameter (
_program
) that contains the full path / filename but NOT the extension, eg?_program=/some/app/services/common/appinit
The proposal is to add a new
.env
variable (SASJS_RUNTIMES
) that will dictate which runtimes are available, and in which order. For instance, ifSASJS_RUNTIMES=[SAS,JS]
then the executor will first look forappinit.sas
and if not found, will runappinit.js
.The developer therefore just needs to add
servicename.js
files alongside (in the same folder as) their SAS services, to provide the necessary (mocked) response.How it will be achieved - Technical Perspective
If a
.js
file is picked up, then - similar to the.sas
file - it will be placed in a session folder (code.js
) with any URL and session variables inserted, eg:The
appinit.js
file will contain any logic, update thesasjs_stpsrv_header_loc
and return the output to the_webout
file.The NodeJS server will generate the LOG file and package the
_webout
into the final API response.Other points
_program=/some/app/service.js
) then it will always run in the runtime of the suffix. Otherwise, where there are multiple files (eg appinit.js, appinit.py) in the same folder, the file chosen will be as per theSASJS_RUNTIMES
array.sasjs compile
doesn't support other languages. The workaround is to add the JS files to thesasjsbuild
folder after compile and before build.Nice to haves