27 lines
675 B
CoffeeScript
27 lines
675 B
CoffeeScript
|
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
|