@sassoftware/viya-serverjs 0.2.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -6
- package/.dockerignore +2 -2
- package/.env +29 -29
- package/.env.proxy +32 -32
- package/.env.server +30 -30
- package/.eslintignore +3 -3
- package/.eslintrc.json +42 -42
- package/Dockerfile +44 -44
- package/README.md +99 -99
- package/cli.js +9 -9
- package/lib/config.js +16 -16
- package/lib/handlers/appCallback.js +23 -24
- package/lib/handlers/codeAuth.js +17 -18
- package/lib/handlers/decodeJwt.js +3 -3
- package/lib/handlers/favicon.js +22 -25
- package/lib/handlers/getApp.js +20 -21
- package/lib/handlers/getApp2.js +22 -25
- package/lib/handlers/getUser.js +14 -17
- package/lib/handlers/index.js +3 -3
- package/lib/handlers/keepAlive.js +28 -31
- package/lib/handlers/keepAlive2.js +9 -12
- package/lib/handlers/logon.js +12 -15
- package/lib/handlers/logout.js +24 -28
- package/lib/handlers/proxyMapUri.js +6 -11
- package/lib/handlers/proxyOnResponse.js +6 -7
- package/lib/handlers/reactDev.js +22 -25
- package/lib/handlers/setCookies.js +52 -53
- package/lib/iService.js +106 -104
- package/lib/index.js +23 -21
- package/lib/parseDocker.js +3 -3
- package/lib/plugins/SASauth.js +30 -32
- package/lib/plugins/appCookie.js +36 -38
- package/lib/plugins/setContext.js +22 -25
- package/lib/plugins/setDefaultRoutes.js +61 -58
- package/lib/plugins/setupAuth.js +35 -38
- package/lib/plugins/setupUserRoutes.js +16 -16
- package/lib/plugins/token.js +9 -10
- package/lib/schemes/SASTokenScheme.js +24 -27
- package/package.json +85 -79
- package/public/data/Cluster_SDOH1.sas +181 -181
- package/public/data/Cluster_SDOH6.sas +179 -179
- package/public/data/NeuralNetwork_High_med.sas +2408 -2408
- package/public/data/NeuralNetwork_high_med1.sas +2408 -2408
- package/public/data/cars.csv +429 -429
- package/public/data/cmdList.txt +15 -15
- package/public/data/iris.csv +151 -151
- package/public/index.html +355 -360
- package/public/indexProxy.html +351 -351
- package/public/simplesubmit.html +233 -0
- package/server.js +362 -362
- package/src/config.js +90 -90
- package/src/handlers/appCallback.js +40 -40
- package/src/handlers/codeAuth.js +31 -31
- package/src/handlers/decodeJwt.js +10 -10
- package/src/handlers/favicon.js +23 -23
- package/src/handlers/getApp.js +52 -52
- package/src/handlers/getApp2.js +25 -25
- package/src/handlers/getUser.js +20 -20
- package/src/handlers/index.js +36 -36
- package/src/handlers/keepAlive.js +53 -53
- package/src/handlers/keepAlive2.js +12 -12
- package/src/handlers/logon.js +23 -23
- package/src/handlers/logout.js +42 -42
- package/src/handlers/proxyMapUri.js +25 -25
- package/src/handlers/proxyOnResponse.js +11 -11
- package/src/handlers/reactDev.js +29 -29
- package/src/handlers/setCookies.js +81 -79
- package/src/iService.js +346 -347
- package/src/index.js +251 -249
- package/src/parseDocker.js +32 -32
- package/src/plugins/SASauth.js +78 -78
- package/src/plugins/appCookie.js +51 -49
- package/src/plugins/setContext.js +33 -33
- package/src/plugins/setDefaultRoutes.js +256 -253
- package/src/plugins/setupAuth.js +49 -49
- package/src/plugins/setupUserRoutes.js +47 -47
- package/src/plugins/token.js +10 -10
- package/src/schemes/SASTokenScheme.js +43 -43
- package/src/visionIndex.html +23 -23
- package/start.sh +14 -14
- package/tls/viyatls.sh +2 -2
package/.babelrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
"@babel/preset-env"
|
|
4
|
-
]
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
"@babel/preset-env"
|
|
4
|
+
]
|
|
5
|
+
|
|
6
|
+
}
|
package/.dockerignore
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
|
|
1
|
+
node_modules
|
|
2
|
+
|
package/.env
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
APPHOST=localhost
|
|
2
|
-
APPENTRY=index.html
|
|
3
|
-
APPLOC=./public
|
|
4
|
-
# VIYA_SERVER=
|
|
5
|
-
# VIYA_SERVER=none
|
|
6
|
-
APPPORT=8080
|
|
7
|
-
APPNAME=viyaapp
|
|
8
|
-
AUTHFLOW=server
|
|
9
|
-
CLIENTID=viyaapp
|
|
10
|
-
CLIENTSECRET=jellico
|
|
11
|
-
REDIRECT=
|
|
12
|
-
# APPDIR=./appDir
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
APPHOST=localhost
|
|
2
|
+
# APPENTRY=index.html
|
|
3
|
+
APPLOC=./public
|
|
4
|
+
# VIYA_SERVER=
|
|
5
|
+
# VIYA_SERVER=none
|
|
6
|
+
APPPORT=8080
|
|
7
|
+
APPNAME=viyaapp
|
|
8
|
+
AUTHFLOW=server
|
|
9
|
+
CLIENTID=viyaapp
|
|
10
|
+
CLIENTSECRET=jellico
|
|
11
|
+
REDIRECT=
|
|
12
|
+
# APPDIR=./appDir
|
|
13
|
+
HTTPS=true
|
|
14
|
+
VIYA_SERVER=https://viya-00m2kebi2b.engage.sas.com
|
|
15
|
+
|
|
16
|
+
// browsers do not accept self-signed certs from localhost
|
|
17
|
+
// so run all apps thru the proxy and call Viya from there
|
|
18
|
+
|
|
19
|
+
APPENV_PROXYSERVER=https://localhost:8080/viyaapp/proxy
|
|
20
|
+
USETOKEN=YES
|
|
21
|
+
SHOWENV=YES
|
|
22
|
+
|
|
23
|
+
APPENV_XYZ=AA
|
|
24
|
+
APPENV_BAD=
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
package/.env.proxy
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
APPHOST=localhost
|
|
2
|
-
# APPENTRY=index.html
|
|
3
|
-
APPENTRY=indexProxy.html
|
|
4
|
-
APPLOC=./public
|
|
5
|
-
VIYA_SERVER=
|
|
6
|
-
APPENV_PROXYSERVER=https://localhost:8080/appBuilder/proxy
|
|
7
|
-
|
|
8
|
-
APPPORT=8080
|
|
9
|
-
APPNAME=appBuilder
|
|
10
|
-
AUTHFLOW=server
|
|
11
|
-
CLIENTID=appbuilder
|
|
12
|
-
CLIENTSECRET=jellico
|
|
13
|
-
REDIRECT=
|
|
14
|
-
|
|
15
|
-
# APPDIR=./appDir
|
|
16
|
-
# HTTPS=true
|
|
17
|
-
USELOGON=YES
|
|
18
|
-
|
|
19
|
-
USETOKEN=YES
|
|
20
|
-
# SHOWENV=YES
|
|
21
|
-
# APPENV=
|
|
22
|
-
APPENV_XYZ=AA
|
|
23
|
-
APPENV_BAD=
|
|
24
|
-
|
|
25
|
-
# APPENV_PUPID=NSHOST=https://sas-logon-app.viya.svc.cluster.local
|
|
26
|
-
|
|
27
|
-
# NAMESPACE=viya
|
|
28
|
-
# TLS_CERT=./certs/tls.crt
|
|
29
|
-
# TLS_KEY=./certs/tls.key
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
APPHOST=localhost
|
|
2
|
+
# APPENTRY=index.html
|
|
3
|
+
APPENTRY=indexProxy.html
|
|
4
|
+
APPLOC=./public
|
|
5
|
+
VIYA_SERVER=
|
|
6
|
+
APPENV_PROXYSERVER=https://localhost:8080/appBuilder/proxy
|
|
7
|
+
|
|
8
|
+
APPPORT=8080
|
|
9
|
+
APPNAME=appBuilder
|
|
10
|
+
AUTHFLOW=server
|
|
11
|
+
CLIENTID=appbuilder
|
|
12
|
+
CLIENTSECRET=jellico
|
|
13
|
+
REDIRECT=
|
|
14
|
+
|
|
15
|
+
# APPDIR=./appDir
|
|
16
|
+
# HTTPS=true
|
|
17
|
+
USELOGON=YES
|
|
18
|
+
|
|
19
|
+
USETOKEN=YES
|
|
20
|
+
# SHOWENV=YES
|
|
21
|
+
# APPENV=
|
|
22
|
+
APPENV_XYZ=AA
|
|
23
|
+
APPENV_BAD=
|
|
24
|
+
|
|
25
|
+
# APPENV_PUPID=NSHOST=https://sas-logon-app.viya.svc.cluster.local
|
|
26
|
+
|
|
27
|
+
# NAMESPACE=viya
|
|
28
|
+
# TLS_CERT=./certs/tls.crt
|
|
29
|
+
# TLS_KEY=./certs/tls.key
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
package/.env.server
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
APPHOST=localhost
|
|
2
|
-
APPENTRY=index.html
|
|
3
|
-
APPLOC=./public
|
|
4
|
-
VIYA_SERVER=
|
|
5
|
-
APPENV_PROXYSERVER=https://localhost:8080/appBuilder/proxy
|
|
6
|
-
APPPORT=8080
|
|
7
|
-
APPNAME=appBuilder
|
|
8
|
-
AUTHFLOW=server
|
|
9
|
-
CLIENTID=appbuilder
|
|
10
|
-
CLIENTSECRET=jellico
|
|
11
|
-
REDIRECT=/new
|
|
12
|
-
# APPDIR=./appDir
|
|
13
|
-
# HTTPS=true
|
|
14
|
-
USELOGON=YES
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
USETOKEN=YES
|
|
18
|
-
# SHOWENV=YES
|
|
19
|
-
# APPENV=
|
|
20
|
-
APPENV_XYZ=AA
|
|
21
|
-
APPENV_BAD=
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# NAMESPACE=viya
|
|
26
|
-
# TLS_CERT=./certs/tls.crt
|
|
27
|
-
# TLS_KEY=./certs/tls.key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
APPHOST=localhost
|
|
2
|
+
APPENTRY=index.html
|
|
3
|
+
APPLOC=./public
|
|
4
|
+
VIYA_SERVER=
|
|
5
|
+
APPENV_PROXYSERVER=https://localhost:8080/appBuilder/proxy
|
|
6
|
+
APPPORT=8080
|
|
7
|
+
APPNAME=appBuilder
|
|
8
|
+
AUTHFLOW=server
|
|
9
|
+
CLIENTID=appbuilder
|
|
10
|
+
CLIENTSECRET=jellico
|
|
11
|
+
REDIRECT=/new
|
|
12
|
+
# APPDIR=./appDir
|
|
13
|
+
# HTTPS=true
|
|
14
|
+
USELOGON=YES
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
USETOKEN=YES
|
|
18
|
+
# SHOWENV=YES
|
|
19
|
+
# APPENV=
|
|
20
|
+
APPENV_XYZ=AA
|
|
21
|
+
APPENV_BAD=
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# NAMESPACE=viya
|
|
26
|
+
# TLS_CERT=./certs/tls.crt
|
|
27
|
+
# TLS_KEY=./certs/tls.key
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
package/.eslintignore
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
public
|
|
3
|
-
env
|
|
1
|
+
node_modules
|
|
2
|
+
public
|
|
3
|
+
env
|
|
4
4
|
lib
|
package/.eslintrc.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"env": {
|
|
4
|
-
"browser": true,
|
|
5
|
-
"node": true,
|
|
6
|
-
"es6": true
|
|
7
|
-
},
|
|
8
|
-
"parser": "@babel/eslint-parser",
|
|
9
|
-
"extends": ["eslint:recommended", "prettier"],
|
|
10
|
-
"parserOptions": {
|
|
11
|
-
"requireConfigFile": false,
|
|
12
|
-
"babelOptions": {"configFile": "./.babelrc"},
|
|
13
|
-
"ecmaVersion": 6,
|
|
14
|
-
"sourceType": "module",
|
|
15
|
-
"ecmaFeatures": {
|
|
16
|
-
"jsx": true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"rules": {
|
|
20
|
-
"key-spacing": [
|
|
21
|
-
2,
|
|
22
|
-
{
|
|
23
|
-
"align": "colon"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"jsx-quotes": [2, "prefer-double"],
|
|
27
|
-
"no-console": 0,
|
|
28
|
-
"no-unused-vars": [
|
|
29
|
-
1,
|
|
30
|
-
{
|
|
31
|
-
"args": "none"
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"no-debugger": 0,
|
|
35
|
-
"react/prop-types": 0,
|
|
36
|
-
"array-bracket-spacing": [2, "never"],
|
|
37
|
-
"space-in-parens": [2, "never"],
|
|
38
|
-
"space-before-function-paren": [2, "always"],
|
|
39
|
-
"semi": [2, "always"],
|
|
40
|
-
"no-prototype-builtins": 0
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"browser": true,
|
|
5
|
+
"node": true,
|
|
6
|
+
"es6": true
|
|
7
|
+
},
|
|
8
|
+
"parser": "@babel/eslint-parser",
|
|
9
|
+
"extends": ["eslint:recommended", "prettier"],
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"requireConfigFile": false,
|
|
12
|
+
"babelOptions": {"configFile": "./.babelrc"},
|
|
13
|
+
"ecmaVersion": 6,
|
|
14
|
+
"sourceType": "module",
|
|
15
|
+
"ecmaFeatures": {
|
|
16
|
+
"jsx": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"rules": {
|
|
20
|
+
"key-spacing": [
|
|
21
|
+
2,
|
|
22
|
+
{
|
|
23
|
+
"align": "colon"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"jsx-quotes": [2, "prefer-double"],
|
|
27
|
+
"no-console": 0,
|
|
28
|
+
"no-unused-vars": [
|
|
29
|
+
1,
|
|
30
|
+
{
|
|
31
|
+
"args": "none"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"no-debugger": 0,
|
|
35
|
+
"react/prop-types": 0,
|
|
36
|
+
"array-bracket-spacing": [2, "never"],
|
|
37
|
+
"space-in-parens": [2, "never"],
|
|
38
|
+
"space-before-function-paren": [2, "always"],
|
|
39
|
+
"semi": [2, "always"],
|
|
40
|
+
"no-prototype-builtins": 0
|
|
41
|
+
}
|
|
42
|
+
}
|
package/Dockerfile
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
FROM node:12.16.1-alpine
|
|
2
|
-
LABEL maintainer="deva.kumar@sas.com"
|
|
3
|
-
WORKDIR /usr/src/app
|
|
4
|
-
COPY . .
|
|
5
|
-
# COPY package*.json ./
|
|
6
|
-
RUN npm install
|
|
7
|
-
# RUN npm run build
|
|
8
|
-
|
|
9
|
-
# will auto change to localhost in non-docker environments
|
|
10
|
-
ENV APPHOST=0.0.0.0
|
|
11
|
-
ENV PORT=8080
|
|
12
|
-
EXPOSE
|
|
13
|
-
ENV HTTPS=true
|
|
14
|
-
# ENV APPSERVERLEVEL=v2
|
|
15
|
-
#######################################################################
|
|
16
|
-
# You can override these(but in container leave APPHOST as shown below)
|
|
17
|
-
########################################################################
|
|
18
|
-
|
|
19
|
-
# set this the same as EXPOSE here and override in env or as -p option in dockerrun
|
|
20
|
-
# ENV APPPORT=8080
|
|
21
|
-
|
|
22
|
-
ENV APPNAME=
|
|
23
|
-
# ENV AUTHFLOW=
|
|
24
|
-
ENV CLIENTID=
|
|
25
|
-
ENV CLIENTSECRET=jellico
|
|
26
|
-
ENV HAPIDEBUG=NO
|
|
27
|
-
# ENV LOGLEVEL=info
|
|
28
|
-
# ENV USETOKEN=YES
|
|
29
|
-
|
|
30
|
-
#sample setup for creating a temporary cert and key
|
|
31
|
-
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
32
|
-
|
|
33
|
-
# You can specify your own cet and key
|
|
34
|
-
# ENV TLS_CRT=./tls/tls.crt
|
|
35
|
-
# ENV TLS_KEY=./tls/tls.key
|
|
36
|
-
|
|
37
|
-
# Samesite specification
|
|
38
|
-
ENV SAMESITE=None,secure
|
|
39
|
-
|
|
40
|
-
# If your Viya instance still has a unsigned certificate set this value prior to invoking the server
|
|
41
|
-
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
42
|
-
|
|
43
|
-
#####################################################################
|
|
44
|
-
CMD ["npm", "run", "indocker"]
|
|
1
|
+
FROM node:12.16.1-alpine
|
|
2
|
+
LABEL maintainer="deva.kumar@sas.com"
|
|
3
|
+
WORKDIR /usr/src/app
|
|
4
|
+
COPY . .
|
|
5
|
+
# COPY package*.json ./
|
|
6
|
+
RUN npm install
|
|
7
|
+
# RUN npm run build
|
|
8
|
+
|
|
9
|
+
# will auto change to localhost in non-docker environments
|
|
10
|
+
ENV APPHOST=0.0.0.0
|
|
11
|
+
ENV PORT=8080
|
|
12
|
+
EXPOSE 8080
|
|
13
|
+
ENV HTTPS=true
|
|
14
|
+
# ENV APPSERVERLEVEL=v2
|
|
15
|
+
#######################################################################
|
|
16
|
+
# You can override these(but in container leave APPHOST as shown below)
|
|
17
|
+
########################################################################
|
|
18
|
+
|
|
19
|
+
# set this the same as EXPOSE here and override in env or as -p option in dockerrun
|
|
20
|
+
# ENV APPPORT=8080
|
|
21
|
+
|
|
22
|
+
ENV APPNAME=viyaapp
|
|
23
|
+
# ENV AUTHFLOW=
|
|
24
|
+
ENV CLIENTID=viyaapp
|
|
25
|
+
ENV CLIENTSECRET=jellico
|
|
26
|
+
# ENV HAPIDEBUG=NO
|
|
27
|
+
# ENV LOGLEVEL=info
|
|
28
|
+
# ENV USETOKEN=YES
|
|
29
|
+
|
|
30
|
+
#sample setup for creating a temporary cert and key
|
|
31
|
+
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
32
|
+
|
|
33
|
+
# You can specify your own cet and key
|
|
34
|
+
# ENV TLS_CRT=./tls/tls.crt
|
|
35
|
+
# ENV TLS_KEY=./tls/tls.key
|
|
36
|
+
|
|
37
|
+
# Samesite specification
|
|
38
|
+
ENV SAMESITE=None,secure
|
|
39
|
+
|
|
40
|
+
# If your Viya instance still has a unsigned certificate set this value prior to invoking the server
|
|
41
|
+
# ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
42
|
+
|
|
43
|
+
#####################################################################
|
|
44
|
+
CMD ["npm", "run", "indocker"]
|
package/README.md
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
# `Application servers for use with SAS Viya`
|
|
2
|
-
|
|
3
|
-
This package has two servers:
|
|
4
|
-
|
|
5
|
-
1. viya-appserverjs - Use this for developing an app server for web applications(see packages/appjs)
|
|
6
|
-
|
|
7
|
-
2. viya-apiserverjs - Use this to develop rest api servers(see packages/apijs)
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
Specify it as a dependency in your package.json just as you do with other dependencies
|
|
12
|
-
|
|
13
|
-
Use npx command to start the server
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
npx @sassoftware/viyaappserverjs
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## `Basic configuration`
|
|
20
|
-
|
|
21
|
-
1. Set the default settings in Dockerfile. This will ensure these are set when you build containers.
|
|
22
|
-
2. The defaults can be overriden using environment variables.
|
|
23
|
-
|
|
24
|
-
### `Sample env file`
|
|
25
|
-
|
|
26
|
-
When running on a non-docker environment, you can use a .env
|
|
27
|
-
|
|
28
|
-
```env
|
|
29
|
-
VIYA_SERVER=<your viya server>
|
|
30
|
-
APPHOST=localhost < can also be dns name of your server. ex: viyaiscool.unx.sas.com>
|
|
31
|
-
APPPORT=5000 <any port of your choice>
|
|
32
|
-
APPNAME=viyaapp
|
|
33
|
-
|
|
34
|
-
CLIENTID=viyaapp
|
|
35
|
-
CLIENTSECRET=secret
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### `Sample Dockerfile`
|
|
39
|
-
|
|
40
|
-
```env
|
|
41
|
-
FROM node:12.16.1-alpine
|
|
42
|
-
LABEL maintainer="your email"
|
|
43
|
-
WORKDIR /usr/src/app
|
|
44
|
-
COPY . .
|
|
45
|
-
RUN npm install
|
|
46
|
-
# RUN npm run build (if you have to build something)
|
|
47
|
-
EXPOSE 8080
|
|
48
|
-
ENV APPHOST=0.0.0.0
|
|
49
|
-
|
|
50
|
-
AUTHFLOW=code
|
|
51
|
-
|
|
52
|
-
# The following are defaults. Override them as needed
|
|
53
|
-
# APPLOC - where the file specified in APPENTRY is
|
|
54
|
-
# APPENTRY - the main entry of the application
|
|
55
|
-
ENV APPLOC=./public
|
|
56
|
-
ENV APPENTRY=index.html
|
|
57
|
-
# if your app takes advantage of appenv.js to pass configuration to the web application
|
|
58
|
-
# ENV APPENV=appenv.js
|
|
59
|
-
|
|
60
|
-
# See notes below on running with SSL enabled
|
|
61
|
-
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:yourcompany,OU:STO,CN:localhost"
|
|
62
|
-
ENV SAMESITE=None,secure
|
|
63
|
-
|
|
64
|
-
# It is better to set this before invoking the server
|
|
65
|
-
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
66
|
-
|
|
67
|
-
# set this to YES if you want access to the authentication token in the app
|
|
68
|
-
ENV USETOKEN=NO
|
|
69
|
-
|
|
70
|
-
CMD ["npx", "@sassoftware/viya-appserverjs"]
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### `Running with SSL enabled -- Recommended`
|
|
75
|
-
|
|
76
|
-
This is the recommended setting. This will also make browsers like Chrome run with the SAMESITE settings set to Default - your users will thank you.
|
|
77
|
-
|
|
78
|
-
Make sure you specify the VIYA_SERVER with a protocol of https.
|
|
79
|
-
|
|
80
|
-
### `TLS certificates`
|
|
81
|
-
|
|
82
|
-
- Option 1: Let server create a temporary unsigned certificate
|
|
83
|
-
|
|
84
|
-
```env
|
|
85
|
-
ENV TLS_CREATE=C:US,ST:NC,L:Cary,O:YourCompany,OU:yourgroup,CN:localhost
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
- Option 2: Provide your own key and certificate key
|
|
89
|
-
|
|
90
|
-
```env
|
|
91
|
-
ENV TLS_KEY=../certs/self/key.pem
|
|
92
|
-
ENV TLS_CERT=../certs/self/certificate.pem
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
- Option 3: Provide key and certificate as a pfx file
|
|
96
|
-
|
|
97
|
-
```env
|
|
98
|
-
ENV TLS_PFX=../certs/sascert/sascert2.pfx
|
|
99
|
-
```
|
|
1
|
+
# `Application servers for use with SAS Viya`
|
|
2
|
+
|
|
3
|
+
This package has two servers:
|
|
4
|
+
|
|
5
|
+
1. viya-appserverjs - Use this for developing an app server for web applications(see packages/appjs)
|
|
6
|
+
|
|
7
|
+
2. viya-apiserverjs - Use this to develop rest api servers(see packages/apijs)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Specify it as a dependency in your package.json just as you do with other dependencies
|
|
12
|
+
|
|
13
|
+
Use npx command to start the server
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sassoftware/viyaappserverjs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## `Basic configuration`
|
|
20
|
+
|
|
21
|
+
1. Set the default settings in Dockerfile. This will ensure these are set when you build containers.
|
|
22
|
+
2. The defaults can be overriden using environment variables.
|
|
23
|
+
|
|
24
|
+
### `Sample env file`
|
|
25
|
+
|
|
26
|
+
When running on a non-docker environment, you can use a .env
|
|
27
|
+
|
|
28
|
+
```env
|
|
29
|
+
VIYA_SERVER=<your viya server>
|
|
30
|
+
APPHOST=localhost < can also be dns name of your server. ex: viyaiscool.unx.sas.com>
|
|
31
|
+
APPPORT=5000 <any port of your choice>
|
|
32
|
+
APPNAME=viyaapp
|
|
33
|
+
|
|
34
|
+
CLIENTID=viyaapp
|
|
35
|
+
CLIENTSECRET=secret
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `Sample Dockerfile`
|
|
39
|
+
|
|
40
|
+
```env
|
|
41
|
+
FROM node:12.16.1-alpine
|
|
42
|
+
LABEL maintainer="your email"
|
|
43
|
+
WORKDIR /usr/src/app
|
|
44
|
+
COPY . .
|
|
45
|
+
RUN npm install
|
|
46
|
+
# RUN npm run build (if you have to build something)
|
|
47
|
+
EXPOSE 8080
|
|
48
|
+
ENV APPHOST=0.0.0.0
|
|
49
|
+
|
|
50
|
+
AUTHFLOW=code
|
|
51
|
+
|
|
52
|
+
# The following are defaults. Override them as needed
|
|
53
|
+
# APPLOC - where the file specified in APPENTRY is
|
|
54
|
+
# APPENTRY - the main entry of the application
|
|
55
|
+
ENV APPLOC=./public
|
|
56
|
+
ENV APPENTRY=index.html
|
|
57
|
+
# if your app takes advantage of appenv.js to pass configuration to the web application
|
|
58
|
+
# ENV APPENV=appenv.js
|
|
59
|
+
|
|
60
|
+
# See notes below on running with SSL enabled
|
|
61
|
+
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:yourcompany,OU:STO,CN:localhost"
|
|
62
|
+
ENV SAMESITE=None,secure
|
|
63
|
+
|
|
64
|
+
# It is better to set this before invoking the server
|
|
65
|
+
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
66
|
+
|
|
67
|
+
# set this to YES if you want access to the authentication token in the app
|
|
68
|
+
ENV USETOKEN=NO
|
|
69
|
+
|
|
70
|
+
CMD ["npx", "@sassoftware/viya-appserverjs"]
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `Running with SSL enabled -- Recommended`
|
|
75
|
+
|
|
76
|
+
This is the recommended setting. This will also make browsers like Chrome run with the SAMESITE settings set to Default - your users will thank you.
|
|
77
|
+
|
|
78
|
+
Make sure you specify the VIYA_SERVER with a protocol of https.
|
|
79
|
+
|
|
80
|
+
### `TLS certificates`
|
|
81
|
+
|
|
82
|
+
- Option 1: Let server create a temporary unsigned certificate
|
|
83
|
+
|
|
84
|
+
```env
|
|
85
|
+
ENV TLS_CREATE=C:US,ST:NC,L:Cary,O:YourCompany,OU:yourgroup,CN:localhost
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- Option 2: Provide your own key and certificate key
|
|
89
|
+
|
|
90
|
+
```env
|
|
91
|
+
ENV TLS_KEY=../certs/self/key.pem
|
|
92
|
+
ENV TLS_CERT=../certs/self/certificate.pem
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- Option 3: Provide key and certificate as a pfx file
|
|
96
|
+
|
|
97
|
+
```env
|
|
98
|
+
ENV TLS_PFX=../certs/sascert/sascert2.pfx
|
|
99
|
+
```
|
package/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
let core = require('./lib/index.js');
|
|
8
|
-
console.log('Starting the cli for @sassoftware/viya-serverjs');
|
|
9
|
-
core(null, true, 'app', null);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let core = require('./lib/index.js');
|
|
8
|
+
console.log('Starting the cli for @sassoftware/viya-serverjs');
|
|
9
|
+
core(null, true, 'app', null);
|
package/lib/config.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ------------------------------------------------------------------------------------
|
|
3
|
-
* * Copyright (c) SAS Institute Inc.
|
|
4
|
-
* * Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* * you may not use this file except in compliance with the License.
|
|
6
|
-
* * You may obtain a copy of the License at
|
|
7
|
-
* *
|
|
8
|
-
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
* *
|
|
10
|
-
* * Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* * distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* * See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
* ----------------------------------------------------------------------------------------
|
|
16
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* ------------------------------------------------------------------------------------
|
|
3
|
+
* * Copyright (c) SAS Institute Inc.
|
|
4
|
+
* * Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* * you may not use this file except in compliance with the License.
|
|
6
|
+
* * You may obtain a copy of the License at
|
|
7
|
+
* *
|
|
8
|
+
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* *
|
|
10
|
+
* * Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* * distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* * See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
* ----------------------------------------------------------------------------------------
|
|
16
|
+
*
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
'use strict';
|