1
0
mirror of https://github.com/seejohnrun/haste-server.git synced 2025-12-18 20:11:28 +00:00

[SAT-1957] Convert haste-server to Typescript

This commit is contained in:
Yusuf Yilmaz
2022-05-27 11:00:09 +02:00
parent 68f6fe2b96
commit 9f45927593
38 changed files with 9825 additions and 1701 deletions

21
src/lib/helpers/config.ts Normal file
View File

@@ -0,0 +1,21 @@
import * as fs from 'fs'
import { Config } from '../../types/config'
const getConfig = (): Config => {
const configPath = process.argv.length <= 2 ? 'config.json' : process.argv[2]
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'))
config.port = (process.env.PORT || config.port || 7777) as number
config.host = process.env.HOST || config.host || 'localhost'
if (!config.storage) {
config.storage = { type: 'file' }
}
if (!config.storage.type) {
config.storage.type = 'file'
}
return config
}
export default getConfig