Fix the config in the npm lib?
Some checks failed
Publish JS SDK / docker (push) Failing after 10s

This commit is contained in:
Braydon 2024-09-10 17:19:24 -04:00
parent 4010b141f5
commit 45e017d840
2 changed files with 10 additions and 8 deletions

@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { Snowflake } from "@/types/snowflake";
import { TetherConfig } from "@/types/config";
import { defaultConfig, TetherConfig } from "@/types/config";
import { UserStatusPacket } from "@/types/socket";
import { DiscordUser } from "@/types/user/discord-user";
@ -10,17 +10,13 @@ import { DiscordUser } from "@/types/user/discord-user";
* the given snowflake.
*
* @param snowflake the user's snowflake
* @param config the Tether config
* @param config the optional Tether config
*/
export const useTetherWS = (
snowflake: Snowflake,
config: TetherConfig = {
endpoint: "api.usetether.rest",
secure: true,
debug: false,
}
config?: TetherConfig | undefined
): DiscordUser | undefined => {
const { endpoint, secure, debug } = config;
const { endpoint, secure, debug } = { ...defaultConfig, ...config };
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
const [user, setUser] = useState<DiscordUser | undefined>();

@ -1,3 +1,9 @@
export const defaultConfig: TetherConfig = {
endpoint: "api.usetether.rest",
secure: true,
debug: false,
};
export type TetherConfig = {
/**
* The API endpoint to connect to.