mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
28 lines
655 B
JavaScript
Executable File
28 lines
655 B
JavaScript
Executable File
import { FeaturedWallpaper } from "@db_models"
|
|
|
|
export default {
|
|
method: "GET",
|
|
route: "/featured_wallpapers",
|
|
fn: async (req, res) => {
|
|
const { all } = req.query
|
|
|
|
const query = {
|
|
active: true
|
|
}
|
|
|
|
if (all) {
|
|
delete query.active
|
|
}
|
|
|
|
const featuredWallpapers = await FeaturedWallpaper.find(query)
|
|
.sort({ date: -1 })
|
|
.limit(all ? undefined : 10)
|
|
.catch(err => {
|
|
return res.status(500).json({
|
|
error: err.message
|
|
}).end()
|
|
})
|
|
|
|
return res.json(featuredWallpapers)
|
|
}
|
|
} |