neo4j server side javascript - javascript

I have a neo4j desktop (1.4.3) database on my Windows PC. in an html code, I am connectecting to the DB using
const driver = neo4j.driver("bolt://IP_ADDRESS:7687", neo4j.auth.basic("neo4j", "PASSWORD"));
After that I query the DB and display the results on the web page (I use leafletjs maps, but this is not the issue)
var session = driver.session();
session
.run(`MATCH....etc.... return ....
`)
.subscribe({
...... etc
Everything is fine so far. I run the page on my PC or from another PC in my home network, everything is fine. The setting of neo4j is (dbms.default_listen_address=0.0.0.0) no issues there.
The question is how do I expose this page to the colleagues outside my network?
Using noip.com, I got a temporary domain mapped to my external IP.
I also configured the router to forward port 80.
But when the page Javascript gets loaded on an external client, it tries to connect to neo4j on that client. When I put the external IP addtess in "const driver ..." the connection does not work.
How do I make the connection to the DB from my server, but the queries to the DB come from the client who loaded the Javascript?
Edit: Forgot to mention that I am also using Apache Web Server (Xampp) to serve the page to remote users.

A simple architecture that does what you want, plus mitigates the risk of opening up your database to everyone uses a HTTP server + API that are accessible via your noip provider.
Your public facing frontend (HTML + JavaScript (for making API calls etc)) makes the HTTP(s) calls to your publicly accessible API (for example a nodejs server) to make the database calls. Cypher/a direct database connection to neo has no place in your users' browsers.
You can also use a starter like the GRANDstack.

Related

Query Oracle database on local network from Javascript in browser

I have a Oracle database server hosting data, and I want to build a small app on my local network for people to do light data entry.
Normally we can't query a database from the browser because the browser is client-side and the database is on the server.
But what if the server and website are both hosted on the local network? Would it then be possible? The problem is I don't have a server I'm just making a small website as a file on a shared drive.
But what if the server and website are both hosted on the local network?
This does not change almost anything, maybe it makes things a bit easier when it comes to application security.
Normally we can't query a database from the browser because the browser is client-side and the database is on the server.
That's not true. You can query a database from a browser/client-side. The problem behind such a solution is security of course, because in this case the client would have to know the database credentials, which is why such operations are performed on the server side, but it does not mean that querying database from client-side is not possible.
The conclusion is that if you know the database credentials anyway, it is possible to write a simple application (which will query database from client-side) for yourself. For this you can use OracleDB module.
---EDIT---
I will only emphasize once again that you should not make such an application available anywhere outside for security reasons (availability of database credentials).
However, you can use JavaScript fullstack frameworks like nextjs or sveltekit - they are able to perform some server-side operations and then pass this data to the client. This approach would be much safer.
I'd use Oracle Application Express.
It is installed in Oracle database; lets you develop applications rather quickly (if you know some SQL; even if you don't - use wizards). The only "tool" you need is a web browser. Your users would also need it (the browser), accessing your application via local network and enjoy beautiful application you'll create.

Local node.js server connect to http website

I currently own a website, which will be used for global access and a database. I am also building devices that run a local node.js server, that forms a connection to this website.
So I guess this would be a reverse websocket? I don't own the webserver, it's hosted, so I'd assume I would use php.
I'm needing a 2 way connection that can push or request updates from both ends... Maybe websockets isn't the answer in this case?

Connect to Secure Socket Server written in C++ with client written in JavaScript

What I want to achieve:
I have a linux server connected to network which runs a database. The database is not reachable from network. There is a software which acts as a middle layer between the server and client(s). The clients would access the database through this layer. This is required because:
There will be multiple users with different permissions.
I want a common API because the client software will be implemented to mobile platform, mostly for Android and as a webpage(this is where I want to use JavaScript) as well.
I don't want to expose the database directly to clients because I would be forced to store the database's login credentials in client's device.
The client software will be used only for data exchange and displaying the result to user. Any processing would be done in server.
The part which is not clear is the webpage. I could use PHP, but I want to make it like the Google Hangouts app in Gmail or the Facebook Messenger. The content which is fetched from database is displayed without reloading the page. Since I have't done anything like this in JavaScript, I don't know where to start, which libraries I should use.
Note that the communication between the client and the server would be done over secure sockets. The middle layer would be implemented in C++ using OpenSSL.
I would suggest to connect to the server using C++ with the system() command.

connect to node server finding the mask automatically

so this is my problem:
I have a node server with a game i'm creating. the node server is listening in a ip mask that is given to him in network, like 192.168.x.x (isn't always the same).
The game 'frontend' is a web page, in a domain (like paperplane.io) that points to my dropbox project and makes it accessible.
How can I make my game frontend, the client, know behind what mask is node server listning, in that network, so it can communicate with it with no specific configuration.
Synthesizing: start node server in local network. every device in that network can access it via web url. plug & play.
thaks
Ok, so i solved my problem by having my node server sending updates to a mysql database with something like: I'm XPTO and I'm at 192.169.X.XX.
so, when i access my application i tell her what i'm looking for (i always know) like this:
XPTO.application.com
by the subdomain i check the database for key:value and get my nodejs ip mask in network.

Node.js & MySQL - JavaScript application - how to interact with offline AND online databases

I am making a web-app using JavaScript. I plan to use Node.js to connect the app to an existing MySQL database.
First of all, will the Node code be written in the same .js file as my application? Or is it a separate file?
I need the data to be current at all times (even if you were to close the browser and re-open it, AND even in the event of the user not having a wifi connection), so my thought was to constantly update the local device's db and then to intermittently update the MySQL db. Is this the best strategy? If so, how exactly can Node talk to the offline db and MySQL?
First of all, will the Node code be written in the same .js file as my application? Or is it a separate file?
It is possible to keep your client side JavaScript in the same file as your server side JavaScript, but it doesn't make any sense to do so. They are separate programs. (Library files, on the other hand, are a different story).
so my thought was to constantly update the local device's db and then to intermittently update the MySQL db.
Working with a local database and syncing to a shared one is a common strategy. You do need to handle conflicting updates in a way that is sensible for your purposes though.
If so, how exactly can Node talk to the offline db and MySQL?
Node.js can't talk to the offline database, at least not directly.
You will have a web application running in the browser. It will use client side JavaScript with a client side database and some means of communicating with the server (often this is done by sending JSON over HTTP to and from a web service).
Then you will have a server side application running in Node.js. It will use server side JavaScript with a server side MySQL database and some means of communicating with the client (i.e. an HTTP server hosting a web service).

Categories

Resources