32 lines
899 B
JavaScript
32 lines
899 B
JavaScript
const router = require('express').Router()
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
module.exports = (plugin, app) => {
|
|
// gear, gear/type, gear/type/name
|
|
router.get(['/gear', '/gear/:type', '/gear/:type/:name'], async function(req, res) {
|
|
let entry = null
|
|
if (req.params.name) {
|
|
if (!app.live.db.gear[req.params.type]) {
|
|
// TODO: 404 - no such gear type
|
|
} else {
|
|
entry = app.live.db.gear[req.params.type].find(v=>v.name===req.params.name)
|
|
if (!entry) {
|
|
// TODO: 404 - no such gear by name
|
|
}
|
|
}
|
|
}
|
|
res.render('index', {
|
|
content: app.dot.tables({...req.params, db: app.live.db.gear, entry: entry}),
|
|
menu: app.live.menu,
|
|
title: 'gear',
|
|
www_name: app.live.conf.www_name,
|
|
www_copyright: app.live.conf.www_copyright,
|
|
})
|
|
})
|
|
|
|
plugin.log('added gear route')
|
|
|
|
return router
|
|
}
|