const express = require("express") const router = express.Router() const {logHeaderApi, eventNames} = require("../../rpdata/api/LogHeader") const {charactersApi} = require("../../rpdata/api/Character") const {channelApi} = require("../../rpdata/api/Channel") const listTemplate = require("../../marko/page/logs/list.marko") router.get("/", async(req, res) => { const filter = {limit: 75} if (req.query.characters) { filter.characters = req.query.characters.split(",") filter.limit = 0 } if (req.query.channels) { filter.channels = req.query.channels.split(",") filter.limit = 0 } if (req.query.events) { filter.events = req.query.events.split(",") filter.limit = 0 } if (req.query.search) { filter.search = req.query.search filter.limit = 0 } if (req.query.limit) { filter.limit = parseInt(req.query.limit) } try { res.markoAsync(listTemplate, { filter: filter, logs: logHeaderApi.list(filter), characters: charactersApi.listHeaders(), channels: channelApi.list(), eventNames: logHeaderApi.eventNames(), selected: {index: true}, }) } catch(err) { console.error(err) } }) module.exports = router