# @sassoftware/restaf-server

> app and api server for SAS Viya user applications

Latest version **1.3.0** (published 2022-02-06) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @sassoftware/restaf-server
pnpm add @sassoftware/restaf-server
yarn add @sassoftware/restaf-server
bun add @sassoftware/restaf-server
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2022-02-06 |
| First published | 2019-12-31 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 32 |
| Unpacked size | 38 MB |
| Known vulnerabilities | 0 (+27 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Deva Kumar |
| Maintainers | coalman, jefurbee, devakumaraswamy, ckedwards, rbtlevey, brmorr, bjtomlin, jolyna |
| Keywords | REST, API, Viya, restaf |

## Links

- npm: https://www.npmjs.com/package/@sassoftware/restaf-server
- Repository: https://github.com/sassoftware/restaf-server
- Homepage: https://github.com/sassoftware/restaf-server#readme
- Issues: https://github.com/sassoftware/restaf-server/issues
- npm.io page: https://npm.io/package/@sassoftware/restaf-server

## Dependencies (32)

- [qs](https://npm.io/package/qs.md) ^6.10.3
- [only](https://npm.io/package/only.md) 0.0.2
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [axios](https://npm.io/package/axios.md) ^0.25.0
- [debug](https://npm.io/package/debug.md) ^4.3.3
- [yargs](https://npm.io/package/yargs.md) 17.3.1
- [core-js](https://npm.io/package/core-js.md) ^3.21.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [tcp-ping](https://npm.io/package/tcp-ping.md) ^0.1.1
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^17.1.1
- [hapi-pino](https://npm.io/package/hapi-pino.md) ^9.1.2
- [is-docker](https://npm.io/package/is-docker.md) ^3.0.0
- [@hapi/bell](https://npm.io/package/@hapi/bell.md) ^12.3.0
- [@hapi/boom](https://npm.io/package/@hapi/boom.md) ^9.1.4
- [@hapi/h2o2](https://npm.io/package/@hapi/h2o2.md) ^9.1.0
- [@hapi/hapi](https://npm.io/package/@hapi/hapi.md) ^20.2.1
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.7
- [jwt-decode](https://npm.io/package/jwt-decode.md) ^3.1.2
- [selfsigned](https://npm.io/package/selfsigned.md) ^2.0.0
- [@hapi/inert](https://npm.io/package/@hapi/inert.md) ^6.0.5
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [pino-pretty](https://npm.io/package/pino-pretty.md) ^7.5.1
- [@hapi/cookie](https://npm.io/package/@hapi/cookie.md) ^11.0.2
- [@hapi/vision](https://npm.io/package/@hapi/vision.md) ^6.1.0
- [hapi-swagger](https://npm.io/package/hapi-swagger.md) ^14.2.4
- [request-debug](https://npm.io/package/request-debug.md) ^0.2.0
- [docker-file-parser](https://npm.io/package/docker-file-parser.md) ^1.0.7
- [hapi-require-https](https://npm.io/package/hapi-require-https.md) ^5.0.0
- [node-cache-promise](https://npm.io/package/node-cache-promise.md) ^1.0.2
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.13.9
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^8.3.0
- [should-send-same-site-none](https://npm.io/package/should-send-same-site-none.md) ^2.0.5

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2022-02-06
- 3.1.0 (dev) — 2024-12-10
- 2.1.0 (test) — 2022-09-26
- 8.4.3 (rc1) — 2021-01-10
- 8.3.8 (rc2) — 2021-01-07
- 8.2.9 (kube) — 2020-10-22
- 8.2.1 (tls) — 2020-09-15
- 1.2.2 — 2021-01-25
- 8.4.2 — 2021-01-08
- 8.4.1 — 2021-01-08
- 8.3.7 — 2021-01-06
- 8.3.6 — 2021-01-05
- 8.3.5 — 2021-01-05
- 8.3.4 — 2021-01-04
- 8.3.3 — 2021-01-03
- … 56 more at https://npm.io/package/@sassoftware/restaf-server/versions

## README

# `Application server for use with SAS Viya`

This package has two servers:

1. restaf-server - Use this for developing an app server for web applications(see packages/appjs)
    - alternate name: viya-aappserverjs to be consisetent with item 2 below
2. viya-apiserverjs - Use this to develop rest api servers(see packages/apijs)

> The restaf-server will be soon super-seeded by viya-app-server with better support for protecting all routes

## `Basic configuration`

1. Set the default settings in Dockerfile. This will ensure these are set when you build containers.
2. Use the .env file when running bare-os and docker-compose file to set run time overrides.

### `Sample env file`
```env
VIYA_SERVER=<your viya server>
APPHOST=localhost < can also be dns name of your server. ex: viyaiscool.unx.sas.com>
APPPORT=5000   <any port of your choice>
```
### `Sample Dockerfile`

```env
FROM node:12.16.1-alpine
LABEL maintainer="your email"
WORKDIR /usr/src/app
COPY . .
RUN npm install
# RUN npm run build (if you have to build something)
EXPOSE 8080
ENV APPHOST=0.0.0.0

#######################################################################
# You can override these in .env file or docker-compose file
########################################################################

ENV APPNAME=viyaapp
ENV AUTHFLOW=code
ENV CLIENTID=viyaapp
ENV CLIENTSECRET=secret

# The following are defaults 
ENV APPLOC=./public
ENV APPENTRY=index.html
# if your app takes advantage of appenv.js to pass configuration to the web application 
# ENV APPENV=appenv.js 

# See notes below on running with SSL enabled
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:yourcompany,OU:STO,CN:localhost"
ENV SAMESITE=None,secure
ENV NODE_TLS_REJECT_UNAUTHORIZED=0

#####################################################################
CMD ["npx", "@sassoftware/viya-appserverjs"]

```

### `Running with SSL enabled -- Recommended`

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.

Make sure you specify the VIYA_SERVER with a protocol of https.

The following are the key settings:

1. `SAMESITE`
    - The recommend setting is None,secure.
    - If not set the servers will default to None,false - this is prmarily for backward compatability.

```env
ENV SAMESITE=None,secure
```

You should be able to set these browser settings to default:
- SameSite by default cookies
- Coookies with SameSite must be secure

I am not really sure about the impact of setting for new Schemeful Same-site option to default. So enable it at your own risk.

2. The certificates for SSL can be set in one of the following ways(all values are just examples). 


- Let server create a temporary unsigned certificate

    ```env
    ENV TLS_CREATE=C:US,ST:NC,L:Cary,O:YourCompany,OU:yourgroup,CN:localhost
    ```

- Provide your own key and certificate key

```env
ENV TLS_KEY=../certs/self/key.pem
ENV TLS_CERT=../certs/self/certificate.pem
```

- Provide key and certificate as a pfx file

```env
ENV TLS_PFX=../certs/sascert/sascert2.pfx
```

### `Running without SSL`

Make sure your specify VIYA_SERVER with a protocol of http

1. `SAMESITE`
    - Set this as None,false

```env
ENV SAMESITE=None,false
```

You might also have to disable all the SAMESITE options in your browser:

- SameSite by default cookies
- Coookies with SameSite must be secure
- Schemeful Same-site

### CLIENTID and CLIENTSECRET

Recommend you use the authorization_flow code. Set the redirect url to this pattern:

<protocol>://<APPHOST>:<APPPORT>/<APPNAME>
ex:
<https://localhost:5000/viyaapp>

If you also run without ssl enabled then set it to something like this:
<https://localhost:5000/viyaapp,http://localhost:5000/viyaapp>

If you are using port 443 for ssl-enabled, then add this redirect also
<https://localhost/viyaapp>


## Viya Server Configuration and more

Please see <https://github.com/sassoftware/restaf-server/wiki>

---
_Source: https://npm.io/package/@sassoftware/restaf-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
