-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
56 lines (49 loc) · 1 KB
/
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
import * as process from 'process';
interface Config {
region: 'eu-central-1' | 'us-east-1';
dynamoDb: {
tableName: string;
port: number;
};
s3: {
deploymentBucket: string;
port: number;
};
isOffline?: boolean;
}
const defaultConfig: Config = {
region: 'eu-central-1',
dynamoDb: {
tableName: 'items',
port: 3001,
},
s3: {
deploymentBucket: 'aws-serverless-sandbox-1237841654', // use custom hash to avoid conflicts
port: 8000,
},
};
const configProduction: Config = {
...defaultConfig,
isOffline: false,
};
const configLocal: Config = {
...defaultConfig,
isOffline: true,
};
export const getConfig = (
stage = process.env.STAGE,
): Config & { stage: 'offline' | 'production' } => {
if (stage === 'offline') {
return {
...configLocal,
stage: 'offline',
};
}
if (stage === 'production') {
return {
...configProduction,
stage: 'production',
};
}
throw new Error(`No available config for stage ${stage}`);
};