Skip to content

Instantly share code, notes, and snippets.

@QuadradS
Created February 17, 2020 11:19
Show Gist options
  • Save QuadradS/3e2a8afcfff637652f1557d805c2e7a4 to your computer and use it in GitHub Desktop.
Save QuadradS/3e2a8afcfff637652f1557d805c2e7a4 to your computer and use it in GitHub Desktop.
Example of user service
import { AuthJwtPayloadDTO, ChangePasswordByRecoveryTokenDTO, UserResponseDTO } from 'goin-shared'
import { passportApi } from '../../utils/request.util'
import { UserService } from '../index'
import { PassportApiPaths } from '../../enums/microservices-endpoints'
import { ComponentByName } from 'ts-framework'
import Injectables from '../../enums/injectables'
@ComponentByName(Injectables.services.user)
export default class DefaultService implements UserService {
getCurrentUser(authJwtPayload: AuthJwtPayloadDTO): Promise<UserResponseDTO> {
return passportApi.get(PassportApiPaths.auth.loginByCredentials, { headers: { user: String(authJwtPayload) } })
}
updateUserPasswordByRecoveryToken(dto: ChangePasswordByRecoveryTokenDTO): Promise<void> {
return passportApi.patch(PassportApiPaths.user.changePasswordByRecoveryToken, dto)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment