27 lines
797 B
TypeScript
27 lines
797 B
TypeScript
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
|
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
|
import { WebSocketService } from '../../../common/services/websocket.service';
|
|
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
|
|
|
const wsService = new WebSocketService(prismaClient);
|
|
|
|
export const handler = safeHandler(
|
|
async (
|
|
event: APIGatewayProxyEvent,
|
|
context?: Context
|
|
): Promise<APIGatewayProxyResult> => {
|
|
const connectionId = event.requestContext.connectionId;
|
|
if (connectionId) {
|
|
await wsService.disconnect(connectionId);
|
|
}
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify({
|
|
success: true,
|
|
message: 'Disconnected',
|
|
}),
|
|
};
|
|
}
|
|
);
|