NathanaelAma / LoRDeckTrackerServer

Class methods should utilize this JS-0105
Anti-pattern
Minor
2 months agoa year old
Expected 'this' to be used by class method 'createCookie'
55    return { expiresIn, token: sign(dataStoredInToken, secretKey, { expiresIn }) };
56  }
57
58  public createCookie(tokenData: TokenData): string {59    return `Authorization=${tokenData.token}; HttpOnly; Max-Age=${tokenData.expiresIn};`;
60  }
61}
Expected 'this' to be used by class method 'createToken'
47    return findUser;
48  }
49
50  public createToken(user: User): TokenData {51    const dataStoredInToken: DataStoredInToken = { _id: user._id };
52    const secretKey: string = SECRET_KEY;
53    const expiresIn: number = 60 * 60;
Expected 'this' to be used by class async method 'index'
 17   * @param res - The response object.
 18   * @param next - The next function.
 19   */
 20  public index = async (req: Request, res: Response, next: NextFunction): Promise<void> => { 21    try {
 22      await res.status(200).json({ data: 'Hello World', message: 'DeckController' });
 23    } catch (error) {
Expected 'this' to be used by class async method 'getSummonerByPuuid'
35   * @returns A Promise that resolves to either an AccountDTO or SummonerDTO object.
36   * @throws {HttpException} if the puuid or region is empty, or if the region is not valid.
37   */
38  public async getSummonerByPuuid(puuid: string, region: LeagueRegion | RiotRegion): Promise<dto.AccountDTO | dto.SummonerDTO> {39    if (isEmpty(puuid)) throw new HttpException(400, 'puuid is empty');
40    if (isEmpty(region)) throw new HttpException(400, 'region is empty');
41
Expected 'this' to be used by class async method 'getSummonerByName'
20   * @returns {dto.SummonerDTO} A Promise that resolves to a SummonerDTO object.
21   * @throws {HttpException} if summonerName or region is empty.
22   */
23  public async getSummonerByName(summonerName: string, region: LeagueRegion): Promise<dto.SummonerDTO> {24    if (isEmpty(summonerName)) throw new HttpException(400, 'summonerName is empty');
25    if (isEmpty(region)) throw new HttpException(400, 'region is empty');
26