diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 226cc90..db2d98b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,25 +2,22 @@ Contributions are very welcome! Feel free to raise an issue or start a discussion, for help in getting started. +The app can be deployed using Docker or NodeJS. ## Configuration -Configuration is made in the `configuration` section of `package.json`: +Configuration is made using `.env` files (per [README.md](https://github.com/sasjs/server#env-var-configuration) settings), _except_ for one case, when running in NodeJS in production - in which case the path to the SAS executable is made in the `configuration` section of `package.json`. -- Provide path to SAS9 executable. +The `.env` file should be created in the location(s) below. Each folder contains a `.env.example` file that may be adjusted and renamed. + +* `.env` - the root .env file is used only for Docker deploys. +* `api/.env` - this is the primary file used in NodeJS deploys +* `web/.env` - this file is only necessary in NodeJS when running `web` and `api` seperately (on different ports). -### Using dockers: +## Using Docker -There is `.env.example` file present at root of the project. [for Production] - -There is `.env.example` file present at `./api` of the project. [for Development] - -There is `.env.example` file present at `./web` of the project. [for Development] - -Remember to provide enviornment variables. - -#### Development +### Docker Development Mode Command to run docker for development: @@ -38,7 +35,7 @@ It will build following images if running first time: - `mongo-seed-clients` - will be populating client data specified in _./mongo-seed/clients/client.json_ -#### Production +### Docker Production Mode Command to run docker for production: @@ -54,47 +51,45 @@ It will build following images if running first time: - `mongo-seed-users` - will be populating user data specified in _./mongo-seed/users/user.json_ - `mongo-seed-clients` - will be populating client data specified in _./mongo-seed/clients/client.json_ -### Using node: +## Using NodeJS: -#### Development (running api and web seperately): +Be sure to use v16 or above, and to set your environment variables in the relevant `.env` file(s) - else defaults will be used. -##### API +### NodeJS Development Mode -Navigate to `./api` -There is `.env.example` file present at `./api` directory. Remember to provide enviornment variables else default values will be used mentioned in `.env.example` files -Command to install and run api server. +SASjs Server is split between an API server (serving REST requests) and a WEB Server (everything else). These can be run together, or on seperate ports. + +### NodeJS Dev - Single Port + +Here the environment variables should be configured under `api.env`. Then: ``` +cd ./web && npm i && npm build +cd ../api && npm i && npm start +``` + +### NodeJS Dev - Seperate Ports + +Set the backend variables in `api/.env` and the frontend variables in `web/.env`. Then: + +#### API server +``` +cd api npm install npm start ``` -##### Web - -Navigate to `./web` -There is `.env.example` file present at `./web` directory. Remember to provide enviornment variables else default values will be used mentioned in `.env.example` files -Command to install and run api server. +#### Web Server ``` +cd web npm install npm start ``` -#### Development (running only api server and have web build served): +#### NodeJS Production Mode -##### API server also serving Web build files - -There is `.env.example` file present at `./api` directory. Remember to provide enviornment variables else default values will be used mentioned in `.env.example` files -Command to install and run api server. - -``` -cd ./web && npm i && npm build && cd ../ -cd ./api && npm i && npm start -``` - -#### Production - -##### API & WEB +Update the `.env` file in the *api* folder. Then: ``` npm run server @@ -105,7 +100,7 @@ This will install/build `web` and install `api`, then start prod server. ## Executables -Command to generate executables +In order to generate the final executables: ``` cd ./web && npm i && npm build && cd ../ diff --git a/api/package-lock.json b/api/package-lock.json index e04bb34..9f8fafe 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -2448,9 +2448,9 @@ } }, "node_modules/async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dependencies": { "lodash": "^4.17.14" } @@ -12060,9 +12060,9 @@ } }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "requires": { "lodash": "^4.17.14" } diff --git a/api/package.json b/api/package.json index b629c00..d835e4c 100644 --- a/api/package.json +++ b/api/package.json @@ -8,6 +8,7 @@ "prestart": "npm run initial", "prebuild": "npm run initial", "start": "nodemon ./src/server.ts", + "start:prod": "node ./build/src/server.js", "build": "rimraf build && tsc", "postbuild": "npm run copy:files", "swagger": "tsoa spec", diff --git a/api/scripts/systemInit.sas b/api/scripts/systemInit.sas index c92e858..62a751f 100644 --- a/api/scripts/systemInit.sas +++ b/api/scripts/systemInit.sas @@ -5,23 +5,12 @@ _before_ any user-provided content. A number of useful CORE macros are also compiled below, so that they can be - available "out of the box". + available by default for Stored Programs. + + Note that the full CORE library is available to sessions in SASjs Studio.