This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/backend/routes/games/list.coffee

27 lines
675 B
CoffeeScript
Raw Normal View History

2019-06-04 15:00:09 +00:00
logger = (require 'logging').default '/games/list'
# session storage (volatile data)
session = (require '../../session')
module.exports =
url: '/games/list'
method: 'POST'
# schema: (require './info.schema')
handler: (request, reply) ->
session.check request.body.session ? ""
.then (userid) ->
# active session found, get associated user
session.getGames()
.then (games) ->
logger.debug "OK '#{userid}' got games"
reply.send
success: true
games: games
.catch ->
# no session found
logger.info "FAIL '#{request.body.session}' session not found"
reply.send
success: false