mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
7f48c67512
* Add `unicorn/prefer-node-protocol` * Fix `unicorn/prefer-node-protocol` ESLint errors * Run `npm run format:fix` * Add sandboxed-module sourceTransformers in mocha setups Fix `no such file or directory, open 'node:fs'` in `sandboxed-module` * Remove `node:` in the SandboxedModule requires * Fix new linting errors with `node:` GitOrigin-RevId: 68f6e31e2191fcff4cb8058dd0a6914c14f59926
24 lines
747 B
JavaScript
24 lines
747 B
JavaScript
const Path = require('node:path')
|
|
const send = require('send')
|
|
const Settings = require('@overleaf/settings')
|
|
const OutputCacheManager = require('./OutputCacheManager')
|
|
|
|
const ONE_DAY_S = 24 * 60 * 60
|
|
const ONE_DAY_MS = ONE_DAY_S * 1000
|
|
|
|
function getPdfRange(req, res, next) {
|
|
const { projectId, userId, contentId, hash } = req.params
|
|
const perUserDir = userId ? `${projectId}-${userId}` : projectId
|
|
const path = Path.join(
|
|
Settings.path.outputDir,
|
|
perUserDir,
|
|
OutputCacheManager.CONTENT_SUBDIR,
|
|
contentId,
|
|
hash
|
|
)
|
|
res.setHeader('cache-control', `public, max-age=${ONE_DAY_S}`)
|
|
res.setHeader('expires', new Date(Date.now() + ONE_DAY_MS).toUTCString())
|
|
send(req, path).pipe(res)
|
|
}
|
|
|
|
module.exports = { getPdfRange }
|