chore: rename src/ to server/
This commit is contained in:
39
server/config.ts
Normal file
39
server/config.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import chalk from 'chalk'
|
||||
|
||||
const default_data_path = "./thewhitesilk_data"
|
||||
let config = {
|
||||
data_path: default_data_path,
|
||||
server: {
|
||||
use: "http",
|
||||
/**
|
||||
* used in server.listen()
|
||||
*/
|
||||
listen: {
|
||||
port: 3601,
|
||||
host: "::",
|
||||
/**
|
||||
* setting ipv6Only to true will disable dual-stack support, i.e., binding to host :: won't make 0.0.0.0 be bound.
|
||||
*/
|
||||
ipv6Only: false,
|
||||
},
|
||||
/**
|
||||
* used in https.createServer()
|
||||
*/
|
||||
https: {
|
||||
key: default_data_path + '/key.pem',
|
||||
cert: default_data_path + '/cert.pem',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
try {
|
||||
config = JSON.parse(await fs.readFile('thewhitesilk_config.json', 'utf-8'))
|
||||
} catch (_e) {
|
||||
console.log(chalk.yellow("配置文件貌似不存在, 正在创建..."))
|
||||
await fs.writeFile('thewhitesilk_config.json', JSON.stringify(config))
|
||||
}
|
||||
|
||||
await fs.mkdir(config.data_path, { recursive: true })
|
||||
|
||||
export default config
|
||||
Reference in New Issue
Block a user