-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
49 lines (39 loc) · 1.64 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Member, Profile, Server } from "@prisma/client";
import { NextApiResponse } from "next";
import { Server as SocketIOServer } from "socket.io";
import { Server as NetServer, Socket } from "net";
export type ServerWithMembersWithProfiles = Server & {
members: (Member & { profile: Profile })[];
};
export type NextApiResponseServerIo = NextApiResponse & {
socket: Socket & {
server: NetServer & {
io: SocketIOServer;
};
};
};
/**
*
The NextApiResponseServerIo type is a custom type definition that extends the NextApiResponse type provided by Next.js. It introduces additional properties related to Socket.IO integration. Let's break down the type definition:
typescript
Copy code
export type NextApiResponseServerIo = NextApiResponse & {
socket: Socket & {
server: NetServer & {
io: SocketIOServer;
};
};
};
NextApiResponseServerIo Type:
Extends NextApiResponse: This type extends the NextApiResponse type, meaning it inherits all the properties and methods of the standard Next.js API response.
Additional Properties:
socket Property:
This property represents the Socket object associated with the response.
Why? It allows access to the underlying Socket.IO functionality for handling real-time communication.
server Property:
This property represents the NetServer object associated with the response socket.
Why? It gives access to the HTTP server, which is required for setting up the Socket.IO server.
io Property:
This property represents the SocketIOServer instance associated with the HTTP server.
Why? It provides access to the Socket.IO server instance, allowing customization and interaction with Socket.IO features.
*/