adding in character detail stuff

This commit is contained in:
jmosrael@gmail.com
2024-05-12 16:00:34 -07:00
parent e2b261e989
commit 1a3f8c4b25
5 changed files with 59 additions and 15 deletions

View File

@@ -80,13 +80,13 @@ app.post('/api/character', jsonParser, async (req, res) => {
const count = req.body.count
const characterData = await Character.findAll({
offset: page * count,
limit: count
offset: page * count,
limit: count
})
const pageCount = Math.ceil(await Character.count() / count)
const pageCount = Math.ceil((await Character.count()) / count)
res.setHeader('Content-Type', 'application/json')
res.json({characterData, pageCount})
res.json({ characterData, pageCount })
})
app.get('/api/game/:characterId', async (req, res) => {
@@ -94,18 +94,21 @@ app.get('/api/game/:characterId', async (req, res) => {
})
app.post('/api/game', jsonParser, async (req, res) => {
const page = req.body.page
const orderBy = req.body.orderBy
const count = req.body.count
const page = req.body.page || 0
const orderBy = req.body.orderBy || 'id'
const count = req.body.count || 10
const filter = req.body.filter || ''
const gameData = await Game.findAll({
offset: page * count,
limit: count
console.log(filter)
const gameData = await Game.findAll({
offset: page * count,
limit: count
})
const pageCount = Math.ceil(await Character.count() / count)
const pageCount = Math.ceil((await Character.count()) / count)
res.setHeader('Content-Type', 'application/json')
res.send({gameData, pageCount})
res.send({ gameData, pageCount })
})
app.get('/api/game/:gameId', async (req, res) => {