Last active
August 16, 2021 20:16
Revisions
-
mvcds revised this gist
Aug 16, 2021 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ const defaultConfiguration = { alcohol: 21, softDrugs: Infinity, @@ -7,18 +6,20 @@ const defaultConfiguration = { adult: 21 } type Configuration = typeof defaultConfiguration export const async getCountryConfiguration = ( country: Country ): Configuration => { try { const record: Configuration = await service.getCountryConfiguration(country) return { ...defaultConfiguration, ...record } } catch (e) { logger.error(`service.getCountryConfiguration for ${country}`, e) return defaultConfiguration } } -
mvcds created this gist
Aug 16, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ //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 } }