Last active
August 3, 2020 06:08
-
-
Save jakejrichards/9152fe9557778f280216cb42e0b840fe to your computer and use it in GitHub Desktop.
This file contains 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
// This is a sample of what the event object that gets | |
// passed to your connect route could look like. | |
// I've chosen to use an authorizer that will pass | |
// the userId so that I can store the connectionId with the userId | |
// in my database | |
interface APIGatewayWebsocketEvent { | |
methodArn: string; | |
queryStringParameters: { | |
token: string; | |
}; | |
requestContext: { | |
eventType: string; | |
connectionId: string; | |
authorizer: { | |
userId: string; | |
}; | |
}; | |
} | |
function onConnect(event: APIGatewayWebsocketEvent) { | |
const { | |
requestContext: { | |
connectionId, | |
authorizer: { userId }, | |
}, | |
} = event; | |
// save connectionId & userId to database for further | |
// messaging capabilities | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment