|
1 | 1 | (* HTTP Route Handlers *) |
2 | 2 |
|
3 | 3 | (serveStatic: StatusPost API) { |
4 | | - <Extract> the <file> from the <pathParameters: file>. |
5 | | - <Create> the <template-path> with "static/" ++ <file>. |
6 | | - <Transform> the <content> from the <template: template-path>. |
7 | | - <Return> an <OK: status> with <content>. |
| 4 | + Extract the <file> from the <pathParameters: file>. |
| 5 | + Create the <template-path> with "static/" ++ <file>. |
| 6 | + Transform the <content> from the <template: template-path>. |
| 7 | + Return an <OK: status> with <content>. |
8 | 8 | } |
9 | 9 |
|
10 | 10 | (homePage: StatusPost API) { |
11 | | - <Retrieve> the <all-messages> from the <message-repository>. |
12 | | - <Extract> the <recent-messages: 0-19> from the <all-messages>. |
13 | | - <Transform> the <html> from the <template: index.html>. |
14 | | - <Return> an <OK: status> with <html>. |
| 11 | + Retrieve the <all-messages> from the <message-repository>. |
| 12 | + Extract the <recent-messages: 0-19> from the <all-messages>. |
| 13 | + Transform the <html> from the <template: index.html>. |
| 14 | + Return an <OK: status> with <html>. |
15 | 15 | } |
16 | 16 |
|
17 | 17 | (getMessages: StatusPost API) { |
18 | | - <Retrieve> the <all-messages> from the <message-repository>. |
19 | | - <Extract> the <recent-messages: 0-19> from the <all-messages>. |
20 | | - <Return> an <OK: status> with <recent-messages>. |
| 18 | + Retrieve the <all-messages> from the <message-repository>. |
| 19 | + Extract the <recent-messages: 0-19> from the <all-messages>. |
| 20 | + Return an <OK: status> with <recent-messages>. |
21 | 21 | } |
22 | 22 |
|
23 | 23 | (postMessage: StatusPost API) { |
24 | | - <Extract> the <body> from the <request: body>. |
25 | | - <Extract> the <message-text: message> from the <body>. |
26 | | - <Create> the <message: Message> with { |
| 24 | + Extract the <body> from the <request: body>. |
| 25 | + Extract the <message-text: message> from the <body>. |
| 26 | + Create the <message: Message> with { |
27 | 27 | message: <message-text>, |
28 | 28 | createdAt: <now> |
29 | 29 | }. |
30 | | - <Store> the <message> into the <message-repository>. |
31 | | - <Broadcast> the <message> to the <websocket>. |
32 | | - <Return> a <Created: status> with <message>. |
| 30 | + Store the <message> into the <message-repository>. |
| 31 | + Broadcast the <message> to the <websocket>. |
| 32 | + Return a <Created: status> with <message>. |
| 33 | +} |
| 34 | + |
| 35 | +(getMetrics: StatusPost API) { |
| 36 | + Return an <OK: status> with <metrics: prometheus>. |
33 | 37 | } |
34 | 38 |
|
35 | 39 | (* Repository Observer - cleanup when message count exceeds 40 *) |
36 | 40 | (Cleanup Messages: message-repository Observer) when <message-repository: count> > 40 { |
37 | | - <Retrieve> the <all-messages> from the <message-repository>. |
38 | | - <Extract> the <keep-messages: 0-19> from the <all-messages>. |
39 | | - <Clear> the <all> from the <message-repository>. |
40 | | - <Store> the <keep-messages> into the <message-repository>. |
41 | | - <Log> "Cleaned up messages, kept last 20" to the <console>. |
42 | | - <Return> an <OK: status> for the <cleanup>. |
| 41 | + Retrieve the <all-messages> from the <message-repository>. |
| 42 | + Extract the <keep-messages: 0-19> from the <all-messages>. |
| 43 | + Clear the <all> from the <message-repository>. |
| 44 | + Store the <keep-messages> into the <message-repository>. |
| 45 | + Log "Cleaned up messages, kept last 20" to the <console>. |
| 46 | + Return an <OK: status> for the <cleanup>. |
43 | 47 | } |
0 commit comments