mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 11:34:15 +00:00
20 lines
554 B
JavaScript
20 lines
554 B
JavaScript
import { FeaturedWallpaper } from "@db_models"
|
|
|
|
export default async (req) => {
|
|
let { limit = 10, offset = 0, random = false } = req.query
|
|
|
|
if (random) {
|
|
const items = await FeaturedWallpaper.countDocuments({ active: true })
|
|
|
|
offset = Math.floor(Math.random() * items)
|
|
|
|
const wallapers = await FeaturedWallpaper.find({ active: true }).skip(offset).limit(1)
|
|
return wallapers[0]
|
|
}
|
|
|
|
const wallapers = await FeaturedWallpaper.find({
|
|
active: true
|
|
}).skip(offset).limit(limit)
|
|
|
|
return wallapers
|
|
} |