diff --git a/src/app/api/zeus/index.ts b/src/app/api/zeus/index.ts index 03ac9f2..1eb116f 100644 --- a/src/app/api/zeus/index.ts +++ b/src/app/api/zeus/index.ts @@ -7,14 +7,22 @@ export const HOST = "http://localhost:8080/v1/graphql" export const HEADERS = {} -import { createClient, type Sink } from 'graphql-ws'; // keep +import { createClient, type Sink } from 'graphql-ws'; export const apiSubscription = (options: chainOptions) => { - // const headers : Record = {}; + const h = options[1]?.headers; + if (h === undefined) { + throw new Error('auth headers required'); + } + // const passedHeaders : HeadersInit = /*options[1]?.headers ??*/ new Headers(); + // const h = {'authorization':passedHeaders['authorization'] ?? '','x-hasura-role':passedHeaders['x-hasura-role'] ?? ''}; + // const empty : [string, string][] = []; + // const headers : HeadersInit = passedHeaders ? passedHeaders : empty; const client = createClient({ url: String(options[0]), - // connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries()), + + connectionParams: h !== undefined ? Object.fromEntries(new Headers(h as HeadersInit).entries()) : undefined, }); const ws = new Proxy( @@ -81685,4 +81693,4 @@ type ZEUS_VARIABLES = { ["vouches_var_pop_order_by"]: ValueTypes["vouches_var_pop_order_by"]; ["vouches_var_samp_order_by"]: ValueTypes["vouches_var_samp_order_by"]; ["vouches_variance_order_by"]: ValueTypes["vouches_variance_order_by"]; -} \ No newline at end of file +}