From f82e874ac0d90109172df95623927d5fb4969a46 Mon Sep 17 00:00:00 2001 From: marlonerler Date: Fri, 5 Jul 2024 19:58:42 +0200 Subject: [PATCH] replace Fs API where possible --- config-handler.ts | 6 ++---- index.ts | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/config-handler.ts b/config-handler.ts index 30c61c5..80c90b9 100644 --- a/config-handler.ts +++ b/config-handler.ts @@ -1,5 +1,3 @@ -import Fs from "fs/promises"; - // CONFIG const configPath = "config.json"; @@ -12,12 +10,12 @@ export const defaultConfig = { // METHODS export async function createConfig() { const configString = JSON.stringify(defaultConfig, null, 4); - await Fs.writeFile(configPath, configString); + await Bun.write(configPath, configString); } export async function getConfig(): Promise { try { - const configString = (await Fs.readFile(configPath)).toString(); + const configString = await Bun.file(configPath).text(); const configObject = JSON.parse(configString); Object.keys(defaultConfig).forEach((key) => { diff --git a/index.ts b/index.ts index 15baf74..770c364 100755 --- a/index.ts +++ b/index.ts @@ -1,22 +1,18 @@ #!/usr/bin/env bun -import { ServerWebSocket, write } from "bun"; import { addConnection, - connectServer, connectServers, - connectedClientCount, forgetConnection, getStats, processMessage, - subscribeChannel, - subscriptions, } from "./websocket-handler"; import { writeInfo, writeStat, writeSuccess } from "./utility"; import Colors from "colors"; import IP from "ip"; import Path from "path"; +import { ServerWebSocket } from "bun"; import { getConfig } from "./config-handler"; // CONFIG