Webserver Resources when using Node Driver - javascript

I am currently building a demo for a simple cordapp, and am trying to implement a simple webpage to show an example of interacting with the node. I am launching my nodes using the node driver, and have created custom API's as well as some custom HTML and JS. I am having issues getting changes made to my JS and HTML files to propagate through to being shown on the webserver - and while I know these files are stored with the node I can figure out the correct method to go about getting the node to update these files.
I have tried removing the build folder, rebuilding the project and then running my node driver script, with no luck. I have also tried simply copying the files into build/resources, but I this also doesnt seem to work and I am not sure if this is where nodes run using the node driver actually pull their web resources from. Is there anything I am missing here? Could anyone potentially point me in the direction of a better process to develop and test this? (rather than having to re run my node driver everytime I make a change to either my HTML or JS files)

Turns out the issue had nothing to do with the Corda side of things, but rather developing in chrome. Due to chromes caching for some reason old JS file were being used. Resolved by flushing the cache using Ctrl+Shift+R (See Disabling Chrome cache for website development)

Related

Revert build process Ionic 4

I built an application using Ionic 4 for my android device and it runs pretty well. For some reason I lost the source of the project (not completely but most of it), so now the only possible way to retrieve it without completely rewrite it is to use the code inside the apk.
I managed to get it from the device, extract the content and locate the www folder which is obviously not that readable.
I would like to find a way to revert the build process that build the javascript from the typescript.
Any suggestion?

Bundle.js ReactJS file beautify

I've build a project with pure reactJS using create-react-app and I successfully uploaded the app to my server but unfortunately I've lost my laptop and all of my data :( but my project working on the site my question is:
Is it possible to get my project back again to development mode through existing files?
You may be able to use https://github.com/1egoman/debundle to un-bundle the index.js file (in the case of create-react-app, Webpack is the bundler). If the bundled file was built in production mode, you may need to use something like https://www.npmjs.com/package/unuglify-js to get it back in somewhat readable order.
Sorry to point you to libraries which may or may not work, but the truth is that you may be better starting from scratch--the real knowledge in your mind, not in the source code. You may be able to throw in some improvements the second time around... look at the bright side!
solution in here: Can I use a sourcemap and bundle file to retrieve original react code
THIS IS 90% fix.
Publish the APP so you can access it through browser (e.g. NETLIFY, can publish by accessing your Git repo) -> open the published project in the browser -> then inside the browser press ctrl + shift + i (chrome and pc).
This gives you access to developer tools.
Find: SOURCES TAB
on left hand side you will see folder structure -> click into STATIC
Now you can see all CONTENT inside JS files and CSS by clicking on them.
You can now either copy and paste them into you IDE or download them by right clicking them and Save As.

How to have web page include all js files in a directory tree?

I'm trying to figure out how to set up a JavaScript development project that will allow me to factor my code into several files. I plan to run this eventually on a client web browser, but first I need to set up an efficient development environment.
I've used other programming languages before that let you keep a large number of files in a subdirectory and then let you compile everything into your final deployable (or have an interpreter do something similar). Javascript doesn't seem to allow this - I have to manually add a <script> tag for each js file to the head of my web page to get the browser to load it. This can get very hard to manage once you have more than about 10 files that you need to keep track of. It would be nice if I could write <script src="myscripts/**/*.js"> to suck in everything, at least during development time.
I've found Grunt 'uglify' which looks like it would be a handy tool for creating a final file for deployment, but during development I need to keep everything separate so I can debug properly. Is there any way to have my web page load every js file in my development directory?
As others have mentioned in comments, Webpack (or similar) is the way to go. It bundles up all of your relevant code, and can also process it for minification.
I want to address this comment though:
but during development I need to keep everything separate so I can debug properly
You don't need, or want, that. While developing, you want to be testing against the same sort of build process you'll use in a deployment later. So, how can you easily debug your compiled scripts? There's a .map file that gets built, which tells the browser what your original code looked like.
Chrome and other browsers will automatically load and parse this file when you open your developer tools. Then, you'll be able to see the original source code (and in the original language, for anything transpiled) and debug it as if it were not bundled in the first place.
Don't deploy this map file, unless you want external users to be able to see all your original source code.

Stress testing a JAvascript file which only runs in the browser

I need to run a Javascript file for a relatively long time(maybe about 5 weeks or so at one time), without it stopping or being interrupted. Currently the script is a client side script which connects to the server and receives data via Sockjs. There is no HTMl/GUI. There is only some computation.
I need to make sure the client always stays connected to the server all the time. I need to be able to run some script from the command line which is like forever.js. I have tried porting the javascript to node.js but it doesnt work. It only works in the browser. I have tried reading the file and doing an eval but none of it works. Are there any other options open for me? I have tried phantomJS but that doesnt work too. I have looked at How can I use a javascript library on the server side of a NodeJS app when it was designed to run on the client? and Load "Vanilla" Javascript Libraries into Node.js but I reapeatedly get SockJS is not defined. I guess the problem lies deep in the library and is not a simple fix.
Could anyone give me some pointers? What are my other options? Whats the best way to test a client javascript library which seems to work only on the browser?
This is the repo I am using :
https://github.com/sockjs/sockjs-client
It doesnt seems to be running on node. I tried to replace the script tag with require, and download the sock.js into a separate file and use it.
There are "headless" browser modules available. These produce a virtual browser environment that can be programatically controlled. The primary use of these is to do unit/integration testing of browser side code without actually running a browser:
Phantomjs
Slimerjs
These might fit your needs. You can create a nodejs script that will load the said code in a virtual browser page.

whitelisting files with nodejs to hide sourcemaps

I recently integrated my error logging with getsentry.com. My problem now it that I had to generate a source map so basically anyone with a modern browser can now see my original code fully commented.
I'm looking for a way to allow access to the source map files to only specific ips and/or subnets with nodejs, since I'm using heroku.
I imagine it will involve using something like https://www.npmjs.org/package/express-ipfilter or https://www.npmjs.org/package/ip. But still trying to think of how to create a middle where to 'route' to the files and evaluate the ips

Categories