Skip to content

Commit

Permalink
Fix: encode/decode homepage content (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs authored Apr 13, 2021
1 parent a01380d commit c4e8549
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions routes/homepage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require('express');
const router = express.Router();
const base64 = require('base-64')

// Import middleware
const {
Expand All @@ -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
Expand All @@ -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 })
}
Expand Down

0 comments on commit c4e8549

Please sign in to comment.