Move index route to controller

master
Joe Biellik 5 years ago
parent 95b4d3003a
commit ecd0647250

@ -4,6 +4,16 @@ const isBinaryFile = require('isbinaryfile').isBinaryFile;
const Paste = require('../models/paste');
module.exports = {
async index(ctx) {
await ctx.render('index', {
pretty: config.prettyHtml,
title: config.name,
url: ctx.request.origin,
expires: config.expires,
highlights: config.highlights
});
},
async view(ctx) {
try {
const paste = await Paste.findById(ctx.params.id).exec();

@ -22,18 +22,7 @@ const body = require('koa-body')({
const pastes = require('./controllers/pastes');
router
.get('/', conditional, etag, async (ctx) => {
ctx.set('Cache-Control', 'public');
await ctx.render('index', {
pretty: config.prettyHtml,
title: config.name,
url: ctx.request.origin,
expires: config.expires,
expiresDefault: config.expiresDefault,
highlights: config.highlights
});
})
.get('/', conditional, etag, pastes.index)
.post('/', body, pastes.create)
.get('/:id', conditional, etag, pastes.view);

Loading…
Cancel
Save