-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
39 lines (37 loc) · 890 Bytes
/
config.js
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
class HufferConfig {
/**
* @typedef config {
* aws:[],
* directories: {
* // Images
* "/media/": {
* namespace: "hdn-media",
* interceptors: [()=>{}]
* },
* }
* }
* @param config config
*/
constructor(config) {
this.aws = config.aws;
this.directories = config.directories;
this.aws.forEach((c) => {
c.CloudFrontOriginBucket = c.CloudFrontOrigin.replace(
"s3://",
""
).replace(".s3.amazonaws.com", "");
});
}
getAWSConfig(stage) {
return this.aws.find((c) => c.Stage === stage);
}
getAWSConfigForBucket(bucket) {
return this.aws.find((c) => c.CloudFrontOriginBucket === bucket);
}
isValidAWSBucket(bucket) {
return !!this.aws.find((c) => {
return c.CloudFrontOriginBucket === bucket;
});
}
}
module.exports = HufferConfig;