Last active
September 5, 2019 07:57
-
-
Save shulcsm/2a1e93f2e3f22b3e96dbe9224bd283b2 to your computer and use it in GitHub Desktop.
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 characters
interface Actions { | |
item: ItemAction; | |
} | |
export function createActions<K extends keyof Actions>( | |
endpoint: string, | |
url: string, | |
actions: K[], | |
): Pick<Actions, K> { | |
const res = {}; | |
if (actions.includes('item')) { | |
res['item'] = { | |
path: `${url}/:id`, | |
endpoint: { | |
endpoint: `${endpoint}:id/`, | |
method: 'GET', | |
}, | |
} | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment