title: Is there any possibility to use socket.io just for specific part of application?
body: <p>I am pretty new in socket.io. Just I want to know is there any possibility to use socket for certain part of application and the rest continue working with normal http RESTful API?</p>
  
  <p>To be more specific, I have develop an app with ionic 5 for frontend and nodejs, express and mongodb for backend.</p>
  
  <p>I have added socket.io into my app.js file same as below and server is listening.</p>
  
  <pre><code>const app = express();
  const port = process.env.PORT || 5000;
  const http = require("http");
  const server = http.createServer(app);
  const io = require("socket.io")(server);
  
  io.on('connection',(socket)=&gt;{
  console.log('a user connected')
  socket.on('disconnect', function(){
      io.emit('user-changed', {user:socket.username,event:'left'});
  })
  socket.on('comment',(comment)=&gt;{
      console.log(comment)
      io.emit('comment',{cmt: comment.text,user:socket.username, createdAt: new Date()})
  })})
  </code></pre>
  
  <p>My route file for discussion APIs</p>
  
  <pre><code>const express = require("express");
  const router = require("express-promise-router")();
  const discussionController = require("../controllers/discussion.controller");
  const auth = require("../../helpers/auth");
  
  router.route("/").get(discussionController.getAllDiscussions);
  router.route("/discussion/:id").get(discussionController.getDiscussion);
  router.route("/comment").post(auth, discussionController.createComment);
  router.route("/comments/:id").get(auth, discussionController.getComments);
  router.route("/search/:params").get(auth, discussionController.searchDiscussion);
  router.route("/create-discussion").post(auth,discussionController.createDiscussion);
  
  module.exports = router;
  </code></pre>
  
  <p>My controller file</p>
  
  <pre><code>const mongoose = require("mongoose");
  const Discussion = require("../../models/discussion.model");
  const Comment = require("../../models/comment.model");
  
  module.exports = {
    getAllDiscussions: async (req, res, next) =&gt; {},
    getDiscussion: async (req, res, next) =&gt; {},
    getComments: async (req, res, next) =&gt; {},
    createDiscussion: async (req, res, next) =&gt; {},
    createComment: async (req, res, next) =&gt; {},
    searchDiscussion: async (req, res, next) =&gt; { }
  };
  </code></pre>
  
  <p>Also in my app.module n front, I have added SocketIoModule and Config same as below.</p>
  
  <pre><code>import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
  const config: SocketIoConfig = { url: 'http://localhost:5000', options: {} };
  </code></pre>
  
  <p>So, everything is working fine and I can send and receive comment from discussion page too.
  What I want is the possibility of opening socket just for discussion page not enitre app and also how can I integrated with my server side controller to save into database and retrieve it.</p>