Electron like node integration in nodejs web server - node.js

I'm new to web servers in nodejs and i'd like to know if there is possible to have an electron like node integration in a web server (to be able to use nodejs in index.js script file linked to index.html)
Thx for all :)

It's not possible. Browsers control the way that client side JavaScript is executed, so it's just technically impossible to connect both runtimes in any way that works on client machine, you'd need a customized browser, which is what Electron basically is. And neither should you want to - if the runtimes were connected in that way, any user could execute arbitrary commands on your server.

Related

Chatbot using Api.ai nodejs angular socket.io

I have been using api.ai javascript SDK on angular to build my chat app to integrate it with the website. As this javascript sfk is deprecated I am now exploring to build the same on Node JS SDK with socket.io for real-time experience and angular for client features...
Currently, I'm following the below link to build my chat app
https://codingblast.com/chat-application-angular-socket-io/
As I am very new to Node I have lots of doubt like...
How to deploy my node and angular app on a server to host it on my website
Angular and node can it be deployed as a simple app.. if so what are the steps and how could I achieve it.
Is node is possible ti have multi threading as many users might chat with my chatbot in parallel before on angular it will be acheived by session id.. but how it is possible on the node?
Is it fine to deploy my node app on my existing apache server or should I use separate server
How can I host multiple node js chat app on a single server since each app will use a port... how much it is possible...
Which server is recommended for node deployment windows ubuntu or Linux.
Please help me...
Angular Apps are static files that can be served using any server. For NodeJS, you will need a server that supports NodeJS runtime execution environment. A simple cloud server will do. (AWS or others that you may prefer)
Angular runs on the client-side, NodeJS runs on the server-side, there is no "Simple App Deployment" (as far as I've known). You need to run the NodeJS server code which will server the REST API, and send the Angular deployment files to the client with some file server. (Even the NodeJS server can do it)
"Node.js is a single threaded language which in background uses multiple threads to execute asynchronous code" [Source]
But you can use "fork" to run parallel tasks. For chatbot, you may consider using WebSockets.
It is possible to run NodeJS with Apache server, but how you want to deploy it depends on your decision and architecture. See HERE for more information.
Link in no. 4 should have answer this this.
NodeJS can be deployed on both Windows and Linux(Ubuntu) environment. It depends on how much you can spend, and how much benefit that expenditure will bring you. (Linux server operating systems are totally free, Windows servers aren't)

Run node.js app with node-webkit?

I have a nodejs app with modules, views etc..
Is it possible to open this app with node-webkit instead of opening it in the browser ?
Thanks.
Yes, it is. Node-WebKit is a package with browser + node web server. But I believe you will probably want to change your architecture, because you don't need the client-server style. If you run your app without any changes, node-WebKit will act just like node server and you still need a browser to access the app. There is no reason to use node-WebKit instead of pure node in this case.
To use node-WebKit embedded browser you should know that there are no need to start node server. The browser's JavaScript environment is already connected to node and you can execute node commands and packages direct from the JavaScript files (eg.: access file system from the browser, a dream to every web developer). It's like you are running a browser inside the server, without the need of make requests and receive responses... For this reason you don't need to use packages as socket.io, cause the communication is already established. But you can use the fact of node is a server to easily establish communication between different machines, for example.

Integrate Node with Phonegap app

I want to develop an hybrid cross platform app that creates a socket connection to given Ip.
I have achieved it using webTCP module in node.js by running node from cmd to start the server.
Now I want to pack this in to an app using Phonegap. But my question is how do I run node(to start server) in mobile through the app created using phonegap.
Do we need to install node in mobile. If so how can I do that?
Thanx in advance.
nodejs isn't done (yet) to run on Android. NodeJs is a server thing so it should run on your server to run tour backend.
In order to do what you want to do you will have to redesign your architecture.
Indeed, Cordova/PhoneGap is a little server (actually it's is a WebView but you can approximate it to a static content delevery server). So you will have to made your cordova app talk to your node-server.
1. CORS
Cordova-app <- INTERNET -> Node-server
The first thing to do is to enable CORS, for nodejs and whitelist the adress of your node-server in cordova
2. let's talk
Now you can start talking to your server with your cordova app, there is many ways to do that :
xhr/Ajax request
Pur WebSocket (you will need to enable JAVA-WebSocket)
Socketio
3. being more powerful
You will need more powerful feature between your app and your server side. In order to do that, you could need some WebApp framework. Indeed, they automate for you the connection between the server and your application and offer you a cool and easy environment to do great apps. If you want to know more about it, you could look at
BackBone
Marionette
AngularJs
Hope that help.

Building Single Page Application without doing any Server Side Development

I am new to any JS framework and hence I am planning to build a SPA without using any Server Side Development using Ebmer.js. Since everything need to be done at the client side, can it be done without using node.Js which does provide some server side functionality ?
Basically I would like to build a login page functionality so that user can login only when they have provided correct credentials.
To build a SPA, you can go through different framework like jQuery Mobile, Sencha Touch which are AJAX based completely and needs a server. To simulate a server and to handle AJAX request you need to host a local server. Sencha has provided Sencha CMD 5.x which you can install in any system (Windows, MAC, Linux). After installing this software you just have to browse to the folder which you want to deploy on the server.
.
Open Command prompt or terminal,and type the command sencha web start.
After this you can access your application through a local server hosted on port:1841.
You will get an access to your file system as shown below.
And the result is like

Is using node.js is suitable for web GUI app and using same source for desktop app?

Im thinking about using node.js for web application , that is something like tomcat with servlents or Apache and php.
my questions are basic but fundamental:
1. can i use node.js as web server? using jquery and all the server side stuff?
2. i want to let the users to be able to use the application in offline mode , and let
the user to download the web app as desktop app .
can node.js be good for this job ?
Node.js is a platform for creating server-side and networking applications. You can use its HTTP and Socket support to create a web server.
And yes, you can use client side libraries and frameworks like jQuery, Angular.js, Ember.js, etc etc. by using a Node.js REST API as backend (as a possible solution).
You can make desktop applications using:
Node-QT bindings
Appjs

Resources