-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrouter.ts
More file actions
44 lines (38 loc) · 882 Bytes
/
router.ts
File metadata and controls
44 lines (38 loc) · 882 Bytes
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
import { getSwapCoffeeStatus } from "./coffee.js";
export type BlockchainMode = "ping";
export type BlockchainRequest = {
mode?: BlockchainMode;
};
export type BlockchainResponse = {
ok: boolean;
mode: BlockchainMode;
provider: "swap.coffee";
status: {
swapCoffee: ReturnType<typeof getSwapCoffeeStatus>;
};
error?: string;
};
export async function handleBlockchainRequest(
request: BlockchainRequest = {},
): Promise<BlockchainResponse> {
const mode: BlockchainMode = request.mode ?? "ping";
if (mode === "ping") {
return {
ok: true,
mode,
provider: "swap.coffee",
status: {
swapCoffee: getSwapCoffeeStatus(),
},
};
}
return {
ok: false,
mode,
provider: "swap.coffee",
status: {
swapCoffee: getSwapCoffeeStatus(),
},
error: `Unsupported blockchain mode: ${mode}`,
};
}