@@ -2,6 +2,7 @@ import { Inject, Injectable, Logger } from '@nestjs/common';
22import { JwtService } from '@nestjs/jwt' ;
33import axios from 'axios' ;
44import type { Request , Response } from 'express' ;
5+ import ms from 'ms' ;
56
67import { CreateUser } from '@nbw/database' ;
78import type { UserDocument } from '@nbw/database' ;
@@ -22,18 +23,18 @@ export class AuthService {
2223 @Inject ( JwtService )
2324 private readonly jwtService : JwtService ,
2425 @Inject ( 'COOKIE_EXPIRES_IN' )
25- private readonly COOKIE_EXPIRES_IN : string ,
26+ private readonly COOKIE_EXPIRES_IN : ms . StringValue ,
2627 @Inject ( 'FRONTEND_URL' )
2728 private readonly FRONTEND_URL : string ,
2829
2930 @Inject ( 'JWT_SECRET' )
3031 private readonly JWT_SECRET : string ,
3132 @Inject ( 'JWT_EXPIRES_IN' )
32- private readonly JWT_EXPIRES_IN : string ,
33+ private readonly JWT_EXPIRES_IN : ms . StringValue ,
3334 @Inject ( 'JWT_REFRESH_SECRET' )
3435 private readonly JWT_REFRESH_SECRET : string ,
3536 @Inject ( 'JWT_REFRESH_EXPIRES_IN' )
36- private readonly JWT_REFRESH_EXPIRES_IN : string ,
37+ private readonly JWT_REFRESH_EXPIRES_IN : ms . StringValue ,
3738 @Inject ( 'APP_DOMAIN' )
3839 private readonly APP_DOMAIN ?: string ,
3940 ) { }
@@ -171,11 +172,11 @@ export class AuthService {
171172
172173 public async createJwtPayload ( payload : TokenPayload ) : Promise < Tokens > {
173174 const [ accessToken , refreshToken ] = await Promise . all ( [
174- this . jwtService . signAsync ( payload , {
175+ this . jwtService . signAsync < TokenPayload > ( payload , {
175176 secret : this . JWT_SECRET ,
176177 expiresIn : this . JWT_EXPIRES_IN ,
177178 } ) ,
178- this . jwtService . signAsync ( payload , {
179+ this . jwtService . signAsync < TokenPayload > ( payload , {
179180 secret : this . JWT_REFRESH_SECRET ,
180181 expiresIn : this . JWT_REFRESH_EXPIRES_IN ,
181182 } ) ,
@@ -199,7 +200,7 @@ export class AuthService {
199200
200201 const frontEndURL = this . FRONTEND_URL ;
201202 const domain = this . APP_DOMAIN ;
202- const maxAge = parseInt ( this . COOKIE_EXPIRES_IN ) * 1000 ;
203+ const maxAge = ms ( this . COOKIE_EXPIRES_IN ) * 1000 ;
203204
204205 res . cookie ( 'token' , token . access_token , {
205206 domain : domain ,
0 commit comments