Logging nodejs microservices application with winston - node.js

I wrote server side application that is devided to serveral microservices all of them currentlly written in nodejs. Im using winston as my logging library. Im using also elk to monitor my logs. Recently, i discovered i cant monitor my logs comfortably, and i need a way to view in the kibana the request all the way in my microservices. I mean, i want to view all the logs from the one the request entered the first microservice, until she sent back from the last microservice it went threw. I dont have unique id to my requests or entities that sent, so i need to generate new unique id to each request. but i dont want to add the generated id to each method in my application. There is an elegant solution to do this without changing all my logs? Thanks alot.

Related

How to implement a Node.js service for checking an endpoint at regular intervals

I'm have built an app that the user save package tracking numbers and then when tapping on them the app sends a request to the parcel provider and gets back the tracking info. Pretty simple.
What i want to do is to create a backend server that stores the user's tracking codes and checks them at regular intervals. When the status change then the user gets a push notification.
My thought is to use a Nodes.js server with a MongoDB database but i'm stuck how to implement the tracking code monitoring on the server. Should i use a timer? Is there a better/simpler approach for this?

simple react app with fetch from Bigcommerce API

I'm relatively new to react and wanted to create an app that uses the Bigcommerce API to change product data submitted by the user through a form. My idea is to have a simple form for the user to input a quantity, for example. Once the user submits the quantity the want to change, the new number will be reflected on the product page on Bigcommerce Admin pages.
I have already created the same kind of app with Node with no front end. The app I made reads a csv file and calls the proper APIs to update their quantities. I wanted to create sort of the same app but in React with no csv reading abilities. I am having trouble with CORS errors now for some reason. I tried creating a backend with Node for this React app but I still get the same error.
I tried some other API. one that does not require authentication and that worked fine. I was able to see results when I do the console.log(data).
It seems that this Bigcommerce API won't work because it requires authentication, which I already have made on their backend several times to double check my work. I'm confused and not convinced that there is no way for a react app to fetch data from a remote server with credentials.
I figured it out, but I'm still convinced that I can do this with only a front end application in React. Without Node, However.
What I did was create an endpoint with Express using Node as the backend. Installed cors modules, then allowed requests coming from the front end URL address. Also, pay attention to whether you are using localhost:PORT# or 127.0.0.1:PORT#
to the browser these are different. Make sure they're the same when you open up the browser.

Send notification with Flutter and SwiftUI apps from Node.js API

Me and my friends are building the same app on different platforms, but with a single RESTful API built with Node.js and MongoDB. If, for instance, a user changes something, like a setting, and the setting gets updated in the database, how can I make it so other users get notifications from their app? Like one user sends a friend request to me, and then I get a
notification with the friend request. This applies to both Flutter and SwiftUI. It seems weird for me, because working with this API, it's only about requests and responses, and I don't have any idea how to make the API trigger notifications on the app. So please, tell me a way to do this, or something I can look into. Thank you.

A way around a Chron script

Is there a way to do the following in a SPA:
Add User
Update list of users, for all other logged in users, with the added user if they are in the User List Module of the application. Do this without a chron job constantly checking if there is a new user.
Almost like forcing a response without a Request. Is this a Unicorn?
I am trying to see if there is an efficient way of doing this.
Technologies are NodeJS, Express, and React on the client.
You could try setting up a websocket connection between your logged in users and your server. That way, you would be able to push a change (like a new user being added) to all your clients. However, all the clients would still need to be constantly online. Try looking into socket.io as a gentle introduction to websockets.
You could also try looking into WebRTC and other P2P web technologies, though I'm not sure if that would help you in any way.

Making Firebase and Angular2 project

I'm new at Firebase, I'm starting making a project which has to include Firebase and angular2, but I am such confused about how to implement them. I don't know if a there's the need to have a Back-end implementation (like Java or NodeJs) to handle some security issues (like form validation, authentication, routing etc), or it's enough just implementing Angular2 to handle all these issues. I would be so Thankful about any helpful advice how I could implement these both technologies to build my project successfully. Thanks
first firebase is something like your backend firebase can safe get and send request as your backend apps...
and angular js will do the rest like you just said andd all the backend stuff you can handle by firebase :)
This is my simple explanation on how this 2 works together
Always keep in mind that Angular works only in front-end. Its domain is the look and feel, application events, sending data to server and anything else that has something to do with displaying data is coded in this area.
Backend services in the other hand interacts with your database, creating business logic, handling authentications, saving / sending of data and other stuff that interacts with the database is coded from here.
Now how these two interact is done by the frontend service to send HTTP requests to the Server which is the backend service. This is done by using Angulars $http service or the so called jQuery AJAX or the infamous XMLHttpRequest JavaScript native. New technologies today utilizes Web Sockets which is being used by Firebase and some other frameworks, Web Sockets offers a faster way sending / fetching data from server.
The server then interprets the data being sent and send appropriate response. For example getting user list, saving profile, getting reports, logging in, etc.. It would work in this workflow.
1) Angular sends http request to server to get list of users.
2) Backend service installed in the server then interprets the data being sent.
3) Backend service then gets list of users from the database.
4) Backend then sends the data back to the frontend service.
5) Frontend then recieves server response and displays the data to the view.
Also these two is coded separately. To have more detailed explations research about how frontend and backend services interact you can find so much resouces in Google.

Resources