diff --git a/routes/homepage.js b/routes/homepage.js index c000590db..1be566889 100644 --- a/routes/homepage.js +++ b/routes/homepage.js @@ -1,5 +1,6 @@ const express = require('express'); const router = express.Router(); +const base64 = require('base-64') // Import middleware const { @@ -22,7 +23,8 @@ async function readHomepage (req, res, next) { const IsomerFile = new File(accessToken, siteName) const homepageType = new HomepageType() IsomerFile.setFileType(homepageType) - const { sha, content } = await IsomerFile.read(HOMEPAGE_INDEX_PATH) + const { sha, content: encodedContent } = await IsomerFile.read(HOMEPAGE_INDEX_PATH) + const content = Base64.decode(encodedContent) // TO-DO: // Validate content @@ -43,7 +45,7 @@ async function updateHomepage (req, res, next) { const IsomerFile = new File(accessToken, siteName) const homepageType = new HomepageType() IsomerFile.setFileType(homepageType) - const { newSha } = await IsomerFile.update(HOMEPAGE_INDEX_PATH, content, sha) + const { newSha } = await IsomerFile.update(HOMEPAGE_INDEX_PATH, Base64.encode(content), sha) res.status(200).json({ content, sha: newSha }) }