Skip to content

Instantly share code, notes, and snippets.

@mvcds
Last active August 16, 2021 20:16
Show Gist options
  • Save mvcds/94b4b443978cf0f4bc4df59b33124a6c to your computer and use it in GitHub Desktop.
Save mvcds/94b4b443978cf0f4bc4df59b33124a6c to your computer and use it in GitHub Desktop.
Testing data or rules 5
//hard-coded data giving by business (probably) to "play safe"
const defaultConfiguration = {
alcohol: 21,
softDrugs: Infinity,
hardDrugs: Infinity,
drive: 21,
adult: 21
}
// ts-magic, creates an interface-like type definition
// it uses a value as template, infering the types correctly
type Configuration = typeof defaultConfiguration
export const async getCountryConfiguration = (
country: Country
): Configuration => {
//try-catch is on the service
const record: Configuration = await service.getCountryConfiguration(country)
return {
...defaultConfiguration,
...record
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment