Trying to access Redis via React: Can't resolve 'hiredis' - node.js

I've created a simple react app via create-react-app and I'm trying to access my Redis DB using the node redis client.
When I start up my app, I receive the following error:
Module not found: Can't resolve 'hiredis' in
'/Users/Joseph/workspace/chatbots/diagnosis-bot/symptom-search/node_modules/redis/node_modules/redis-parser/lib'
I have a feeling it is because redis is actually made for node and not react, but still want to know whether there is any workaround this without having to make a separate back-end node app just to access Redis.

I do not know of any way you could connect to Redis without an intermediary using React.
There are security issues with trying to connect directly to Redis from a front-end application: you would have to expose users to your connection details.

Related

Subscribe to a Redis Server through VueJS

I am currently working on an application with the current tech stack:
Backend:
Mongoose
Express
Apollo
GraphQL
Frontend:
Vuejs
Apollo
GraphQL
So since I am a beginner with GraphQL I had no idea that apollo's inbuilt subscribe PubSub cannot be used in production and has no method of scaling without using services like Redis.
That being said, I have started a local Redis server for testing it, I managed to start a Redis Client in the backend using ioredis and it connects fine to the Redis server. I have now a problem that I can't start this up on my Vue frontend in order to receive messages being published by my backend. The creator of ioredis suggested that it is only for backends and I should use something else for the frontend.
I am currently confused as to how should I go about listening or subscribing to the redis server from my Vue frontend so I can receive published messages? Maybe I am looking at this in the wrong way? Any help would be appreciated.
Note: I have already done this with apollo/graphql's inbuilt subscribe but like mentioned, it can't be scaled.

Angular 6 webapp that connects to PostgreSQL using sequelize-typescript

I'm using Angular6, PostgreSQL and sequelize-typescript. The goal is to connect to a DB and get a list of names and ages into a table.
I started by creating an Express server.
I then used sequelize-typescript to connect to my PostgreSQL DB and call this connection when initializing server
I created a model of my data element using sequelize-typescript and using it to connect to my PosgreSQL DB.
I then created a simple route to the data using Express Router
I added the route to the initial Express Server
This all seemed to work (albeit messy as I'm learning as I go). But I can reach my local server through the browser (localhost:3000) and use PostMan to get the data from the DB (localhost:3000/people).
Client side:
I already have the initial front-end app that was created with I ng'ed the project using command line. I can reach this at (localhost:4200)
I created a simple component called people using ng g component people.
How do I get the data from my server route into the client component? I believe it's through HTTP and then subscribe but there seems to be a lot of different ways to do this. I'm looking for advice on the best pattern to use in Angular6.
TL;DR How do I get the data from my route to the front end
I finally got it working correctly, I needed to create a service that listened to the API url and from there I could return the observable to the component.
The solution (even though it's not cleaned up properly) sits at:
https://github.com/micklynch/travelbudget

Deepstream.io. Node Api vs NodeJS SDK

I have one misunderstanding with Deepstream.io. It has both NodeJS SDK (which can make client for deepstreamHub from my node application) and NodeApi, which allows to install deepstreamHub as npm package. Why do we need both of this options? When should I use each of the option?
For example, I have existing realtime node app, which uses socket.io as transport layer. And I want rewrite app and migrate from socket.io. What option should I use? Install deepstream as a package in existing app and call my app logic in RPC callbacks, or install standalone server on computer, then install deepstream.io-client-js in my app and also register my app logic as RPC callbacks, using ds.rpc.provide ? I do not understand difference of two approaches
It looks like there is a misunderstanding between deepstreamHub[1] (the cloud platform) and deepstream[2] (the standalone server).
If using deepstream the server, you'll likely need to host it yourself on a cloud provider (AWS, Azure, etc). With deepstreamHub you get given an application endpoint which you can connect to and a dashboard to manage your application permissions, authentication methods and data.
Either way you'll need to install the deepstream.io-client-js module in your application, you can then connect to your server or your application endpoint (if using deepstreamHub).
After this you can register app logic as RPC endpoints and proceed to write your app logic as normal.
[1] (https://deepstreamhub.com/)
[2] (https://deepstreamhub.com/open-source/)

How to catch un-handled exception in Meteor + NodeJs application

we are using Meteor + NodeJS application. Meteor application use for communication for client and Nodejs application for connect to DB. We gave the nodeJS application reference in meteor application.
When any un-handled error occurs in nodejs application we are not able to catch it.
We deploy the meteor and nodejs application as a package.
From Meteor we called nodejs methods using Meteor.wrapAsync(node.method1).
we are able to catch the exception in meteor till callback from node method. After callback if any exception occurs in nodejs method we are not able to handle it.
Thanks for your replay
Since there isn't any code presented here, I'm going to assume that you have the following scenario:
You have a Meteor application that calls services that are hosted in a different node server.
The node services are sharing the same database as the Meteor app.
Clients only interact with the Meteor app.
Meteor is using its own embedded node server, so service calls to the other node app is actually a communication between two different node servers, which means that they have their own call stack, hence they can't handle each other's exceptions.
The only way to communicate errors between the two is if you handle the exceptions in the node application and send error codes to the Meteor app. They can be either HTTP codes, if you're using ajax, for example, or your own kind of error codes.

share mongodb between nodejs and meteor

I just finished a REST server application in nodejs using express, passport and mongodb
I want to create a meteor app for the LIVE Statistics of that mongodb REST api's , like number of connections, user online etc.
But I can't figure out a way to use custom mongodb with meteor. Basically I want to share the same database with nodejs/express application and meteor.
Is it possible? I am sure it should be, but I can't figure out HOW!
Help please!
Okay, I got here what to do.
While deploying meteor, they have an option to choose the database.
So i created an app on meteor and then deployed it for nodejs
here is how,
meteor bundle myapp.tgz
extracted myapp.tgz and used the command below.
PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js
Here is complete doc : http://docs.meteor.com/#deploying

Resources