-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.ts
64 lines (57 loc) · 1.92 KB
/
client.ts
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
55
56
57
58
59
60
61
62
63
64
// This is a simple client that sends a create restaurant command and a change restaurant menu command to the server
// Create a restaurant command JSON
const createRestaurantCommandJson = `
{
"commandId": "691490bb-c4d3-45b8-99d0-efcf20e353ag",
"decider": "Restaurant",
"kind": "CreateRestaurantCommand",
"id": "691490bb-c4d3-45b8-99d0-efcf20e353ao",
"name": "Eat at Joes",
"menu": {
"menuItems": [
{"menuItemId": "1", "name": "Salad", "price": "8.99"},
{"menuItemId": "2", "name": "Soup", "price": "6.99"},
{"menuItemId": "3", "name": "Steak", "price": "19.99"}
],
"menuId": "34110e19-ca72-45e7-b969-61bebf54da08",
"cuisine": "SERBIAN"
}
}
`;
// Change restaurant menu command JSON
const changeRestaurantMenuCommandJson = `
{
"commandId": "691490bb-c4d3-45b8-99d0-efcf20e353ag",
"decider": "Restaurant",
"kind": "ChangeRestaurantMenuCommand",
"id": "691490bb-c4d3-45b8-99d0-efcf20e353ao",
"menu": {
"menuItems": [
{"menuItemId": "1", "name": "Salad", "price": "8.99"},
{"menuItemId": "2", "name": "Soup", "price": "6.99"},
{"menuItemId": "3", "name": "Steak", "price": "19.99"}
],
"menuId": "34110e19-ca72-45e7-b969-61bebf54da08",
"cuisine": "SERBIAN"
}
}
`;
// Send the create restaurant command to the server
const createRestaurantCommandResult = await fetch("http://localhost:8000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: createRestaurantCommandJson,
});
console.log(createRestaurantCommandResult);
// Send the change restaurant menu command to the server
const changeRestaurantMenuCommandResult = await fetch("http://localhost:8000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: changeRestaurantMenuCommandJson,
});
console.log(changeRestaurantMenuCommandResult);
// Run the client : `deno run --allow-net client.ts`