Skip to content

Instantly share code, notes, and snippets.

@codyzu
Created September 6, 2019 12:13
Show Gist options
  • Save codyzu/22eef4da18f09b24dff28ae774071092 to your computer and use it in GitHub Desktop.
Save codyzu/22eef4da18f09b24dff28ae774071092 to your computer and use it in GitHub Desktop.
async function getUserFromDatabase(ctx) {
const {
req: {
headers: {Authorization: userCred},
},
} = ctx;
const user = await db.getUserByCredential(userCred);
return {
...ctx,
user,
};
}
async function sendMessageToUser(ctx) {
const {user} = ctx;
await messaging.sendToUser(user.username, 'hello');
return ctx;
}
async function replyOk(ctx) {
const {user} = ctx;
const {res} = ctx;
res.status(200).send(`Ok ${user.username}`);
return ctx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment