Created
September 6, 2019 09:33
-
-
Save codyzu/8a8c86c66bc88fff6b065b648ecad028 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
const getUserFromDatabase = memoize(async ctx => { | |
const { | |
req: { | |
headers: {Authorization: userCred}, | |
}, | |
} = ctx; | |
const user = await db.getUserByCredential(userCred); | |
return user; | |
}); | |
const sendMessageToUser = memoize(async ctx => { | |
const {username} = await getUserFromDatabase(ctx); | |
await messaging.sendToUser(username, 'hello'); | |
}); | |
const replyOk = memoize(async ctx => { | |
const {username} = await getUserFromDatabase(ctx); | |
const {res} = ctx; | |
res.status(200).send('done'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment