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: 0} if (req.query.characters) { filter.characters = req.query.characters.split(",") } if (req.query.channels) { filter.channels = req.query.channels.split(",") } if (req.query.events) { filter.events = req.query.events.split(",") } if (req.query.search) { filter.search = req.query.search } 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