Install Dependencies and Types

Video Lecture

Install Dependencies and Types Install Dependencies and Types

Description

Create Socket Server Script, Install Dependencies and Types

src/server/server.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
import http from "http"
import socketIO from "socket.io"

const port: number = 3000

class App {
    private server: http.Server
    private port: number

    constructor(port: number) {
        this.port = port

        this.server = new http.Server();
        const io: socketIO.Server = socketIO(this.server);
    }

    public Start() {
        this.server.listen(this.port, () => {
            console.log( `Server listening on port ${this.port}.` )
        })
    }
}

new App(port).Start()

Install Dependencies and Types

Install Types for Nodejs

1
npm install @types/node

Install SocketIO

1
npm install socket.io

Install Types for SocketIO

1
npm install @types/socket.io