diff --git a/index.js b/index.js index d551f09..6d5db54 100644 --- a/index.js +++ b/index.js @@ -21,13 +21,13 @@ const log = initLog("[ MAIN ]") // Read the .env file dotenv.config() -dbInit() setStat("startup", start) setStat("lastDBUpdate", start) if (process.env.DOWNLOAD_FILES === "enabled") await downloadEssentialData() +dbInit() generateDB() const Server = express() diff --git a/routes/routes.js b/routes/routes.js index 86a67fd..069bfd2 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -12,6 +12,21 @@ routes.get( } ) +routes.get( + '/search', + (req, res) => { + const map = req.query.qmap ?? "" + const categories = req.query.categories ?? [] + const stars = req.query.stars ?? [] + const sort = req.query.sortBy ?? "map" + const order = req.query.order === "desc" ? "desc" : "asc" + + const maps = wrapper.searchMap(map, categories.split(","), stars.split(","), sort, order) + + tx(req, res)('pages/maps.njk', { maps }, true, { currentSection: "maps" }) + } +) + routes.get( '/maps', (req, res) => {