import { Injectable } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { map , mapTo } from 'rxjs/operators' ; import { api as userTypes } from '@grpc-proto/user/user.types' ; import { api as userApi } from '@grpc-proto/user/user' ; import { UserDataFinder } from './dal/data-finders/UserDataFinder' ; import { UserDataProducer } from './dal/data-producers/UserDataProducer' ; import { UserDataRemover } from './dal/data-removers/UserDataRemover' ; import { UserDataUpdater } from './dal/data-updaters/UserDataUpdater' ; @ Injectable ( ) export class UserService { constructor ( private readonly userDataFinder , private readonly userDataProducer , private readonly userDataUpdater , private readonly userDataRemover ) { } public createUser ( data ) { return this . userDataProducer . createUser ( data ) ; } public updateUser ( data , id ) { return this . userDataUpdater . updateUser ( data , id ) . pipe ( mapTo ( null ) ) ; } public deleteUser ( id ) { return this . userDataRemover . deleteUser ( id ) . pipe ( mapTo ( null ) ) ; } public getUser ( id ) { return this . userDataFinder . getUserOne ( id ) ; } public getUsersAll ( ) { return this . userDataFinder . getUsersAll ( ) . pipe ( map ( users => ( { users } ) ) ) ; } public verifyUser ( data ) { return this . userDataFinder . getUserByConditions ( { ... data } ) ; } }