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/decks/list.coffee

35 lines
904 B
CoffeeScript
Raw Normal View History

2019-05-10 12:09:49 +00:00
logger = (require 'logging').default '/decks/list'
# session storage (volatile data)
session = (require '../../session')
# fftcg.db (persistent data)
fftcgdb = (require '../../db')
module.exports =
url: '/decks/list'
method: 'POST'
# schema: (require './info.schema')
handler: (request, reply) ->
session.check request.body.session ? ""
.then (userid) ->
# active session found, get associated user
fftcgdb.getDecks (userid)
.then (decks) ->
logger.debug "OK '#{userid}' got decks"
reply.send
success: true
2019-05-13 15:35:15 +00:00
decks: decks
2019-05-10 12:09:49 +00:00
.catch (err) ->
# couldnt get user details
logger.warn "FAIL '#{err}' for user id '#{userid}'"
reply.send
success: false
.catch ->
# no session found
logger.info "FAIL '#{request.body.session}' session not found"
reply.send
success: false