Where do xml files fit in a js project directory structure? - javascript

I'm working on a js project that follows this directory structure:
/doc
/src
/test
/etc
This client-side js app can be configured by a server app (a whole separate application) via json. We define the structure, attributes, attributes description and allowed attribute values for that json data using some xml files. Those xml files are parsed by the server app so it can send a correct json object.
Should I create a new "dist" directory for that xmls as they are distributed to the server app team. Or should I put them in my doc directory as they in some way document the interface between the server and client apps. Or should I do something different? I'm asking for best practices.

Sounds like these files are a resource, so I would put them underneath a resource directory. Probably something like /src/resource or /resource.

Related

Angular 8 not under rootDir when i add json file

I have added some json file to my library, but when I build it there is error my.json file not under rootDir.
Assuming you want to access the .json file as part of the application build process (i.e. not via http), you will will need to put it into the assets folder in your project.
More information about the folder structure of an Angular application here.
You can then follow the instructions here to access the data from your components.

Get contents of a web directory with angularJS

Say I have a web dir someserver.com/json/ that has directory listing enabled.
And say in that directory I have several <vcenter name> directories.
And say that in each someserver.com/<vcenter name> directory there is a bunch of JSON files.
Assuming that my AngularJS app is running on someserver.com.
Is there a way in angularJS to get a listing of the vcenter dirs and json files within?
I plan to build an web app that parses info from all the JSON files and formats them into individual tables.

Where to put compiled JS in NodeJS app

I am building a NodeJS application and I am not sure where I should compile my Javascript to (i.e. minified and uglified Javascript) and how to structure my app.
All the examples I have found online say to simply make a /public directory and put all the JS in there.
The problem with that is that even if I serve the Javascript file app.min.js from /public/js, it is still really easy for someone to figure out that at public/js/app.js he can find all my original javascript code and steal it.
What is the proper way to structure the app so I can separate development files and distribution files?
You put your public JS files in a directory that your node.js server serves up to the public and you put your private source files somewhere else that your node.js server does NOT give any access to the public.
Simply don't put private files that you don't intend to share anywhere in the same hierarchy as your public files that your node.js has routes configured to serve.
Remember, your node.js server ONLY serves files or directories that you have explicit routes for. So, just make sure the private files are somewhere other than those directories containing publicly served files.
There are lots of different ways to structure it (and none is any more "right" than any other as it depends upon what else you have in your file structure). For a simple system, I create a specific "public" directory below my server and I put all public stuff off of that. I can then use express.static() routes for the public hierarchy and nothing private ever gets shared.

How to reference JS and CSS rails assets in production with a URL?

In my Rails production environment, I want to have a certain JS file and certain CSS file on my server that are not precompiled and included in the asset pipeline. In other words, I want to be able to reference the files with a URL, like this:
https://mywebsite.com/example/my_javascript_file.js
How do I do this, or where do I place the files on my server so that they can be referenced in this way in production?
I could add these files to the public directory, is that best practice?

forwarding to a html file whose directory name changes

I have folder structure like the following
-> Parent folder
---> version_HTML (folder)
-----> index.html (file)
I would like to use an HTML file with javascript at the version_HTML level which will look for the file index.html in the subfolder and open it, as the folder name will keep varying.
The HTML file will be run from the local directory, and will not be hosted on the server or WWW.
I am open to alternative solutions too.
Any help is appreciated.
As I understand you want to create a file on the server from a web page, it's not possible only with Javascript, and the way to do it is non trivial for a non developer.
The parent's name is not so much important since you can ask "create a file on my parent folder" but it has to be done by a server-side language, you can look at PHP, python or nodejs.
Also you'll need to send a AJAX request from Javascript to the server when you want the server to create this file. I insist, is not easy for a non-developer.

Categories