Created
February 25, 2023 01:02
-
-
Save macdonst/e8cd39459ff737f4d6b7cf8fff948863 to your computer and use it in GitHub Desktop.
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
const path = require('path') | |
const { readFileSync } = require('fs') | |
exports.handler = async function http (req) { | |
let here = path.dirname('.') | |
let postsFilePath = path.join(here, 'rss.xml.br') | |
let posts = readFileSync(postsFilePath, 'binary') | |
console.log(posts.length) | |
let b64 = Buffer.from(posts).toString('base64') | |
console.log(b64.length) | |
return { | |
statusCode: 200, | |
headers: { | |
'cache-control': 'max-age=86400', | |
'content-type': 'application/rss+xml', | |
'content-encoding': 'br', | |
'content-length': b64.length | |
}, | |
body: b64, | |
isBase64Encoded: true, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment