O'Reilly logo

Firebase Cookbook by Houssem Yahiaoui

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Now, go back to your NodeJS project that was created in the first recipe. Let's download the node.js socket.io dependency:
       ~> npm install express socket.io --save
  1. Socket.io is also event-based and lets us create our custom event for everything we have, plus some native one for connections. Also, we've installed ExpressJS for configuration sake in order to create a socket.io server.
  2. Now after doing that, we need to configure our socket.io server using express. In this case, do as shown in the following code:
      const express = require('express');      const app = express();      app.io = require('socket.io')();      // [*] Configuring our static files.      app.use(express.static('public/'));      // [*] Configuring Routes. app.get('/', (req, res) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required