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

feat: generate executables for sasjs/server with web component

This commit is contained in:
Saad Jutt
2021-11-12 06:40:10 +05:00
parent 7b8cd0892c
commit 514a262340
8 changed files with 10310 additions and 262 deletions

1
.gitignore vendored
View File

@@ -7,4 +7,5 @@ sas/
tmp/
build/
certificates/
executables/
.env

1099
api/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,24 @@
"test": "mkdir -p tmp && mkdir -p ../web/build && jest --coverage",
"lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
"lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
"package:lib": "npm run build && cp ./package.json build && cp README.md build && cd build && npm version \"5.0.0\" && npm pack"
"package:lib": "npm run build && cp ./package.json build && cp README.md build && cd build && npm version \"5.0.0\" && npm pack",
"exe:prepare": "npm run build && cd build && npm run api && npm run public:copy && npm run web && pkg .",
"api": "npm run api:mkdir && npm run api:copy",
"api:mkdir": "mkdir tmp && mkdir tmp/files && mkdir tmp/logs && mkdir tmp/webouts && mkdir tmp/sessions",
"api:copy": "cp -r ../tmp/ ./tmp/",
"public:copy": "cp -r ../public/ ./public/",
"web": "cd .. && npm run web:mkdir && npm run web:copy && cd build",
"web:mkdir": "rimraf web && mkdir web && mkdir web/build",
"web:copy": "cp -r ../web/build/ ./web/build/"
},
"bin": "src/server.js",
"pkg": {
"assets": [
"tmp/files/**/*",
"public/**/*",
"../web/build/**/*"
],
"outputPath": "../../executables"
},
"release": {
"branches": [
@@ -50,6 +67,7 @@
"jest": "^27.0.6",
"mongodb-memory-server": "^8.0.0",
"nodemon": "^2.0.7",
"pkg": "^5.4.1",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.3",

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,93 @@ components:
requestBodies: {}
responses: {}
schemas:
AuthorizeResponse:
properties:
code:
type: string
description: 'Authorization code'
example: someRandomCryptoString
required:
- code
type: object
additionalProperties: false
AuthorizePayload:
properties:
username:
type: string
description: 'Username for user'
example: secretuser
password:
type: string
description: 'Password for user'
example: secretpassword
clientId:
type: string
description: 'Client ID'
example: clientID1
required:
- username
- password
- clientId
type: object
additionalProperties: false
TokenResponse:
properties:
accessToken:
type: string
description: 'Access Token'
example: someRandomCryptoString
refreshToken:
type: string
description: 'Refresh Token'
example: someRandomCryptoString
required:
- accessToken
- refreshToken
type: object
additionalProperties: false
TokenPayload:
properties:
clientId:
type: string
description: 'Client ID'
example: clientID1
code:
type: string
description: 'Authorization code'
example: someRandomCryptoString
required:
- clientId
- code
type: object
additionalProperties: false
InfoJWT:
properties:
clientId:
type: string
userId:
type: number
format: double
required:
- clientId
- userId
type: object
additionalProperties: false
ClientPayload:
properties:
clientId:
type: string
description: 'Client ID'
example: someFormattedClientID1234
clientSecret:
type: string
description: 'Client Secret'
example: someRandomCryptoString
required:
- clientId
- clientSecret
type: object
additionalProperties: false
MemberType.folder:
enum:
- folder
@@ -151,28 +238,6 @@ components:
- tree
type: object
additionalProperties: false
ExecuteReturnJsonResponse:
properties:
status:
type: string
log:
type: string
result:
type: string
message:
type: string
required:
- status
type: object
additionalProperties: false
ExecuteReturnJsonPayload:
properties:
_program:
type: string
description: 'Location of SAS program'
example: /Public/somefolder/some.file
type: object
additionalProperties: false
UserResponse:
properties:
id:
@@ -293,91 +358,26 @@ components:
- description
type: object
additionalProperties: false
ClientPayload:
ExecuteReturnJsonResponse:
properties:
clientId:
status:
type: string
description: 'Client ID'
example: someFormattedClientID1234
clientSecret:
log:
type: string
result:
type: string
message:
type: string
description: 'Client Secret'
example: someRandomCryptoString
required:
- clientId
- clientSecret
- status
type: object
additionalProperties: false
AuthorizeResponse:
ExecuteReturnJsonPayload:
properties:
code:
_program:
type: string
description: 'Authorization code'
example: someRandomCryptoString
required:
- code
type: object
additionalProperties: false
AuthorizePayload:
properties:
username:
type: string
description: 'Username for user'
example: secretuser
password:
type: string
description: 'Password for user'
example: secretpassword
clientId:
type: string
description: 'Client ID'
example: clientID1
required:
- username
- password
- clientId
type: object
additionalProperties: false
TokenResponse:
properties:
accessToken:
type: string
description: 'Access Token'
example: someRandomCryptoString
refreshToken:
type: string
description: 'Refresh Token'
example: someRandomCryptoString
required:
- accessToken
- refreshToken
type: object
additionalProperties: false
TokenPayload:
properties:
clientId:
type: string
description: 'Client ID'
example: clientID1
code:
type: string
description: 'Authorization code'
example: someRandomCryptoString
required:
- clientId
- code
type: object
additionalProperties: false
InfoJWT:
properties:
clientId:
type: string
userId:
type: number
format: double
required:
- clientId
- userId
description: 'Location of SAS program'
example: /Public/somefolder/some.file
type: object
additionalProperties: false
securitySchemes:
@@ -393,6 +393,113 @@ info:
name: 'Analytium Ltd'
openapi: 3.0.0
paths:
/SASjsApi/auth/authorize:
post:
operationId: Authorize
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizeResponse'
examples:
'Example 1':
value: {code: someRandomCryptoString}
summary: 'Accept a valid username/password, plus a CLIENT_ID, and return an AUTH_CODE'
tags:
- Auth
security: []
parameters: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizePayload'
/SASjsApi/auth/token:
post:
operationId: Token
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
examples:
'Example 1':
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
summary: 'Accepts client/auth code and returns access/refresh tokens'
tags:
- Auth
security: []
parameters: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TokenPayload'
/SASjsApi/auth/refresh:
post:
operationId: Refresh
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
examples:
'Example 1':
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
summary: 'Returns new access/refresh tokens'
tags:
- Auth
security:
-
bearerAuth: []
parameters: []
/SASjsApi/auth/logout:
post:
operationId: Logout
responses:
'204':
description: 'No content'
summary: 'Logout terminate access/refresh tokens and returns nothing'
tags:
- Auth
security:
-
bearerAuth: []
parameters: []
/SASjsApi/client:
post:
operationId: CreateClient
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ClientPayload'
examples:
'Example 1':
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString}
summary: 'Create client with the following attributes: ClientId, ClientSecret. Admin only task.'
tags:
- Client
security:
-
bearerAuth: []
parameters: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ClientPayload'
/SASjsApi/drive/deploy:
post:
operationId: Deploy
@@ -524,61 +631,6 @@ paths:
-
bearerAuth: []
parameters: []
/SASjsApi/client/execute:
get:
operationId: ExecuteReturnRaw
responses:
'200':
description: Ok
content:
application/json:
schema:
type: string
description: "Trigger a SAS program using it's location in the _program parameter.\nEnable debugging using the _debug parameter.\nAdditional URL parameters are turned into SAS macro variables.\nAny files provided are placed into the session and\ncorresponding _WEBIN_XXX variables are created."
summary: 'Execute Stored Program, return raw content'
tags:
- STP
security:
-
bearerAuth: []
parameters:
-
in: query
name: _program
required: true
schema:
type: string
example: /Public/somefolder/some.file
post:
operationId: ExecuteReturnJson
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteReturnJsonResponse'
description: "Trigger a SAS program using it's location in the _program parameter.\nEnable debugging using the _debug parameter.\nAdditional URL parameters are turned into SAS macro variables.\nAny files provided are placed into the session and\ncorresponding _WEBIN_XXX variables are created."
summary: 'Execute Stored Program, return JSON'
tags:
- STP
security:
-
bearerAuth: []
parameters:
-
in: query
name: _program
required: false
schema:
type: string
example: /Public/somefolder/some.file
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteReturnJsonPayload'
/SASjsApi/user:
get:
operationId: GetAllUsers
@@ -885,113 +937,61 @@ paths:
format: double
type: number
example: '6789'
/SASjsApi/client:
post:
operationId: CreateClient
/SASjsApi/client/execute:
get:
operationId: ExecuteReturnRaw
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ClientPayload'
examples:
'Example 1':
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString}
summary: 'Create client with the following attributes: ClientId, ClientSecret. Admin only task.'
type: string
description: "Trigger a SAS program using it's location in the _program parameter.\nEnable debugging using the _debug parameter.\nAdditional URL parameters are turned into SAS macro variables.\nAny files provided are placed into the session and\ncorresponding _WEBIN_XXX variables are created."
summary: 'Execute Stored Program, return raw content'
tags:
- Client
- STP
security:
-
bearerAuth: []
parameters: []
parameters:
-
in: query
name: _program
required: true
schema:
type: string
example: /Public/somefolder/some.file
post:
operationId: ExecuteReturnJson
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteReturnJsonResponse'
description: "Trigger a SAS program using it's location in the _program parameter.\nEnable debugging using the _debug parameter.\nAdditional URL parameters are turned into SAS macro variables.\nAny files provided are placed into the session and\ncorresponding _WEBIN_XXX variables are created."
summary: 'Execute Stored Program, return JSON'
tags:
- STP
security:
-
bearerAuth: []
parameters:
-
in: query
name: _program
required: false
schema:
type: string
example: /Public/somefolder/some.file
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ClientPayload'
/SASjsApi/auth/authorize:
post:
operationId: Authorize
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizeResponse'
examples:
'Example 1':
value: {code: someRandomCryptoString}
summary: 'Accept a valid username/password, plus a CLIENT_ID, and return an AUTH_CODE'
tags:
- Auth
security: []
parameters: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizePayload'
/SASjsApi/auth/token:
post:
operationId: Token
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
examples:
'Example 1':
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
summary: 'Accepts client/auth code and returns access/refresh tokens'
tags:
- Auth
security: []
parameters: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TokenPayload'
/SASjsApi/auth/refresh:
post:
operationId: Refresh
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
examples:
'Example 1':
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
summary: 'Returns new access/refresh tokens'
tags:
- Auth
security:
-
bearerAuth: []
parameters: []
/SASjsApi/auth/logout:
post:
operationId: Logout
responses:
'204':
description: 'No content'
summary: 'Logout terminate access/refresh tokens and returns nothing'
tags:
- Auth
security:
-
bearerAuth: []
parameters: []
$ref: '#/components/schemas/ExecuteReturnJsonPayload'
servers:
-
url: /

View File

@@ -1,4 +1,6 @@
import path from 'path'
import express from 'express'
import morgan from 'morgan'
import webRouter from './routes/web'
import apiRouter from './routes/api'
@@ -8,7 +10,7 @@ const app = express()
app.use(express.json({ limit: '50mb' }))
app.use(morgan('tiny'))
app.use(express.static('public'))
app.use(express.static(path.join(__dirname, '../public')))
app.use('/', webRouter)
app.use('/SASjsApi', apiRouter)

View File

@@ -3,21 +3,22 @@ import PropTypes from 'prop-types'
import { CssBaseline, Box, TextField, Button } from '@mui/material'
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json'
}
const getAuthCode = async (credentials: any) => {
return fetch('/SASjsApi/auth/authorize', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers,
body: JSON.stringify(credentials)
}).then((data) => data.json())
}
const getTokens = async (payload: any) => {
return fetch('/SASjsApi/auth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers,
body: JSON.stringify(payload)
}).then((data) => data.json())
}

View File

@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
@@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}