Skip to main content

API Gateway (WebSocket)


This page is a work in progress. If you want to help us to make this page better, please consider contributing on GitHub.

AWS Documentation


import middy from '@middy/core'
import wsJsonBodyParserMiddleware from '@middy/ws-json-body-parser'
import wsResponseMiddleware from '@middy/ws-response'
import wsRouterHandler from '@middy/ws-router'

import { handler as connectHandler } from './handlers/connect.js'
import { handler as disconnectHandler } from './handlers/disconnect.js'
import { handler as defaultHandler } from './handlers/default.js'

const routes = [
routeKey: '$connect',
handler: connectHandler
routeKey: '$disconnect',
handler: disconnectHandler
routeKey: 'default',
handler: defaultHandler

export const handler = middy()