-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
Websocket
and drop GraphQL
- Loading branch information
1 parent
fa55db5
commit 72ee6b7
Showing
25 changed files
with
423 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import { InputType, Int, Field } from "@nestjs/graphql"; | ||
|
||
@InputType() | ||
export class CreatePlayerInput { | ||
@Field(() => Int, { description: "Example field (placeholder)" }) | ||
exampleField: number; | ||
name: string; | ||
uuid: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
import { CreatePlayerInput } from "./create-player.input"; | ||
import { InputType, Field, Int, PartialType } from "@nestjs/graphql"; | ||
|
||
@InputType() | ||
export class UpdatePlayerInput extends PartialType(CreatePlayerInput) { | ||
@Field(() => Int) | ||
id: number; | ||
export class UpdatePlayerInput { | ||
id!: number; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { PlayersGateway } from "./players.gateway"; | ||
|
||
describe("PlayersGateway", () => { | ||
let gateway: PlayersGateway; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [PlayersGateway] | ||
}).compile(); | ||
|
||
gateway = module.get<PlayersGateway>(PlayersGateway); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(gateway).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
ConnectedSocket, | ||
MessageBody, | ||
OnGatewayConnection, | ||
SubscribeMessage, | ||
WebSocketGateway, | ||
WebSocketServer | ||
} from "@nestjs/websockets"; | ||
import { Namespace, Server, Socket } from "socket.io"; | ||
|
||
@WebSocketGateway() | ||
export class PlayersGateway implements OnGatewayConnection { | ||
@WebSocketServer() private readonly server: Server; | ||
|
||
// @ts-ignore | ||
@WebSocketServer({ namespace: "namespace" }) | ||
private readonly namespace: Namespace; | ||
|
||
constructor() { | ||
console.log("PlayersGateway created", this.server, this.namespace); | ||
} | ||
|
||
handleConnection(client: Socket, ...args: any[]) { | ||
console.log("Client connected", client.id, args); | ||
} | ||
|
||
@SubscribeMessage("message") | ||
handleMessage( | ||
@MessageBody() data: string, | ||
@ConnectedSocket() client: Socket, | ||
payload: any | ||
): string { | ||
console.log(data, client.connected); | ||
|
||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { Module } from "@nestjs/common"; | ||
|
||
import { PlayersService } from "./players.service"; | ||
import { PlayersResolver } from "./players.resolver"; | ||
import { PlayersGateway } from "./gateways/players.gateway"; | ||
|
||
@Module({ | ||
providers: [PlayersResolver, PlayersService] | ||
providers: [PlayersService, PlayersGateway] | ||
}) | ||
export class PlayersModule {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.