import { LoadRepertoireRequest , LoadRepertoireResponse } from '../../protocol/actions' ; import { assert } from '../../util/assert' ; import { Action } from '../action' ; import { CheckRequestResult } from '../checkrequestresult' ; import { DatabaseWrapper } from '../databasewrapper' ; export class LoadRepertoireAction implements Action < LoadRepertoireRequest , LoadRepertoireResponse > { private database_ : DatabaseWrapper ; constructor ( database ) { this . database_ = database ; } checkRequest ( ) { return Promise . resolve ( { success : true } ) ; } do ( request , user ) { return this . database_ . getRepertoireForOwner ( request . repertoireId , assert ( user ) ) . then ( repertoire => { return { repertoire } ; } ) ; } }