DCtheTall / node-video-chat

A working WebRTC video chat app backed by socket.io and Redis. It also uses GraphQL for user authentication and instant messaging.
https://dcthetall-video-chat.herokuapp.com
96 stars 42 forks source link

Missing build documentation #23

Open DCtheTall opened 4 years ago

DCtheTall commented 4 years ago

Multiple issues have brought up that the local build process is confusing or unclear. There should be build instructions added to the README.

Cybertwip commented 4 years ago

I'm trying to build the server, I managed to compile and run, but I'm at the point of rendering the pug template and it does not work properly.

What are your steps to run the signaling server? Is it bundled with the client? What is the logic behind rendering the React application that is being compiled with Webpack?

TypeError: C:\Source\TJSM\node-video-chat-signaling\views\index.pug:1
  > 1| - let app = manifest['app.js'];

    2| - let styles = manifest['app.css'];

    3| - let vendor = manifest['vendor.js'];

    4| head

Cannot read property 'app.js' of undefined

I added this to the server app.js file

app.get('/', function (req, res) {
    res.render('index');
});

Otherwise there will be 404 errors for everything

Cybertwip commented 4 years ago

I think the graphql server is the one connected with the React app.

Heroku gives me an error while deploying the signalServer, but I think it's related to the way we pass it the database url

DCtheTall commented 4 years ago

I think the graphql server is the one connected with the React app.

You are correct! Since we use Apollo's server side rendering algorithm to populate components with some data, the GraphQL server handles serving the views.

The signaling server will just be contacted by the app's internals, once it is up and running you just query the address of the GraphQL server to get the front end. This should probably be documented.

Heroku gives me an error while deploying the signalServer, but I think it's related to the way we pass it the database url

Can you elaborate? Both servers are given the database URL the same way.

I think the signaling server should probably not even be aware the SQL database exists, which was an oversight on my part.

Cybertwip commented 4 years ago

This is the .env file I'm using, it no longer says anything about the database but fails to query, looks like a Postgres version conflict.

This is one of the errors

original: error: operator does not exist: integer = boolean
[SequelizeDatabaseError]: operator does not exist: integer = boolean

What version of Postgres should I be using?

Cybertwip commented 4 years ago

Inside ContactRequests.js there is another error

    try {

      const pendingRequests = await models.contact_request.findAll({
        where: {
          recipient_id: req.user && req.user.id,
          status: models.contact_request.statuses.PENDING,
        },
        include: [{
          model: models.user,
          as: 'sender',
        }],
        order: [['createdAt', 'DESC']],
        limit: 100,
      });
      await Promise.map(pendingRequests, async (request) => {
        if (moment(request.createdAt) < moment().startOf('day').subtract(1, 'month')) {
          request.status = models.contact_request.statuses.EXPIRED;
          await request.save();
        }
      });
      return pendingRequests;
    } catch (err) {
      console.log(err);
      return [];
    }

req.user and req.user.id are undefined, which I suppose are passport or jwt validations, for which the error throws:

WHERE parameter "recipient_id" has invalid "undefined" value

Cybertwip commented 4 years ago

If you explain me the workflow I can help you with the migration, I'm reading your code and figuring out what could be wrong. There are calls to Postgres queries that shouldn't be happening until the user has registered, by using req.user and req.user.id, and some weird casts between integers and booleans.

DCtheTall commented 4 years ago

@VictorJL at this point it's probably better to move this discussion about your errors to another issue. I'll investigate when I have a chance.

Cybertwip commented 4 years ago

No problem. I'm also up for documenting the setup steps I had to face while running the app.

DCtheTall commented 4 years ago

@VictorJL a PR is welcome if you want to add it to the README. I guess my "review" will be trying to reproduce since I haven't manually built this project in quite some time 😆