Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Feat/user broker #4

Merged
merged 11 commits into from
May 23, 2022
Prev Previous commit
Next Next commit
chore(Yellow): clean up and add user types
  • Loading branch information
mateonunez committed May 23, 2022
commit b4ff6368c86472518a118291ae1008758c5da311
1 change: 0 additions & 1 deletion backend/javascript/watchful/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const consumer =
(channel: Channel) =>
async (message: ConsumeMessage | null): Promise<void> => {
if (message) {
console.log('here');
const routingKey: string = message.fields.routingKey;
const rest: RouterProps = {
broker: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { User } from './user';

export type UserLoggedIn = {
event: string;
data: User;
timestamp: string;
};
10 changes: 10 additions & 0 deletions backend/javascript/watchful/src/lib/yellow/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type User = {
id: string;
name: string;
email: string;
email_verified_at: string;
created_at: string;
updated_at: string;
deleted_at: string;
};

7 changes: 4 additions & 3 deletions backend/javascript/watchful/src/router/yellow.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { UserLoggedIn } from '../lib/yellow/types/user-logged-in';
import { RouterProps } from './reducer';

const handler = async (args: RouterProps): Promise<void> => {
const { broker, options } = args;

console.log(`[ yellow router 🟨 ] Received message ${broker.message.content.toString()}`);

const { channel, message } = broker;

channel.ack(message);
const userLoggedInEvent: UserLoggedIn = JSON.parse(message.content.toString());

console.log(`[ yellow router 🟨 ] Received event ${userLoggedInEvent.event}`);

return new Promise(resolve => resolve());
};
Expand Down