diff --git a/.env b/.env index 774db3e..ac30a9b 100755 --- a/.env +++ b/.env @@ -2,6 +2,9 @@ PORT=3001 LOGIN_REDIRECT_LOCATION=/premium USER_AGENT=WoWAnalyzer.com API +# you probably don't need to change this +WCL_HOST=https://www.warcraftlogs.com + # This way you can just use the `yarn start` server, though it won't be autorefreshing SPA_PROXY_HOST=http://localhost:3000 diff --git a/src/route/wcl/events.ts b/src/route/wcl/events.ts index 2e174e9..2b00e47 100644 --- a/src/route/wcl/events.ts +++ b/src/route/wcl/events.ts @@ -2,8 +2,10 @@ import * as api from "../../wcl/api"; import { gql } from "graphql-request"; import { ReportParams, camelCase, compress, wrapEndpoint } from "./common"; +const EVENT_LIMIT = 20000; + // TODO: migrate useAbilityIDs to true. -// requires frontend changes, but means we no longer need to compress the event response (probably) +// requires frontend changes, but is more efficient const eventQuery = gql` query getEvents( $code: String! @@ -12,6 +14,7 @@ const eventQuery = gql` $endTime: Float! $playerId: Int $filter: String + $limit: Int! ) { reportData { report(code: $code) { @@ -23,6 +26,7 @@ const eventQuery = gql` filterExpression: $filter includeResources: true useAbilityIDs: false + limit: $limit ) { data nextPageTimestamp @@ -67,6 +71,7 @@ const events = wrapEndpoint( endTime: number; playerId?: number; filter?: string; + limit: number; } >(eventQuery, { code: req.params.code, @@ -75,6 +80,7 @@ const events = wrapEndpoint( endTime: Number(req.query.end), playerId: req.query.actorid ? Number(req.query.actorid) : undefined, filter: req.query.filter, + limit: EVENT_LIMIT, }); const { data: events, nextPageTimestamp } = rawData.reportData.report.events; @@ -90,7 +96,10 @@ const events = wrapEndpoint( ); export default events; -export const eventsByType = wrapEndpoint( +export const eventsByType = wrapEndpoint< + EventsQuery, + ReportParams & { type: string } +>( "/i/v1/report/events/:type/:code", "wcl-events", async (req) => { @@ -104,6 +113,7 @@ export const eventsByType = wrapEndpoint(eventQuery, { type: req.params.type ? camelCase(req.params.type) : undefined, @@ -113,6 +123,7 @@ export const eventsByType = wrapEndpoint { `${process.env.WCL_CLIENT_ID}:${process.env.WCL_CLIENT_SECRET}`, ).toString("base64"); const response = await axios.postForm( - "https://www.warcraftlogs.com/oauth/token", + `${process.env.WCL_HOST}/oauth/token`, { grant_type: "client_credentials", }, @@ -37,7 +37,7 @@ export async function query( ): Promise { let token = await getToken(); const run = () => - request("https://www.warcraftlogs.com/api/v2/client", gql, variables, { + request(`${process.env.WCL_HOST}/api/v2/client`, gql, variables, { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "Accept-Encoding": "deflate,gzip",