Skip to content

Instantly share code, notes, and snippets.

@shaykav
Last active March 26, 2021 03:45
Show Gist options
  • Save shaykav/37599443c88dfdbb53ee3041b8bf0f0c to your computer and use it in GitHub Desktop.
Save shaykav/37599443c88dfdbb53ee3041b8bf0f0c to your computer and use it in GitHub Desktop.
export const handler: Handler<APIGatewayEvent> = async (event, context, callback) => {
if (!event.requestContext) {
return {
statusCode: 500,
body: ''
};
}
const { eventType, connectionId } = event.requestContext;
if (eventType === 'CONNECT') {
// handle connect
return {
statusCode: 200,
body: ''
};
}
if (eventType === 'DISCONNECT') {
// handle disconnect
return {
statusCode: 200,
body: ''
};
}
if (eventType === 'MESSAGE') {
// handle message
return {
statusCode: 200,
body: ''
};
}
return {
statusCode: 500,
body: ''
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment