diff --git a/src/app.ts b/src/app.ts deleted file mode 100644 index 270fb36..0000000 --- a/src/app.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NestApplication } from 'nest.js'; - -export class Application implements NestApplication { - constructor(private expressApp) {} - - start() { - // do something before server start - this.expressApp.listen(3031, () => { - console.log('Application listen on port:', 3031); - }); - } -} \ No newline at end of file diff --git a/src/modules/users/chat.gateway.ts b/src/modules/users/chat.gateway.ts index 172c64e..7bfd1d9 100644 --- a/src/modules/users/chat.gateway.ts +++ b/src/modules/users/chat.gateway.ts @@ -1,11 +1,12 @@ import { Subject } from 'rxjs/Subject'; -import { SocketGateway, GatewayServer, SubscribeMessage } from 'nest.js/socket'; +import { WebSocketGateway, WebSocketServer, SubscribeMessage } from 'nest.js/websockets'; -@SocketGateway({ port: 2000 }) +@WebSocketGateway({ port: 2000 }) export class ChatGateway { private msg$ = new Subject(); - @GatewayServer server; + @WebSocketServer() + server; get msgStream() { return this.msg$.asObservable(); diff --git a/src/server.ts b/src/server.ts index beaf330..1794b4a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,5 @@ -import { NestRunner } from 'nest.js'; -import { Application } from './app'; +import { NestFactory } from 'nest.js'; import { ApplicationModule } from './modules/app.module'; -NestRunner.run(Application, ApplicationModule); \ No newline at end of file +const app = NestFactory.create(ApplicationModule); +app.listen(3000, () => console.log('Application is listening on port 3000.')); \ No newline at end of file