19 lines
711 B
JavaScript
19 lines
711 B
JavaScript
const express = require("express")
|
|
const path = require("node:path")
|
|
const multer = require("multer")
|
|
const router = express.Router()
|
|
const adminService = require("../../../services/adminService")
|
|
|
|
const upload = multer({ dest: path.join(process.cwd(), "data/temp/") })
|
|
|
|
router.post("/upload", adminService.hasPermission("UPLOAD_CAPE"), upload.single("file"), async (req, res) => {
|
|
const result = await adminService.uploadCape(req.file, req.body.alias)
|
|
res.status(201).json(result)
|
|
})
|
|
|
|
router.delete("/:hash", adminService.hasPermission("DELETE_CAPES"), async (req, res) => {
|
|
const result = await adminService.deleteCape(req.params.hash)
|
|
res.status(200).json(result)
|
|
})
|
|
|
|
module.exports = router |