-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the maps and add new API endpoint for desktop app (#520)
* Fix the maps and add new API endpoint for desktop app * Fix the tests
- Loading branch information
1 parent
0832e87
commit 3ac1796
Showing
9 changed files
with
70 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { logger } from "../../src/logger"; | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import config from "../../config"; | ||
import { generateExpireTimeStamps, getGMTTimeStamp } from "../../src/utils"; | ||
import { getStatsData } from "../../src/apis/coh3stats-api"; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
const statsPatchSelector = config.statsPatchSelector; | ||
const fromTimeStamp = getGMTTimeStamp(new Date(statsPatchSelector[config.latestPatch].from)); | ||
|
||
const data = await getStatsData( | ||
fromTimeStamp, | ||
"now", | ||
"mapStats", | ||
"https://coh3stats.com", | ||
["all"], | ||
{ | ||
Origin: "https://coh3stats.com", | ||
}, | ||
); | ||
|
||
const response = { | ||
latestPatchInfo: statsPatchSelector[config.latestPatch], | ||
mapStats: data, | ||
}; | ||
|
||
res | ||
.setHeader("Cache-Control", "public") | ||
.setHeader("Expires", generateExpireTimeStamps(7)) | ||
.status(200) | ||
.json(response); | ||
} catch (e) { | ||
logger.error(e); | ||
res.status(500).json({}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters