All files / src/models server.js

100% Statements 28/28
100% Branches 0/0
100% Functions 4/4
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 50 514x 4x 4x 4x 4x 4x 4x 4x   4x 4x 4x 4x       4x 4x 4x 4x 4x 4x       4x 4x     4x 4x 4x 4x       4x       4x 4x               4x  
const express = require('express');
const { connect } = require('../db');
const http = require('http');
const socketIo = require('socket.io');
const cors = require('cors');
const Socket = require('./socket.model');
const { transporter, verify } = require('../utils/mailer');
require('dotenv').config();
 
const userRouter = require('../routes/user');
const channelRouter = require('../routes/channel');
const workSpaceRouter = require('../routes/workSpace');
const messageRouter = require('../routes/message');
 
class Server {
  constructor() {
    this.app = express();
    this.port = process.env.PORT;
    connect();
    verify(transporter);
    this.server = http.createServer(this.app);
    this.io = socketIo(this.server, {});
  }
 
  middleware() {
    this.app.use(cors());
    this.app.use(express.json());
 
    // End Points
    this.app.use('/users', userRouter);
    this.app.use('/channels', channelRouter);
    this.app.use('/workSpace', workSpaceRouter);
    this.app.use('/messages', messageRouter);
  }
 
  configSocket() {
    new Socket(this.io);
  }
 
  execute() {
    this.middleware();
    this.configSocket();
 
    // this.server.listen(this.port, () => {
    //   console.log(`server started in http://localhost:${this.port}`);
    // });
  }
}
 
module.exports = Server;