katoikia-app/api-gateway/src/app.service.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-06-29 09:23:07 +00:00
import { Injectable, Inject } from '@nestjs/common';
2022-06-29 02:30:10 +00:00
import { ClientProxy } from "@nestjs/microservices";
import { map } from "rxjs/operators";
@Injectable()
export class AppService {
constructor(
2022-06-29 09:23:07 +00:00
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
2022-06-29 02:30:10 +00:00
) {}
2022-06-29 09:23:07 +00:00
//POST parameter from API
createUser(dni: string, name: string, last_name: string, email: string, phone: number
, password: string , user_type: string, status: string, date_entry: Date){
const pattern = { cmd: 'createUser' };
const payload = {dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: password, user_type: user_type, status: status, date_entry: date_entry};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message})),
);
}
2022-06-29 02:30:10 +00:00
2022-06-29 09:23:07 +00:00
allUsers(){
const pattern = { cmd: 'findAllUsers' };
2022-06-29 02:30:10 +00:00
const payload = {};
2022-06-29 09:23:07 +00:00
return this.clientUserApp
.send<string>(pattern, payload)
2022-06-29 02:30:10 +00:00
.pipe(
2022-06-29 09:23:07 +00:00
map((message: string) => ({ message})),
2022-06-29 02:30:10 +00:00
);
}
2022-06-29 09:23:07 +00:00
2022-06-29 02:30:10 +00:00
}