Is Node.js applicable here? [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've got a plan for four systems: A, B, C and D.
System A is to hold a small database which will accept information from the other three systems via HTTP requests--I'll try to implement a RESTful service here. The other systems only talk to System A.
System B and C both produce a .csv file which I need to monitor for changes and then send their contents back to system A with a timestamp. I'm afraid that while communicating back to A, a file change might be made but the system will ignore it because it's busy.
System D will be run by the client on a browser.
Is Node.js appropriate to run on systems B and C? To monitor the file changes and send some PUT/POST requests to System A? In the rare case of an update taking very long to occur on System A, will Node.js be able to send another request if it sees a file change while the first one is trying to finish? I've never used Node, but I feel like this is what it's good for. I'm willing to give it a shot.

I'm afraid that while communicating back to A, a file change might be made but the system will ignore it because it's busy.
Well worry not because node is built from its very core to be asynchronous. It's very tagline is:
Node.jsĀ® is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
You could certainly use other languages/platforms to solve your use-case as well, but node was practically designed for stuff like this :)
I play a game called Hearthstone and the game generates a log file of what happens as the game progresses. I wrote a little log watcher module that monitors the Hearthstone log file. This code snippet is the portion that monitors the file.
So far my app has never missed any lines in the log file since each of the file change events are queued up as changes happen. My app doesn't block while waiting for file changes and then processing them. Instead, node adds events to the queue and checks their status with each iteration of the event loop. Eventually it processes all the file change events no matter what.

Related

