Node Js files protection - node.js

How can I protect my Node JS files to achieve similar behavior to a PHP file case? I would like to defend it to make it unable to download or display the inner content if anyone knows the URL of the file on the server.

Unless your Node.js server serves its own application directory as static files (or if there's a separate web server that expose them), the source code is not accessible.
Unlike with PHP, the JavaScript source code doesn't need to be anywhere near the hierarchy served by a web server.

Related

Vue Frontend + NodeJS backend - local web app (browser)

I need to create an application which will be ran on the browser (local only, not hosted online). I will need to use a lightweight database which has a physical file (eg SQLite3, so I can have a .db file).
Also, just to mention:
I cant use IndexedDB alone to save the data because clearing browser data would clear the entire "database".
I also wouldn't be able to use electron since the bundle is too big. I need the browser for its portability
Also cant use PouchDB, since due to security constraints, online sync (CouchDB, etc) is not possible. Then it would be 100% stored in IndexedDB, which brings me back to my point on bullet 1
My question is - is there a way to create an offline web application build with VueJS frontend + NodeJS backend? I only need NodeJS because SQLite only works on the Node environment.
Deployment is preferably in .html only (is there any way that is possible, and access only using the file protocol file://)? Otherwise, I may consider using a local web server (localhost) - I'm not sure though if it is possible to serve an html file without any installations (node, python, etc), so I would still have to check all my options about this.
Any thoughts?
I am still new to this so please bear with me! There is very limited info online that talks about a 100% offline web application. Thanks a lot!

React plugin to write files to server in development mode

I am looking for a ready solution for the React development mode that allows modifying server-side files from the client-side scripts.
How it can work? For example, it is a small server script or an extension for create-react-app that can receive upload requests from the client-side script to modify source files.
I need to renew several source files (files2) automatically when other source files (files1) are modified. The client-side react script will process the js object taken from the custom webpack loader, that loads source files1, then I need to renew some source files2 that is using by another webpack loader.
This scheme will not be active in a production mode.
I know I can write my own nodejs based server that will communicate with my client script and modify files, but I am looking for existing solutions and furthermore, I'd like to use the same connection that React development server created to avoid CORS headaches, etc.
Do you know something good about this?

"installing" pixi-display in node.js / pixi.js

This is I'm sure a simple question but I'm struggling to find the answer with my limited knowledge of node.js environments.
I've got a Heroku hosted project built in node.js. I've got an index.js file that serves the index.html file to the client.
How do I include the file "pixi-display.js" in the HTML file so that I can use it on my client side code? Right now I can't even load it in my local environment.

Server-side file system browser

I am creating a node.js web interface for an internal project in the company I am working at. The web page should allow users to select a file that is in the server memory disk for processing. I want to do something like a file browser but for the server-side file system.
I tried implementing it with jqueryfiletree but was not successful since I can not seem to put it to work. Is there any cheap trick or an useful package to do this?
Thank you in advance.
Using node.js you can get all files names in folder, using the fuction fs.readdir(). After that you can read file by name fs.readfile() and send him on client by http.
I think this is simplest solution.

Node.JS mock entire website and host it locally

I'm looking for a way to download an entire website contents and store it locally in my server so I could serve it later to clients.
Something in the line of proxying just that I want the files to be served from my node server and not from the remote server. I've searched for modules that can help me achieve that but have failed to find one.Does anybody knows about such module or perhaps how to do it in a native way?

Resources