startgg-helper-node
Version:
A set of functions and classes useful to communicate with the start.gg API.
22 lines (19 loc) • 596 B
JavaScript
import { GraphQLClient } from 'graphql-request';
const publicEndpoint = 'https://api.start.gg/gql/alpha';
const secretEndpoint = 'https://www.start.gg/api/-/gql';
const headers = {
"client-version": "21",
'Content-Type': 'application/json'
}
/**
* @param {string?} token
*/
export function createClient(token){
return token ?
new GraphQLClient(publicEndpoint, {headers: {
Authorization: token.startsWith("Bearer ") ? token : ("Bearer " + token)
}}) :
new GraphQLClient(secretEndpoint, {
headers: headers
});
}