1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 19:44:35 +00:00

Compare commits

...

13 Commits

Author SHA1 Message Date
munja
f830bbc058 chore(release): 0.0.44 2022-03-29 11:25:00 +01:00
Allan Bowe
f8e1522a5a Merge pull request #110 from sasjs/issue-108
fix: increased req body size
2022-03-28 14:22:44 +03:00
Saad Jutt
0a5aeceab5 fix: DELETE req cannot have body 2022-03-28 05:05:03 +05:00
Saad Jutt
6dc39c0d91 fix: increased req body size 2022-03-28 04:53:24 +05:00
Saad Jutt
117a53ceea fix(session): increased session + bug fixed 2022-03-24 20:22:06 +05:00
Saad Jutt
dd56a95314 fix(stp): use same session from file upload 2022-03-24 18:06:28 +05:00
Saad Jutt
c5117abe71 chore: README.md updated 2022-03-24 05:56:08 +05:00
Saad Jutt
84c632a861 chore(release): 0.0.43 2022-03-24 04:25:40 +05:00
Muhammad Saad
3ddd09eba0 Merge pull request #105 from sasjs/deploy-app-with-current-names-also
Deploy app with current names also
2022-03-24 04:25:12 +05:00
Saad Jutt
0c0301433c test: fixed 2022-03-24 04:22:30 +05:00
Saad Jutt
954b2e3e2e chore: removed test file 2022-03-24 01:12:04 +05:00
Saad Jutt
5655311b96 fix: fallback logo on AppStream 2022-03-24 01:07:06 +05:00
Saad Jutt
9ace33d783 fix(deploy): user can deploy to same appName with different/same appLoc 2022-03-24 00:54:59 +05:00
16 changed files with 68 additions and 62 deletions

View File

@@ -2,6 +2,24 @@
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.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)

View File

@@ -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

View File

@@ -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:

View File

@@ -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) => {

View File

@@ -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.'
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
} }

View File

@@ -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

View File

@@ -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())

View File

@@ -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>`

View File

@@ -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))

View File

@@ -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))

View File

@@ -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
View File

@@ -1,12 +1,12 @@
{ {
"name": "server", "name": "server",
"version": "0.0.42", "version": "0.0.44",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "server", "name": "server",
"version": "0.0.42", "version": "0.0.44",
"devDependencies": { "devDependencies": {
"prettier": "^2.3.1", "prettier": "^2.3.1",
"standard-version": "^9.3.2" "standard-version": "^9.3.2"

View File

@@ -1,6 +1,6 @@
{ {
"name": "server", "name": "server",
"version": "0.0.42", "version": "0.0.44",
"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": {