-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsst.config.ts
62 lines (56 loc) · 1.36 KB
/
sst.config.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
import type { SSTConfig } from 'sst';
import { Api, Function } from 'sst/constructs';
export default {
config() {
return {
name: 'gasilon',
region: 'ap-south-1',
};
},
stacks(app) {
app.setDefaultFunctionProps({
runtime: 'nodejs18.x',
nodejs: { format: 'cjs' },
});
app.stack(({ stack, app }) => {
const domain = domainFromStage(app.stage);
const gasilon = new Function(stack, 'gasilon', {
handler: 'lambda/index.handler',
timeout: '120 seconds',
copyFiles: [{ from: './config.json' }],
environment: {
ENVIRONMENT: process.env.ENVIRONMENT,
SOLANA_SECRET_KEY: process.env.SOLANA_SECRET_KEY,
REDIS_USERNAME: process.env.REDIS_USERNAME,
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
REDIS_HOST: process.env.REDIS_HOST,
},
});
const API = new Api(stack, 'api', {
cors: {
allowOrigins: ['*'],
},
routes: {
'GET /': gasilon,
'POST /': gasilon,
'GET /{proxy+}': gasilon,
'POST /{proxy+}': gasilon,
},
customDomain: domain,
});
stack.addOutputs({
url: API.url,
domain: API.customDomainUrl,
});
});
},
} satisfies SSTConfig;
const apiAlias = {
production: 'api.',
staging: 'api-stg.',
development: 'api-dev.',
};
export const domainFromStage = (stage: string) => {
const prefix = apiAlias[stage] || `api-${stage}.`;
return `${prefix}gasilon.com`;
};