2023-03-04 02:39:59 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
const handler = require('express-async-handler');
|
|
|
|
const content = require('../helpers/content');
|
|
|
|
|
|
|
|
async function view(req, res) {
|
|
|
|
const data = await content.get(req.query.id);
|
|
|
|
if (req.query.raw) {
|
2023-03-04 02:40:29 +01:00
|
|
|
res.header('Content-Type', 'text/plain');
|
2023-03-04 02:39:59 +01:00
|
|
|
res.send(data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res.render('view', {data, id: req.query.id});
|
|
|
|
}
|
|
|
|
|
|
|
|
router.get('/view', handler(view));
|
|
|
|
|
|
|
|
module.exports = router;
|