-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (48 loc) · 1.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import UserService from './services/user.service.js';
import EmailService from './services/email.service.js';
import AuthService from './services/auth.service.js';
async function startApp() {
// Start services
await UserService.start();
await EmailService.start();
await AuthService.start();
try {
// Simulate user creation
await UserService.call('user.createUser', {
name: 'angela',
email: 'angela@gmail.com',
});
const user = await UserService.call('user.createUser', {
name: 'John Doe',
email: 'john@gmail.com',
});
console.log('Created User:', user);
const users = await UserService.call('user.getUsers');
console.log('All Users:', users);
// Simulate sending email
await EmailService.call('email.sendEmail', {
to: user.email,
subject: `Welcome ${user.name}`,
content: 'Welcome to our platform!',
});
// Simulate auth
const authResponse = await AuthService.call('auth.authUser', {
username: 'admin',
password: 'password',
});
console.log('Auth Response:', authResponse);
const invalidAuthResponse = await AuthService.call('auth.authUser', {
username: 'admin',
password: 'wrongpassword',
});
console.log('Invalid Auth Response:', invalidAuthResponse);
} catch (error) {
console.error('Error occurred!', error);
} finally {
// Stop the services
await UserService.stop();
await EmailService.stop();
await AuthService.stop();
}
}
startApp();