mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
27 lines
818 B
JavaScript
Executable File
27 lines
818 B
JavaScript
Executable File
import { Badge } from "@db_models"
|
|
import { Schematized } from "@lib"
|
|
|
|
export default {
|
|
method: "PUT",
|
|
route: "/",
|
|
middlewares: ["withAuthentication", "onlyAdmin"],
|
|
fn: Schematized({
|
|
select: ["badge_id", "name", "label", "description", "icon", "color"],
|
|
}, async (req, res) => {
|
|
let badge = await Badge.findById(req.selection.badge_id).catch((err) => null)
|
|
|
|
if (!badge) {
|
|
badge = new Badge()
|
|
}
|
|
|
|
badge.name = req.selection.name || badge.name
|
|
badge.label = req.selection.label || badge.label
|
|
badge.description = req.selection.description || badge.description
|
|
badge.icon = req.selection.icon || badge.icon
|
|
badge.color = req.selection.color || badge.color
|
|
|
|
badge.save()
|
|
|
|
return res.json(badge)
|
|
})
|
|
} |