import { Injectable } from '@nestjs/common' ; import { sign } from 'jsonwebtoken' ; import { UserService } from '../shared/user.service' ; import { Payload } from '../types/payload' ; @ Injectable ( ) export class AuthService { constructor ( private userService ) { } async signPayload ( payload ) { return sign ( payload , process . env . SECRET_KEY , { expiresIn : '12h' } ) ; } async validateUser ( payload ) { return await this . userService . findByPayload ( payload ) ; } }