import { Injectable } from '@nestjs/common' ; import { JwtService } from '@nestjs/jwt' ; @ Injectable ( ) export class AuthService { constructor ( private readonly jwtService ) { } async validateUser ( username , pass ) { const user = { name : 'walker123' , password : '123321' } ; if ( user && user . password ) { const { password , ... result } = user ; return result ; } return null ; } async login ( user ) { const payload = { username : user . username , sub : user . userId } ; return { access_token : this . jwtService . sign ( payload ) , } ; } }