代码拉取完成,页面将自动刷新
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');
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。