added / fixed some types

This commit is contained in:
mrfry 2022-03-14 19:35:42 +01:00
parent 5f12284bb8
commit bc5c293539
41 changed files with 4378 additions and 8304 deletions

View file

@ -38,6 +38,7 @@ import https from 'https'
import cors from 'cors'
import cookieParser from 'cookie-parser'
import { v4 as uuidv4 } from 'uuid'
import type { Database } from 'better-sqlite3'
import logger from './utils/logger'
import utils from './utils/utils'
@ -51,7 +52,7 @@ const usersDBPath = './data/dbs/users.db'
const logFile = logger.logDir + logger.logFileName
const vlogFile = logger.vlogDir + logger.logFileName
function moveLogIfNotFromToday(path, to) {
function moveLogIfNotFromToday(path: string, to: string) {
if (utils.FileExists(path)) {
const today = new Date()
const stat = utils.statFile(path)
@ -89,10 +90,10 @@ interface Module {
export interface SetupData {
url: string
publicdirs: Array<string>
userDB?: any
userDB?: Database
nextdir?: string
httpServer: any
httpsServer: any
httpServer: http.Server
httpsServer: https.Server
}
if (!utils.FileExists(usersDBPath)) {
@ -122,7 +123,7 @@ try {
process.on('SIGINT', () => exit('SIGINT'))
process.on('SIGTERM', () => exit('SIGTERM'))
function exit(reason) {
function exit(reason: string) {
console.log()
logger.Log(`Exiting, reason: ${reason}`)
Object.keys(modules).forEach((key) => {
@ -152,7 +153,8 @@ const fullchainFile = '/etc/letsencrypt/live/frylabs.net/fullchain.pem'
const chainFile = '/etc/letsencrypt/live/frylabs.net/chain.pem'
let certsLoaded = false
let certs
let certs: { key: string; cert: string; ca: string }
if (
startHTTPS &&
utils.FileExists(privkeyFile) &&
@ -177,7 +179,7 @@ if (
const app = express()
const httpServer = http.createServer(app)
let httpsServer
let httpsServer: https.Server
if (certsLoaded) {
httpsServer = https.createServer(certs, app)
logger.Log('Listening on port: ' + httpsport + ' (https)')