-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.ts
145 lines (142 loc) · 4.05 KB
/
serverless.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import type { AWS } from "@serverless/typescript";
import dynamoDbTables from "./resources/dynamodb-tables";
import createOrg from "@functions/create-org";
import getOrg from "@functions/get-org";
import getWallet from "@functions/get-wallet";
import createWallet from "@functions/create-wallet";
import createNFT from "@functions/create-nft";
import getNFT from "@functions/get-nft";
import getAllNFTs from "@functions/get-all-nfts";
import getUserNFTs from "@functions/get-user-nfts";
import listNFT from "@functions/list-nft";
import getOrgWallet from "@functions/get-org-wallet";
import buyNFT from "@functions/buy-nft";
import getBalance from "@functions/get-balance";
const serverlessConfiguration: AWS = {
service: "polygon-api",
frameworkVersion: "2",
plugins: [
"serverless-esbuild",
"serverless-offline",
"serverless-dotenv-plugin",
"serverless-dynamodb-local",
],
provider: {
name: "aws",
runtime: "nodejs14.x",
apiGateway: {
minimumCompressionSize: 1024,
shouldStartNameWithService: true,
},
lambdaHashingVersion: "20201221",
iamRoleStatements: [
{
Effect: "Allow",
Action: [
"dynamodb:DescribeTable",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
],
Resource: [{ "Fn::GetAtt": ["XTable", "Arn"] }],
},
],
environment: {
AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1",
NODE_OPTIONS: "--enable-source-maps --stack-trace-limit=1000",
STAGE: "${self:custom.stage}",
DB_TABLE: "${self:custom.db_table}",
NETWORK: "${self:custom.environment.NETWORK.${self:custom.stage}}",
TEST_NETWORK: "${self:custom.environment.TEST_NETWORK}",
WALLET: "${self:custom.environment.WALLET.${self:custom.stage}}",
ALCHEMY_KEY:
"${self:custom.environment.ALCHEMY_KEY.${self:custom.stage}}",
TEST_ALCHEMY_KEY: "${self:custom.environment.TEST_ALCHEMY_KEY}",
NFT_STORAGE_API_KEY: "${self:custom.environment.NFT_STORAGE_API_KEY}",
OPENSEA_URL:
"${self:custom.environment.OPENSEA_URL.${self:custom.stage}}",
},
},
// import the function via paths
functions: {
createOrg,
getOrg,
getWallet,
createWallet,
createNFT,
getNFT,
getAllNFTs,
getUserNFTs,
listNFT,
getOrgWallet,
buyNFT,
getBalance
},
package: { individually: true },
custom: {
stage: "${opt:stage, self:provider.stage}",
db_table: "polygon-api-${opt:stage, self:provider.stage}",
table_throughputs: {
prod: 5,
default: 1,
},
table_throughput:
"${self:custom.TABLE_THROUGHPUTS.${self:custom.stage}, self:custom.table_throughputs.default}",
environment: {
NETWORK: {
dev: "maticmum",
prod: "mainnet",
},
TEST_NETWORK: "maticmum",
WALLET: { dev: "prod/wallet", prod: "prod/wallet" },
ALCHEMY_KEY: {
dev: "dev/alchemy",
prod: "prod/alchemy",
},
TEST_ALCHEMY_KEY: "dev/alchemy",
NFT_STORAGE_API_KEY: "prod/nftStorageApiKey",
OPENSEA_URL: {
dev: "https://testnets.opensea.io/assets/mumbai",
prod: "https://opensea.io/assets/matic",
},
},
dynamodb: {
stages: ["dev"],
start: {
port: 8008,
inMemory: true,
heapInitial: "200m",
heapMax: "1g",
migrate: true,
seed: true,
convertEmptyValues: true,
// Uncomment only if you already have a DynamoDB running locally
// noStart: true
},
},
["serverless-offline"]: {
httpPort: 3000,
babelOptions: {
presets: ["env"],
},
},
esbuild: {
bundle: true,
minify: false,
sourcemap: true,
exclude: ["aws-sdk"],
target: "node14",
define: { "require.resolve": undefined },
platform: "node",
concurrency: 10,
external: ["electron"],
},
},
resources: {
Resources: dynamoDbTables,
},
};
module.exports = serverlessConfiguration;