mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 11:44:34 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f48aeb1b0b | ||
|
|
ee80f3f968 | ||
|
|
7f4201ba85 | ||
|
|
f830bbc058 | ||
|
|
f8e1522a5a | ||
|
|
0a5aeceab5 | ||
|
|
6dc39c0d91 | ||
|
|
117a53ceea | ||
|
|
dd56a95314 | ||
|
|
c5117abe71 | ||
|
|
84c632a861 | ||
|
|
3ddd09eba0 | ||
|
|
0c0301433c | ||
|
|
954b2e3e2e | ||
|
|
5655311b96 | ||
|
|
9ace33d783 |
29
CHANGELOG.md
29
CHANGELOG.md
@@ -2,6 +2,35 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.0.45](https://github.com/sasjs/server/compare/v0.0.43...v0.0.45) (2022-03-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* DELETE req cannot have body ([0a5aece](https://github.com/sasjs/server/commit/0a5aeceab560b022197d0c30c3da7f091b261b1e))
|
||||||
|
* increased req body size ([6dc39c0](https://github.com/sasjs/server/commit/6dc39c0d91ac13d6d9b8c0a2240446bfc45bdd7f))
|
||||||
|
* proving a PRINT destination during SAS invocation. ([7f4201b](https://github.com/sasjs/server/commit/7f4201ba855743144fa6d3efac2b11e816d4696e)), closes [#111](https://github.com/sasjs/server/issues/111)
|
||||||
|
* **session:** increased session + bug fixed ([117a53c](https://github.com/sasjs/server/commit/117a53ceeadf487a6326384ae11c10e98646631f))
|
||||||
|
* **stp:** use same session from file upload ([dd56a95](https://github.com/sasjs/server/commit/dd56a95314f0b61480489118734e45877e1745ef))
|
||||||
|
|
||||||
|
### [0.0.44](https://github.com/sasjs/server/compare/v0.0.43...v0.0.44) (2022-03-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* DELETE req cannot have body ([0a5aece](https://github.com/sasjs/server/commit/0a5aeceab560b022197d0c30c3da7f091b261b1e))
|
||||||
|
* increased req body size ([6dc39c0](https://github.com/sasjs/server/commit/6dc39c0d91ac13d6d9b8c0a2240446bfc45bdd7f))
|
||||||
|
* **session:** increased session + bug fixed ([117a53c](https://github.com/sasjs/server/commit/117a53ceeadf487a6326384ae11c10e98646631f))
|
||||||
|
* **stp:** use same session from file upload ([dd56a95](https://github.com/sasjs/server/commit/dd56a95314f0b61480489118734e45877e1745ef))
|
||||||
|
|
||||||
|
### [0.0.43](https://github.com/sasjs/server/compare/v0.0.42...v0.0.43) (2022-03-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deploy:** user can deploy to same appName with different/same appLoc ([9ace33d](https://github.com/sasjs/server/commit/9ace33d7830a9def42d741c23b46090afe0c5510))
|
||||||
|
* fallback logo on AppStream ([5655311](https://github.com/sasjs/server/commit/5655311b9663225823c192b39a03f39d17dda730))
|
||||||
|
|
||||||
### [0.0.42](https://github.com/sasjs/server/compare/v0.0.41...v0.0.42) (2022-03-23)
|
### [0.0.42](https://github.com/sasjs/server/compare/v0.0.41...v0.0.42) (2022-03-23)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -48,11 +48,21 @@ When launching the app, it will make use of specific environment variables. Thes
|
|||||||
Example contents of a `.env` file:
|
Example contents of a `.env` file:
|
||||||
|
|
||||||
```
|
```
|
||||||
MODE=desktop # options: [desktop|server] default: `desktop`
|
# options: [desktop|server] default: `desktop`
|
||||||
CORS=disable # options: [disable|enable] default: `disable` for `server` & `enable` for `desktop`
|
MODE=
|
||||||
WHITELIST= # options: <http://localhost:3000 https://abc.com ...> space separated urls
|
|
||||||
PROTOCOL=http # options: [http|https] default: http
|
# options: [disable|enable] default: `disable` for `server` & `enable` for `desktop`
|
||||||
PORT=5000 # default: 5000
|
CORS=
|
||||||
|
|
||||||
|
# options: <http://localhost:3000 https://abc.com ...> space separated urls
|
||||||
|
WHITELIST=
|
||||||
|
|
||||||
|
# options: [http|https] default: http
|
||||||
|
PROTOCOL=
|
||||||
|
|
||||||
|
# default: 5000
|
||||||
|
PORT=
|
||||||
|
|
||||||
|
|
||||||
# optional
|
# optional
|
||||||
# for MODE: `desktop`, prompts user
|
# for MODE: `desktop`, prompts user
|
||||||
|
|||||||
@@ -649,7 +649,6 @@ paths:
|
|||||||
required:
|
required:
|
||||||
- status
|
- status
|
||||||
type: object
|
type: object
|
||||||
description: "It's optional to either provide `_filePath` in url as query parameter\nOr provide `filePath` in body as form field.\nBut it's required to provide else API will respond with Bad Request."
|
|
||||||
summary: 'Delete file from SASjs Drive'
|
summary: 'Delete file from SASjs Drive'
|
||||||
tags:
|
tags:
|
||||||
- Drive
|
- Drive
|
||||||
@@ -660,19 +659,10 @@ paths:
|
|||||||
-
|
-
|
||||||
in: query
|
in: query
|
||||||
name: _filePath
|
name: _filePath
|
||||||
required: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
example: /Public/somefolder/some.file
|
example: /Public/somefolder/some.file
|
||||||
requestBody:
|
|
||||||
required: false
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
filePath:
|
|
||||||
type: string
|
|
||||||
post:
|
post:
|
||||||
operationId: SaveFile
|
operationId: SaveFile
|
||||||
responses:
|
responses:
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
copySASjsCore,
|
copySASjsCore,
|
||||||
getWebBuildFolderPath,
|
getWebBuildFolderPath,
|
||||||
loadAppStreamConfig,
|
loadAppStreamConfig,
|
||||||
sasJSCoreMacros,
|
|
||||||
setProcessVariables
|
setProcessVariables
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ if (MODE?.trim() !== 'server' || CORS?.trim() === 'enable') {
|
|||||||
|
|
||||||
app.use(cookieParser())
|
app.use(cookieParser())
|
||||||
app.use(morgan('tiny'))
|
app.use(morgan('tiny'))
|
||||||
app.use(express.json({ limit: '50mb' }))
|
app.use(express.json({ limit: '100mb' }))
|
||||||
app.use(express.static(path.join(__dirname, '../public')))
|
app.use(express.static(path.join(__dirname, '../public')))
|
||||||
|
|
||||||
const onError: ErrorRequestHandler = (err, req, res, next) => {
|
const onError: ErrorRequestHandler = (err, req, res, next) => {
|
||||||
|
|||||||
@@ -108,20 +108,14 @@ export class DriveController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's optional to either provide `_filePath` in url as query parameter
|
|
||||||
* Or provide `filePath` in body as form field.
|
|
||||||
* But it's required to provide else API will respond with Bad Request.
|
|
||||||
*
|
*
|
||||||
* @summary Delete file from SASjs Drive
|
* @summary Delete file from SASjs Drive
|
||||||
* @query _filePath Location of SAS program
|
* @query _filePath Location of SAS program
|
||||||
* @example _filePath "/Public/somefolder/some.file"
|
* @example _filePath "/Public/somefolder/some.file"
|
||||||
*/
|
*/
|
||||||
@Delete('/file')
|
@Delete('/file')
|
||||||
public async deleteFile(
|
public async deleteFile(@Query() _filePath: string) {
|
||||||
@Query() _filePath?: string,
|
return deleteFile(_filePath)
|
||||||
@FormField() filePath?: string
|
|
||||||
) {
|
|
||||||
return deleteFile((_filePath ?? filePath)!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,9 +299,3 @@ const updateFile = async (
|
|||||||
|
|
||||||
return { status: 'success' }
|
return { status: 'success' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateFilePath = async (filePath: string) => {
|
|
||||||
if (!(await fileExists(filePath))) {
|
|
||||||
throw 'DriveController: File does not exists.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
moveFile,
|
moveFile,
|
||||||
readFileBinary
|
readFileBinary
|
||||||
} from '@sasjs/utils'
|
} from '@sasjs/utils'
|
||||||
import { PreProgramVars, TreeNode } from '../../types'
|
import { PreProgramVars, Session, TreeNode } from '../../types'
|
||||||
import {
|
import {
|
||||||
extractHeaders,
|
extractHeaders,
|
||||||
generateFileUploadSasCode,
|
generateFileUploadSasCode,
|
||||||
@@ -39,7 +39,8 @@ export class ExecutionController {
|
|||||||
preProgramVariables: PreProgramVars,
|
preProgramVariables: PreProgramVars,
|
||||||
vars: ExecutionVars,
|
vars: ExecutionVars,
|
||||||
otherArgs?: any,
|
otherArgs?: any,
|
||||||
returnJson?: boolean
|
returnJson?: boolean,
|
||||||
|
session?: Session
|
||||||
) {
|
) {
|
||||||
if (!(await fileExists(programPath)))
|
if (!(await fileExists(programPath)))
|
||||||
throw 'ExecutionController: SAS file does not exist.'
|
throw 'ExecutionController: SAS file does not exist.'
|
||||||
@@ -51,7 +52,8 @@ export class ExecutionController {
|
|||||||
preProgramVariables,
|
preProgramVariables,
|
||||||
vars,
|
vars,
|
||||||
otherArgs,
|
otherArgs,
|
||||||
returnJson
|
returnJson,
|
||||||
|
session
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +62,13 @@ export class ExecutionController {
|
|||||||
preProgramVariables: PreProgramVars,
|
preProgramVariables: PreProgramVars,
|
||||||
vars: ExecutionVars,
|
vars: ExecutionVars,
|
||||||
otherArgs?: any,
|
otherArgs?: any,
|
||||||
returnJson?: boolean
|
returnJson?: boolean,
|
||||||
|
sessionByFileUpload?: Session
|
||||||
): Promise<ExecuteReturnRaw | ExecuteReturnJson> {
|
): Promise<ExecuteReturnRaw | ExecuteReturnJson> {
|
||||||
const sessionController = getSessionController()
|
const sessionController = getSessionController()
|
||||||
|
|
||||||
const session = await sessionController.getSession()
|
const session =
|
||||||
|
sessionByFileUpload ?? (await sessionController.getSession())
|
||||||
session.inUse = true
|
session.inUse = true
|
||||||
session.consumed = true
|
session.consumed = true
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export class FileUploadController {
|
|||||||
|
|
||||||
const sessionController = getSessionController()
|
const sessionController = getSessionController()
|
||||||
session = await sessionController.getSession()
|
session = await sessionController.getSession()
|
||||||
session.inUse = true
|
// marking consumed true, so that it's not available
|
||||||
|
// as readySession for any other request
|
||||||
|
session.consumed = true
|
||||||
|
|
||||||
req.sasSession = session
|
req.sasSession = session
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export class SessionController {
|
|||||||
? readySessions[0]
|
? readySessions[0]
|
||||||
: await this.createSession()
|
: await this.createSession()
|
||||||
|
|
||||||
if (readySessions.length < 2) this.createSession()
|
if (readySessions.length < 3) this.createSession()
|
||||||
|
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,8 @@ ${autoExecContent}`
|
|||||||
codePath,
|
codePath,
|
||||||
'-LOG',
|
'-LOG',
|
||||||
path.join(session.path, 'log.log'),
|
path.join(session.path, 'log.log'),
|
||||||
|
'-PRINT',
|
||||||
|
path.join(session.path, 'output.lst'),
|
||||||
'-WORK',
|
'-WORK',
|
||||||
session.path,
|
session.path,
|
||||||
'-AUTOEXEC',
|
'-AUTOEXEC',
|
||||||
|
|||||||
@@ -143,9 +143,8 @@ const executeReturnRaw = async (
|
|||||||
query
|
query
|
||||||
)) as ExecuteReturnRaw
|
)) as ExecuteReturnRaw
|
||||||
|
|
||||||
// Should over-ride response header for
|
// Should over-ride response header for debug
|
||||||
// debug on GET request to see entire log
|
// on GET request to see entire log rendering on browser.
|
||||||
// rendering on browser.
|
|
||||||
if (isDebugOn(query)) {
|
if (isDebugOn(query)) {
|
||||||
httpHeaders['content-type'] = 'text/plain'
|
httpHeaders['content-type'] = 'text/plain'
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,8 @@ const executeReturnJson = async (
|
|||||||
getPreProgramVariables(req),
|
getPreProgramVariables(req),
|
||||||
{ ...req.query, ...req.body },
|
{ ...req.query, ...req.body },
|
||||||
{ filesNamesMap: filesNamesMap },
|
{ filesNamesMap: filesNamesMap },
|
||||||
true
|
true,
|
||||||
|
req.sasSession
|
||||||
)) as ExecuteReturnJson
|
)) as ExecuteReturnJson
|
||||||
|
|
||||||
let weboutRes: string | IRecordOfAny = webout
|
let weboutRes: string | IRecordOfAny = webout
|
||||||
|
|||||||
@@ -57,12 +57,11 @@ driveRouter.get('/file', async (req, res) => {
|
|||||||
|
|
||||||
driveRouter.delete('/file', async (req, res) => {
|
driveRouter.delete('/file', async (req, res) => {
|
||||||
const { error: errQ, value: query } = fileParamValidation(req.query)
|
const { error: errQ, value: query } = fileParamValidation(req.query)
|
||||||
const { error: errB, value: body } = fileBodyValidation(req.body)
|
|
||||||
|
|
||||||
if (errQ && errB) return res.status(400).send(errQ.details[0].message)
|
if (errQ) return res.status(400).send(errQ.details[0].message)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await controller.deleteFile(query._filePath, body.filePath)
|
const response = await controller.deleteFile(query._filePath)
|
||||||
res.send(response)
|
res.send(response)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
res.status(403).send(err.toString())
|
res.status(403).send(err.toString())
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ const style = `<style>
|
|||||||
width: 150px;
|
width: 150px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 10px 10px 0 0;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.app-container .app img{
|
.app-container .app img{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
</style>`
|
</style>`
|
||||||
|
|
||||||
@@ -31,7 +31,10 @@ const singleAppStreamHtml = (
|
|||||||
logo?: string
|
logo?: string
|
||||||
) =>
|
) =>
|
||||||
` <a class="app" href="${streamServiceName}" title="${appLoc}">
|
` <a class="app" href="${streamServiceName}" title="${appLoc}">
|
||||||
<img src="${logo ? streamServiceName + '/' + logo : defaultAppLogo}" />
|
<img
|
||||||
|
src="${logo ? streamServiceName + '/' + logo : defaultAppLogo}"
|
||||||
|
onerror="this.src = '${defaultAppLogo}';"
|
||||||
|
/>
|
||||||
${streamServiceName}
|
${streamServiceName}
|
||||||
</a>`
|
</a>`
|
||||||
|
|
||||||
|
|||||||
@@ -40,17 +40,6 @@ export const publishAppStream = async (
|
|||||||
|
|
||||||
if (!streamServiceName) {
|
if (!streamServiceName) {
|
||||||
streamServiceName = `AppStreamName${appCount + 1}`
|
streamServiceName = `AppStreamName${appCount + 1}`
|
||||||
} else {
|
|
||||||
const alreadyDeployed = process.appStreamConfig[streamServiceName]
|
|
||||||
if (alreadyDeployed) {
|
|
||||||
if (alreadyDeployed.appLoc === appLoc) {
|
|
||||||
// redeploying to same streamServiceName
|
|
||||||
} else {
|
|
||||||
// trying to deploy to another existing streamServiceName
|
|
||||||
// assign new streamServiceName
|
|
||||||
streamServiceName = `${streamServiceName}-${appCount + 1}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
router.use(`/${streamServiceName}`, express.static(pathToDeployment))
|
router.use(`/${streamServiceName}`, express.static(pathToDeployment))
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { AppStreamConfig } from '../types'
|
|||||||
import { getTmpAppStreamConfigPath } from './file'
|
import { getTmpAppStreamConfigPath } from './file'
|
||||||
|
|
||||||
export const loadAppStreamConfig = async () => {
|
export const loadAppStreamConfig = async () => {
|
||||||
|
if (process.env.NODE_ENV === 'test') return
|
||||||
|
|
||||||
const appStreamConfigPath = getTmpAppStreamConfigPath()
|
const appStreamConfigPath = getTmpAppStreamConfigPath()
|
||||||
|
|
||||||
const content = (await fileExists(appStreamConfigPath))
|
const content = (await fileExists(appStreamConfigPath))
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
import { getTmpMacrosPath, sasJSCoreMacros, sasJSCoreMacrosInfo } from '.'
|
import { getTmpMacrosPath, sasJSCoreMacros, sasJSCoreMacrosInfo } from '.'
|
||||||
|
|
||||||
export const copySASjsCore = async () => {
|
export const copySASjsCore = async () => {
|
||||||
|
if (process.env.NODE_ENV === 'test') return
|
||||||
|
|
||||||
console.log('Copying Macros from container to drive(tmp).')
|
console.log('Copying Macros from container to drive(tmp).')
|
||||||
|
|
||||||
const macrosDrivePath = getTmpMacrosPath()
|
const macrosDrivePath = getTmpMacrosPath()
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.42",
|
"version": "0.0.45",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.42",
|
"version": "0.0.45",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^2.3.1",
|
"prettier": "^2.3.1",
|
||||||
"standard-version": "^9.3.2"
|
"standard-version": "^9.3.2"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.42",
|
"version": "0.0.45",
|
||||||
"description": "NodeJS wrapper for calling the SAS binary executable",
|
"description": "NodeJS wrapper for calling the SAS binary executable",
|
||||||
"repository": "https://github.com/sasjs/server",
|
"repository": "https://github.com/sasjs/server",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user