I am trying to create a NodeJS server that runs locally on the clients machine. I have all the credentials to access the db in a config file and have created an exe file using pkg module so that my client can run the exe file and have the server running on their machine.
I do not want my client to get hold of the credentials but the source code of the exe file contains the credentials. How can I safeguard the database credentials?
Store your credentials encrypted and have your program directly (or indirectly through a compiled program to further hide your logic) decrypt them on startup
Related
I'm building portable node js server using electron. I'm using SQLITE database for storing data.
In development mode I put database file test.db in directory where is my Main.js file and everything is running perfectly.
When I deploy my app electron-builder --mac and run it, it cannot access to database file. (File not found)
So my question is where should I store my test.db file so it's working both in development and production mode?
Is it possible to embed db file somewhere while creating application for win/mac/linux so end user doesn't need to take care where is db file located?
Thank you
you can store it into application data,
const dbPath = path.join(app.getPath("userData"), "sample.db")
Check out docs here,
https://www.electronjs.org/docs/api/app#appgetpathname
I don't really have experience with backend and how things work together. I have created a simple live message sending app with node.js and socket.io. When I host a static web server on my machine (http-server which runs on local port using node.js) my app works perfectly fine but when I upload it on my host or github pages just for test, the backend doesn't seem to work. I uploaded all my files with an FTP program and the frontend loads fine but the backend doesn't. Do I have to know something like Django or ASP.NET to make these work on my host?
EDIT: One more thing, first line in my server.js is const io = require('socket.io')(3000)and in my script.js - const socket = io('http://localhost:3000')where 3000 and localhost:3000 stands for local host in my machine. What do i need to put instead of these?
You probably need to install and setup Node.js on your server, contact yout hosting provider for node installation if the option isn't available in yout cPanel.
I am trying to download text file from server to local directory.
If I execute following curl command it copies myfile.txt from server and saves in same directory as newfile.txt.:
curl -o newfile.txt http://myserverip/myfile.txt
I want to automate this by running the command from javascript while loading the webpage.
For example if I open an html page (which runs a javascript) like http://myserverip/getnewfile.html in the browser the myfile.txt from the server should be copied to newfile.txt in the loacl directory.
Can anyone help me to write javascript to execute the curl command?
Please note that the server in local area network and router is configured to allow connections only from white-listed mac ids of local machines so there is no any authentication required to connect to server.
You can't run local command-line commands from JavaScript, because that would be a massive security vulnerability. The tool you want to use for this is either window.open (to open a tab with the file in order to cause the browser to download it) or the fetch API (to retrieve the file for use in JavaScript).
I am currently working on a server where I want to autorun a file whenever I connect to the server myself. Example; I start the server and when I connect to it I want it to run a backup. My server is running on another computer and I connect to it from my main computer to save performance. The thing is that I also want to be able to work inside the server from my main computer. Example; The server is running on PC1 and I want to have access to the server from PC2 via vagrant.
The server is run by vagrant.
I have some experience within - Ruby, C++, Vagrant, javascript and SQL if this is helpful for the answer.
I found how to connect to the server remotely via the vagrant environment using ssh vagrant#192.168.x.x where the x.x is the ip of the local computer.
Example
IP to the vagrant server is 192.168.192.192
On my main computer I run the command ssh vagrant#192.168.192.192 and I login with the default password.
Here is my problem... I have a node server that multiple node terminals(raspberry pi) connect to. These node terminals run a series of jobs and some of them generate files. The files are not saved in the terminal but in a mysql blob. Now these terminals are managed through an interface in the server (a CRM webpage). I manage them using socket.io and there is also redis available. Through socket.io I can tell the terminal what file I want, but the problem I'm facing is getting the file to the requesting browser client. I can identify the browser via the socket id but I am not sure as to how I am going to serve that file. Any help or suggestion would be great. Note: Im not using any JS or nodejs frameworks.