This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
import { fortniteAPI } from '../tools/auth' | ||
import { CustomError } from '../models/error' | ||
import { Response, Request } from 'express' | ||
import { Request, Response } from "express"; | ||
import { CustomError } from "../models/error"; | ||
import { fortniteAPI } from "../tools/auth"; | ||
|
||
export function getStatsPVE (req: Request, res: Response) { | ||
let username = req.params.username | ||
fortniteAPI.login() | ||
.then(() => { | ||
fortniteAPI.getStatsPVE(username) | ||
.then((stats) => { | ||
res.json(stats) | ||
}) | ||
.catch((err) => { | ||
if (err === 'Player Not Found') { | ||
res.status(404).send(new CustomError(404, err)) | ||
} /* istanbul ignore next */ else if (err === 'No Data') { | ||
res.status(400).send(new CustomError(400, err)) | ||
} else { | ||
/* istanbul ignore next */ | ||
res.status(500).send(new CustomError(500, err)) | ||
} | ||
}) | ||
}) | ||
/* istanbul ignore next */ | ||
export function getStatsPVE(req: Request, res: Response) { | ||
const username = req.params.username; | ||
fortniteAPI.login().then(() => { | ||
fortniteAPI | ||
.getStatsPVE(username) | ||
.then((stats) => { | ||
res.json(stats); | ||
}) | ||
.catch((err) => { | ||
if (err === "Player Not Found") { | ||
res.status(404).send(new CustomError(404, err)); | ||
} else if (err === "No Data") { | ||
/* istanbul ignore next */ res | ||
.status(400) | ||
.send(new CustomError(400, err)); | ||
} else { | ||
/* istanbul ignore next */ | ||
res.status(500).send(new CustomError(500, err)); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
export function getFortnitePVEInfo (req: Request, res: Response) { | ||
let language = req.params.lang || 'en' | ||
fortniteAPI.login() | ||
.then(() => { | ||
fortniteAPI.getFortnitePVEInfo(language) | ||
.then((store) => { | ||
res.json(store) | ||
}) | ||
.catch((err) => { | ||
/* istanbul ignore next */ | ||
res.status(500).send(new CustomError(500, err)) | ||
}) | ||
}) | ||
export function getFortnitePVEInfo(req: Request, res: Response) { | ||
const language = req.params.lang || "en"; | ||
fortniteAPI.login().then(() => { | ||
fortniteAPI | ||
.getFortnitePVEInfo(language) | ||
.then((store) => { | ||
res.json(store); | ||
}) | ||
.catch((err) => { | ||
/* istanbul ignore next */ | ||
res.status(500).send(new CustomError(500, err)); | ||
}); | ||
}); | ||
} |