Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created February 25, 2023 01:02
Show Gist options
  • Save macdonst/e8cd39459ff737f4d6b7cf8fff948863 to your computer and use it in GitHub Desktop.
Save macdonst/e8cd39459ff737f4d6b7cf8fff948863 to your computer and use it in GitHub Desktop.
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