3 Star 0 Fork 1

mirrors_hack-chat/main

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.mjs 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
import {
existsSync,
readFileSync,
} from 'node:fs';
import {
Low,
JSONFile,
} from 'lowdb';
import {
CoreApp,
} from 'hackchat-server';
import {
ChannelCheckInterval,
} from './commands/utility/_Constants.js';
import {
purgeInactiveChannels,
} from './commands/utility/_Channels.js';
// required file paths
const SessionLocation = './session.key';
const SaltLocation = './salt.key';
const AppConfigLocation = './config.json';
// verify required files exist
if (existsSync(SessionLocation) === false) {
throw Error('Missing session key, you may need to run: npm run config');
}
if (existsSync(SaltLocation) === false) {
throw Error('Missing salt key, you may need to run: npm run config');
}
if (existsSync(AppConfigLocation) === false) {
throw Error('Missing config, you may need to run: npm run config');
}
// build main hack chat server
const server = new CoreApp({
configPath: './.hcserver.json',
logErrDetailed: true,
lang: 'en',
});
// load sessoin key data
server.sessionKey = readFileSync(SessionLocation);
// load salt key data
server.saltKey = readFileSync(SaltLocation);
// load the configuration data
const adapter = new JSONFile(AppConfigLocation);
server.appConfig = new Low(adapter);
await server.appConfig.read();
// create channel memory management job
setInterval(() => {
purgeInactiveChannels(server.appConfig.data);
}, ChannelCheckInterval);
// @todo create storage management job
// start the server
server.init();
console.log('Websocket server ready');
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_hack-chat/main.git
git@gitee.com:mirrors_hack-chat/main.git
mirrors_hack-chat
main
main
master

搜索帮助