-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
64 lines (57 loc) · 1.62 KB
/
index.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
import * as aws from '@pulumi/aws';
import * as awsx from '@pulumi/awsx';
import * as pulumi from '@pulumi/pulumi';
import { faucetCallback, statsCallback } from './routes';
const config = new pulumi.Config();
export const dashNetwork = config.get('dashNetwork');
export const faucetMnemonic = config.get("faucetMnemonic");
export const blockExplorerUrl = config.get("blockExplorerUrl");
export const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Allow-Methods": "OPTIONS,POST,GET"
}
const faucetHandler = new aws.lambda.CallbackFunction("faucet-handler", {
runtime: "nodejs10.x",
memorySize: 256,
callback: faucetCallback,
});
const statsHandler = new aws.lambda.CallbackFunction("stats-handler", {
runtime: "nodejs10.x",
memorySize: 256,
callback: statsCallback,
});
const faucetApi = new awsx.apigateway.API("faucet-api", {
routes: [
{
path: "/",
method: "OPTIONS",
eventHandler: async () => ({
statusCode: 200,
headers: corsHeaders,
body: 'All good'
})
},
{
path: "/",
method: "GET",
eventHandler: faucetHandler,
},
{
path: "/stats",
method: "GET",
eventHandler: statsHandler,
},
],
});
const requestsTable = new aws.dynamodb.Table("requests-table", {
hashKey: "id",
billingMode: "PAY_PER_REQUEST",
attributes: [
{ name: "id", type: "S" },
],
});
export const url = faucetApi.url;
export const apiId = faucetApi.deployment.id;
export const restApi = faucetApi.deployment.restApi;
export const requestsTableName = requestsTable.name;