import { v4 as uuidv4 } from 'uuid';import { getFirstProviderUserId } from 'wasp/auth';import { type WebSocketDefinition, type WaspSocketData,} from 'wasp/server/webSocket';export const webSocketFn: WebSocketFn = (io, context) => { io.on('connection', (socket) => { const username = getFirstProviderUserId(socket.data.user) ?? 'Unknown'; // const username = 'testUser'; // For testing purposes, replace with actual user logic console.log('a user connected: ', username); socket.on('chatMessage', async (msg) => { console.log('message: ', msg); io.emit('chatMessage', { id: uuidv4(), username, text: msg }); // You can also use your entities here: // await context.entities.SomeEntity.create({ someField: msg }) }); });};
import { v4 as uuidv4 } from 'uuid';import { getFirstProviderUserId } from 'wasp/auth';import { type WebSocketDefinition, type WaspSocketData,} from 'wasp/server/webSocket';export const webSocketFn: WebSocketFn = (io, context) => { io.on('connection', (socket) => { const username = getFirstProviderUserId(socket.data.user) ?? 'Unknown'; // const username = 'testUser'; // For testing purposes, replace with actual user logic console.log('a user connected: ', username); socket.on('chatMessage', async (msg) => { console.log('message: ', msg); io.emit('chatMessage', { id: uuidv4(), username, text: msg }); // You can also use your entities here: // await context.entities.SomeEntity.create({ someField: msg }) }); });};
and error I'm getting
Wasp ] ext-src/webSocket.ts(10,45): error TS2345: Argument of type 'AuthUser' is not assignable to parameter of type 'UserEntityWithAuth'.[ Wasp ] Property 'auth' is missing in type 'AuthUser' but required in type '{ auth: MakeAuthEntityWithIdentities<Pick<{ providerName: string; providerUserId: string; providerData: string; authId: string; }, "providerName" | "providerUserId">>; }'.
Wasp ] ext-src/webSocket.ts(10,45): error TS2345: Argument of type 'AuthUser' is not assignable to parameter of type 'UserEntityWithAuth'.[ Wasp ] Property 'auth' is missing in type 'AuthUser' but required in type '{ auth: MakeAuthEntityWithIdentities<Pick<{ providerName: string; providerUserId: string; providerData: string; authId: string; }, "providerName" | "providerUserId">>; }'.
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
W
Wasp
Rails-like framework for React, Node.js and Prisma. Build your app in a day and deploy it with a single CLI command.