You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
714 B
JavaScript

const router = require('express-promise-router')()
const db = require('../db')
const ensureAdmin = require('./middleware/ensureAdmin')
router.get('/:uuid/:size', async (req, res) => {
const image = await db.item.getImage(req.params.uuid, req.params.size)
const cacheSeconds = 60 * 60 * 24;
res.set('Cache-Control', cacheSeconds);
res.set('Content-Type', image.mime_type)
res.end(image.file)
})
router.post('/:uuid/featured', ensureAdmin, async (req, res) => {
const item = await db.item.setFeatured(req.params.uuid)
res.json(item)
})
router.delete('/:uuid', ensureAdmin, async (req, res) => {
const item = await db.item.removeImage(req.params.uuid)
res.json(item)
})
module.exports = router