this
JS-010555 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}
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;
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) {
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
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
If a class method does not use this
, it can sometimes be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (MyClass.callStaticMethod())
class Person {
sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
const person = new Person();
person.sayHi();
class Person {
static sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
Person.sayHi();