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:
21
src/lib/helpers/config.ts
Normal file
21
src/lib/helpers/config.ts
Normal 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
|
||||
Reference in New Issue
Block a user