setup the dm apis

This commit is contained in:
jmosrael@gmail.com
2024-07-12 00:46:53 -07:00
parent 9df2470f65
commit 6d03e450c9
6 changed files with 77 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ export function addCharacterApis(app, jsonParser) {
app.get('/api/character/:characterId', async (req, res) => {
try {
const character = await Character.findOne({
attributes: ["id", "characterName", "playerName", "role", "creationDate", "status"],
attributes: ['id', 'characterName', 'playerName', 'role', 'creationDate', 'status'],
where: { id: req.params['characterId'] }
})
if (character) {
@@ -35,11 +35,9 @@ export function addCharacterApis(app, jsonParser) {
where: filter
})
const totalCount = await Character.count({
where: filter
})
const pageCount = Math.ceil(
totalCount / count
)
where: filter
})
const pageCount = Math.ceil(totalCount / count)
res.setHeader('Content-Type', 'application/json')
res.send({ characterData, pageCount, totalCount })