Applications / code security [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a 5 applications(programmed in 5 different languages) deployed in one common web server and these applications are written to work on a particular task and create a log file for any action. How can we achieve a security of log file by not being over written by other applications?
First of all, if you don't trust one application to not clobber the log file of another one, then you have a really serious problem. `Cos the applications could also do other more harmful things. If the applications are believed to be insecure or untrustworthy, the most secure answer is to not run them at all.
If you are concerned that applications might accidentally write to the same log file1, just configure them to use different log file names or different log file directories2.
If you are simply trying to secure the logging, then one solution is to do your logging via an independent (secure) logging service such as Linux syslog.
Another approach is to create separate accounts for running each of the applications, and make sure that you set the file and directory access so that one application doesn't have permission to modify another's log file.
1 - Actually applications can safely write to the same file if they all open the logfile in "append" mode. Log file rotation could be problematic though.
2 - You've probably already thought of that.
If your logs are stored in a commong log folder, then a simple solution would be to have proper naming for logs of different applications
e.g.
pythonApp_log_timestamp
aspNetApp_log_timestamp
This way applications will write to its designated logs and not overwrite other application's log and would work irrespective of your hosting environment linux or windows.
Also you could limit the file size of each of the log file that your applications create, this way you could ensure that applications create new file if specified file size has been reached and not too much data is dumped into a single file, this will help in debugging or verifying the logs later.
I use this method in my application and helps me find the log from specific duration and not searching logs too much.

How to distribute a Node JS Application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I developed a Node.js Application that I would to like to sell to my clients on monthly charges.
I'm looking for solutions to:
Keep my source code safe
Easy client installation
Serial code solution for activation
Application update method
Any advise will be appreciated.
Similar Question: Secure distribution of NodeJS applications
Your goals
Keep my source code safe
The only way you can do it is by making it a Web application that is used as a service instead of being distributed to the client. Don't trust anyone who tells you about code obfuscation or encryption as this is inherently impossible.
Easy client installation
Nothing easier than a Web application.
Serial code solution for activation
For a Web application you don't even need that. And for any application that you distribute to the client it will be trivial to circumvent and there is no way around it.
Application update method
Web application is always up to date. For a distributed application you can take a look at the Electron auto updater.
Any advise will be appreciated.
General advice
My general advice would be to keep in mind that any Node application that is distributed to the client will be very easy to analyze the source code and to circumvent any activation features that you implement. The only thing you can rely on in that case is law, not technology. Make sure that the licence is enforceable and the terms are clear. Distributing the source code doesn't mean that it has to be open source. The license is what's important, not the visibility of the code.
Your options
Depending on what the application does and how the interface looks like, something that you said nothing about in your question, you have few options:
Distribute the application as is and rely on the license to protect you but understand that anyone could be able to analyze your source code no matter what you do. Here you need to manage updates for every change. People will be able to circumvent your activation code feature.
Make it a web application and keep its inner workings completely to yourself. Here you have no updates problems or source code visibility. No need for activation code, you can give access only to paying customers.
Make it a service and keep all the important logic in your backend API and distribute only a thin client that uses that API. You only need to manage auto updates of the client, the backend code is always up to date. You don't need to implement activation codes, people can just log in to the account on your system in the client program and your backend will know who is a paying customer and who's not. The only source coude visible to the client is the client side code which can be minimal and doesn't have to include any critical logic.
Of course it all depends on the nature of your application which you said nothing about.

How to let people collaborate on same form with real time updates? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a html form with some fields that are linked to a database row that have to be modified at the same time by different users.
Every time one of the users edit an input field it may call a javascript onchange (or similar) function to update the specific column in the row, but the other users that have the same page opened don't see the change until they refresh the page.
What should I use to get it changed on all devices that are looking the page?
The backend is in PHP/MySQL.
Thank you
You have a way to send pushes to your backend server but now you need to get pulls from your server.
For this purpose, you need to maintain a constant communication channel between your client and server to get real time updates from your server. There are multiple options for this:
Websockets: A TCP websocket can be used for real time communication between server and client. See this thread to get more information about websocket support in PHP.
Polling (very dirty way): you can do frequent poll from your client to your server to see if there has been any updates or not. This way of implementation is really inefficient and not recommended at all but still, since some applications already have polls in their system, if your system is already doing frequent polls, you can attach the query to get form status with that poll.
There are a couple of possible approaches.
Have an ajax request in the client periodically poll the web server to retrieve the data. Though depending on how this is implemented, there could be some performance ramifications.
You could benefit from using WebSockets. Since you're using PHP and MySQL you might look into something like Ratchet. Depending on how far along the code base is you could potentially implement something with socket.io using node.
When you look for some already existing tools, this might something for you:
https://fusion-tables-api-samples.googlecode.com/svn/trunk/FusionTablesFormSync/docs/reference.html
When you do not find anything that matches your needs, you can write it on your own. Therefore you need Ajax (To transfer a change to the server), it is more easy to use in combination with jQuery.
http://www.w3schools.com/jquery/jquery_ajax_intro.asp
And you can also fetch the data from the server with ajax, but you have to do requests all the time, which is not very nice. An alternative would be websocket, but this need a lot of knowledge.

what is the difference between LAMPP and METEOR [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can anybody explain me what is the difference between LAMPP and METEOR js framework?
Thanks in advance.
There is quite a big difference between the two.
LAMP:
This is a stack that originally (and still largely) stands for Linux Apache MySQL and PHP
The alternative of windows is called WAMP.
The linux part is the system the stack is running on; Apache is a server system where you can store and access your websites and apps; MySQL is the type of database(Relational Database); PHP is the server-side language you use to create these dynamic sites (you can also use python or perl).
The community is much larger and you can get support everywhere as it has been around longer than Meteor
If you run a linux os, you can literally download the apache server and host it on your computer see: http://httpd.apache.org/
Meteorjs
Meteor is a full stack platform that allows you to write all your code in Javascript. This means you can write the front end in Javascript, then turn around and also write the server/backend using the same JavaScript! Literally write once, run everywhere
Meteor allows you to write an app in very short amount of time as you are using just javascript.
-What really makes Meteor stand out is their "realtime" way of doing things. With mete0r, everything is reactive. When a change happens in the server, it is immediately reflected on the front-end without refresh or waiting at all!
Meteor apps come with Mongodb (NoSQL) already set up as your database system as opposed to MySQL used by LAMP. Meteor goes the extra mile by also creating a small database in the front end of your app and whatever changes you make are performed in this mini-mongo database which automagically synchronizes with the server and updates it. METEOR DOES ALL THIS FOR YOU.
-Learn more at https://www.meteor.com/ and this https://www.youtube.com/watch?v=RpQTPWvD6HA offers a great intro.

Real time collaborative use interface on the web [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm wondering what the technologies and best practices are behind real time collaboration in web interfaces.
An example of this is of course Google Wave. Another is PivotalTracker.com.
I'm particularly interested in any work (frameworks, plugins, etc) people are doing with Ruby on Rails here.
I imagine it would have to use Javascript underneath at some level, but you would need a way to abstract this out. Probably polling the server periodically to see if changes have been made, and also a way to resolve conflicts if in the middle of editing something the server comes back and says someone else has updated it.
Thank you!
Wave has operational transform that has a nice property of being easily combinable. You have two users, each of them does "something" in the user interface and two "somethings" can be combined into final document. That allows you to skip the problems with conflict resolution.
A nice way to enable real-time updates to state of the app is by using Comet, which is essentially a geeky codename for keeping an alive, long standing, unterminated get/post request to the server, that server finishes and responds to when something happens on the server. It allows sending to the client instantaneous updates without having the client periodically poll.
I can't really say how to abstract this away in javascript/r'n'r, many of the underlying technical details are hard enough and application specific that no framework supports them out of the box.

Categories