Skip to content

Instantly share code, notes, and snippets.

@dbauszus-glx
Created March 7, 2020 16:29
Show Gist options
  • Save dbauszus-glx/6cfebb71af24e1a7d5402fbcb976a5cd to your computer and use it in GitHub Desktop.
Save dbauszus-glx/6cfebb71af24e1a7d5402fbcb976a5cd to your computer and use it in GitHub Desktop.
const auth = require('../mod/auth/handler')({
public: true,
login: true
})
const _templates = require('../mod/workspace/templates')
const templates = {}
module.exports = async (req, res) => {
await auth(req, res)
Object.assign(templates, await _templates(req, res))
if (res.finished) return
const md = new Md(req.headers['user-agent'])
const template = templates[(md.mobile() === null || md.tablet() !== null) && '_desktop' || '_mobile'];
const html = template.render({
dir: process.env.DIR || '',
title: process.env.TITLE || 'GEOLYTIX | XYZ',
token: req.query.token || req.params.token.signed || '""',
log: process.env.LOG_LEVEL || '""',
login: (process.env.PRIVATE || process.env.PUBLIC) && 'true' || '""',
})
res.send(html)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment