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

fix: refactored + removed unused package

This commit is contained in:
Saad Jutt
2022-02-15 04:04:38 +05:00
parent de47d78a00
commit d7e1aca7e3
6 changed files with 109 additions and 8570 deletions

8623
api/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,6 @@
"start": "nodemon ./src/server.ts",
"build": "rimraf build && tsc",
"swagger": "tsoa spec",
"semantic-release": "semantic-release -d",
"prepare": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true",
"test": "mkdir -p tmp && mkdir -p ../web/build && jest --silent --coverage",
"lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
@@ -56,7 +55,7 @@
"morgan": "^1.10.0",
"multer": "^1.4.3",
"swagger-ui-express": "^4.1.6",
"tsoa": "^3.14.0"
"tsoa": "3.14.1"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.2",
@@ -77,7 +76,6 @@
"pkg": "^5.4.1",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.3",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",

View File

@@ -398,7 +398,7 @@ components:
bearerFormat: JWT
info:
title: api
version: 0.0.1
version: 0.0.2
description: 'Api of SASjs server'
contact:
name: '4GL Ltd'

View File

@@ -1,8 +1,7 @@
import path from 'path'
import { createServer } from 'https'
import { readFile } from '@sasjs/utils'
import appPromise from './app'
import { getCertificates } from './utils'
appPromise.then(async (app) => {
const protocol = process.env.PROTOCOL ?? 'http'
@@ -25,16 +24,3 @@ appPromise.then(async (app) => {
})
}
})
const getCertificates = async () => {
const privkey = process.env.PRIVATE_KEY ?? 'privkey.pem'
const fullchain = process.env.FULL_CHAIN ?? 'fullchain.pem'
const keyPath = path.join(process.cwd(), privkey)
const certPath = path.join(process.cwd(), fullchain)
const key = await readFile(keyPath)
const cert = await readFile(certPath)
return { key, cert }
}

View File

@@ -0,0 +1,33 @@
import path from 'path'
import { fileExists, getString, readFile } from '@sasjs/utils'
export const getCertificates = async () => {
const { PRIVATE_KEY, FULL_CHAIN } = process.env
const keyPath = PRIVATE_KEY ?? (await getFileInput('Private Key (PEM)'))
const certPath = FULL_CHAIN ?? (await getFileInput('Full Chain (PEM)'))
const key = await readFile(keyPath)
const cert = await readFile(certPath)
return { key, cert }
}
const getFileInput = async (filename: string): Promise<string> => {
const validator = async (filePath: string) => {
if (!filePath) return `Path to ${filename} is required.`
if (!(await fileExists(path.join(process.cwd(), filePath)))) {
return 'No file found at provided path.'
}
return true
}
const targetName = await getString(
`Please enter path to ${filename} (relative path): `,
validator
)
return targetName
}

View File

@@ -3,6 +3,7 @@ export * from './file'
export * from './generateAccessToken'
export * from './generateAuthCode'
export * from './generateRefreshToken'
export * from './getCertificates'
export * from './getDesktopFields'
export * from './removeTokensInDB'
export * from './saveTokensInDB'