Expressjs not sure how to handle multiple users - javascript

This is more of a conceptual question. I am trying to build an expressjs app in which when a user starts I would need to make a temp folder for each user to store some files. I am not sure how to handle this scenario.
I am not much experienced on server side development and this would be my first node/expressjs project.
I am sorry no code yet as I am still clueless how to approach the above problem. I looked into express-session and my current approach would be to create a session and use session id a the folder name.
can anybody guide me towards a more robust approach.

You would need to use Node file system:
https://nodejs.org/api/fs.html#fs_fs_mkdtemp_prefix_callback
There are also lots of npm packages for this you could use which might make it even simpler.
something like this: https://www.npmjs.com/package/tmp
Since you are using sessions, get the username out of the session and then use that to along with a timestamp to create a folder name that wouldn't run into any duplicate names.

Related

What are the best tools to make an online card game?

I'm looking for some event/reactive online tools to make a card game in a browser.
I think JS is most appropriate here but I'm open to all propositions.
I already tried VueJS / Node with Socket.IO but I think it's very messy and not organized enough to make a project like this. So I was wondering if you guys knew some frameworks to make the job.
The projects is to make an online card game like poker.
Thanks !
You could try pixi.js or phaser 3+.
Also I've wright one of my card-games only using html+css+javascript.
For back-end you could use whatever you want. NodeJS + websockets is good choice!
If the main matter is the realtime database connection (for which you are looking for websockets), you could create the game and store it's data to firebase firestore, this way you could get everything synced in real time with a less pain than a node server setup, (for this purpose), if you need some backend functionality you could also work with firebase functions in order to achieve some backend stuff, also you could even store your project on firebase hosting, have an authentication ready platform with firebase auth and depending on your needs you would not even pay a penny (this really depends on the usage)
Hope this could at least be an option to consider.
Check the firebase documentation: FIREBASE
Even if you wish to work with Unity instead of VueJS you can also use firebase for all this matters.

Is it possible top upload `react` app with `mysql` to `github`?

I've made a siple web shop using react, node and mysql. I wanted to push it to github, but I'm not sure if it's possible to do that with database that's on my localhost right now?
Git is a means to version control code.
There would be no problems storing your program's source code and your database schema (along with any migration scripts) in Git.
Storing the data from your database is another story. You would need to export it. Git isn't designed as a means of storing backups though.
Github also offers Github pages for hosting static sites. That service is not suitable for anything that involves server-side programming.
yes, check heroku.its free at some extend.
i have used it for my project, with mongodb.
heroku uses postgresql but there are ways to make your mysql working.
i think there are already questions about that.

Node.js config file vs .env architecture practice and building pattern

I'm developing server side app on Node.js and I thinking about config file usage. But when I google it.. well as for now I have more questions then answers.
In my case I have a-lot-of functions with arguments different types of
sensitivity not just only secret, tokens, keys. Most of this
argument as user-depended. For example, user that launch app use to
define (via CLI [promtly]): number of days, how much times something
will execute, when and where, etc
For example I just check this question and that article. And my question is simple:
Which one to use and why? (or where can I read more about it) Using only .env file, or only config.json or probably both like in article above? Is it OK to store all settings in package.json or not? (like in this question)
I'd be very pleased if more experienced JS devs tell me what should I use and why.
Even if this question is marked as answered feel free to tell me (and everyone on SO) about your experience with such problem. But please, remember, that I'm asking not about *How to do it* or about DotEnv usage (or any other npm module). It's all about patterns & practices.
Is it OK to store all settings in package.json or not?
For sure you could theoretically do that. But you want to configure your service, and you usually run the same package with different configurations. Therefore it really makes sense to have some kind of configuration file, then you can set up different configurations for your local testserver, your development server, your production server and so on.
.env file or config.json ?
That is really up to you. However the .env file seem to not support any nested data, which I think is really useful for configuration. I always used config jsons, and that worked quite well so far.
In my case I have a-lot-of functions with arguments different types of sensitivity not just only secret, tokens, keys.
For sensitive data inside of a production environment you should really use a secret store (e.g. Vault). For local testing
environments this is irrelevant though.
Most values are user-depended
Then either store them in a config file, or use a database.

creating a database in javascript using xampp

I am wanting to use a database in javascript. I am familiar only with xampp for databases. With the code snippet .openDatabase('test1'.x .x .x) A new DB 'test1' is created if one doesn't exist, otherwise it opens 'test1'. Where is this DB found? And probably more importantly,how do I make use xampp instead? Of course should I actually be using javascript at all?
I do understand that what I am asking is not that secure. At this point in time, I don't care. I need to get some sort of practice before adding in extra levels of difficulty.
For your need, you can see the tutorial from: https://www.airpair.com/javascript/complete-expressjs-nodejs-mongodb-crud-skeleton
other tutorial:
http://teknosains.com/i/simple-crud-nodejs-mysql
For other CRUD with JavaScript Tutorials:
https://google/MkVg6Q

A simple database for an HTA

I have been tasked with creating a couple of databases for local use in our office, one for logging sickness calls and another for logging staff taxis.
I do not have the ability to install new software on the machines that will be used to develop the app nor on the machines that will use the app, so no xAMP based application, unfortunately. Excel is available, but I'd rather not go down that route as I want to provide a clean UI.
So I'm looking at putting together an HTA based application. The question is: I cannot seem to find a simple, easy to use database-type storage solution for an HTA application. Do I need to write something from scratch, or can anyone recommend something I can use?
You can try an SQLite ActiveX wrapper, like SQLite COM or SqLite2X.
If you can't install anything...
You should be able to connect to a ... dun dun dunnnn ... Access database using ADODB.Connection - VBScript example here, but the API should be portable to JScript, e.g. http://www.kuro5hin.org/story/2005/7/14/13942/7643
Quick and dirty idea - store everything in a JavaScript Object and read/write JSON to/from a file.
You can also use XML, with smthn like this:
http://msdn.microsoft.com/en-us/library/ms762708%28VS.85%29.aspx
but in my opinion, MDB(msaccess database) is the best way:
no external requirements in xp,vista,sevent and 8
it is a real DB (triggers,indexes)
You can use something like Ragic, instead of writing something from scratch. You really don't have to code anything, and your coworkers wouldn't be too perplexed, as it uses a spreadsheet interface like Excel. Also, it's a cloud database on the web, so you won't have to install on the office computers.

Categories

Resources