From 623bd5a0d2895000c91ba151f64684582682a8c9 Mon Sep 17 00:00:00 2001 From: GeekOfWires Date: Sun, 20 Sep 2020 05:17:08 -0400 Subject: [PATCH] Added basic API for character stats --- api/stats.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 api/stats.js diff --git a/api/stats.js b/api/stats.js new file mode 100644 index 0000000..6984992 --- /dev/null +++ b/api/stats.js @@ -0,0 +1,25 @@ +import express from 'express' +import * as db from './db.js' +import {AVATAR, SQL_ORDER} from "./db.js"; + +const api = express.Router(); + +api.get('/char_stats/:batch', async (req, res, next) => { + try { + const stats = await db.get_stats(); + + stats.empires = { "TR": 0, "NC": 0, "VS": 0 } + + var batch = req.params.batch; + + const avatars = await db.get_character_batch_for_stats(batch, AVATAR.ID, SQL_ORDER.ASCENDING); + + res.status(200).json({ players: avatars }); + + } catch (e) { + console.log(e); + res.status(500).json({ message: 'error' }); + } +}); + +export default api; \ No newline at end of file