Last active
October 9, 2021 22:17
-
-
Save Pyrolistical/bf337eacb2e7d7a1755148f74350e340 to your computer and use it in GitHub Desktop.
separate business layer from infrastructure layer after
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (db) => { | |
return { | |
async findDisqualifiedPlayers(teamID) { | |
return db.collection('playerDisqualifications').find({ | |
teamID | |
}) | |
.toArray(); | |
}, | |
async checkInTeam(teamID) { | |
return db.collection('checkIns').insert({ | |
teamID, | |
checkedInAt: new Date() | |
}); | |
} | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (repository) => { | |
return { | |
async checkIn(teamID) { | |
const disqualifiedPlayers = await repository.findDisqualifiedPlayers(teamID); | |
if (disqualifiedPlayers.length > 0) { | |
throw new Error('cannot check-in with disqualified players'); | |
} | |
return repository.checkinTeam(teamID); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment