-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nils Schönwald
committed
Jul 16, 2019
1 parent
48e8b83
commit c349273
Showing
15 changed files
with
4,741 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"aws": { | ||
"region": "eu-central-1", | ||
"s3": { | ||
"bucket": "cdn.schoen.world" | ||
} | ||
}, | ||
"contentful": { | ||
"accessToken": "VX0Df2ptjUdatNH3XsYRRd85494LOfT-OQwbOYyS550", | ||
"space": "81noh8m93vcd" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const getContentfulData = require('./src/getContentfulData'); | ||
const formatData = require('./src/formatData'); | ||
const writeFileToS3 = require('./src/writeFileToS3'); | ||
const readFileFromS3 = require('./src/readFileFromS3'); | ||
|
||
module.exports.updateTimelineData = async () => { | ||
const languages = ['de', 'en']; | ||
const message = {}; | ||
|
||
await Promise.all(languages.map(async (lang) => { | ||
const data = await getContentfulData(lang); | ||
const formatedData = await formatData(data, lang); | ||
const result = await writeFileToS3(formatedData, lang); | ||
message[lang] = result; | ||
})); | ||
|
||
return { | ||
statusCode: message.de && message.en ? 200 : 500, | ||
body: JSON.stringify({ message }, null, 2), | ||
}; | ||
}; | ||
|
||
module.exports.getTimelineData = async (event) => { | ||
console.log(event); | ||
let language = 'en'; | ||
if (event.queryStringParameters && event.queryStringParameters.lang) { | ||
language = event.queryStringParameters.lang; | ||
} | ||
const result = await readFileFromS3(language); | ||
|
||
return { | ||
statusCode: result ? 200 : 500, | ||
body: result, | ||
headers: { | ||
'access-control-allow-origin': event.headers.origin, | ||
'access-control-allow-credentials': true, | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.