greggman / servez

A simple web server for local web development.
https://greggman.github.io/servez/
295 stars 48 forks source link

Is it possible to run NodeJS scripts with servez? #14

Closed JonathanLef closed 2 years ago

JonathanLef commented 2 years ago

I'm a beginner in back-end development, currently working on a project where the front-end process everything but at the end it must store everything within a file (I may use more than 100Go so I need to work with a local file outside of the browser)

Servez seems great since it setup all the server easily with only a .exe but is it possible to make it process some server-side scripts through http requests or other way?

greggman commented 2 years ago

servez is not really meant to be an extendable server.

Solutions:

You can hack it. It's running Electron which is basically Node + Chromium and you can run node scripts. The main.js file is basically a node script so change it and build your own version.

As for node server in general, servez is just express + express's static-files support with a few things tacked on. You can see how servez is using express here

Also, a little out of date but see this article

JonathanLef commented 2 years ago

Thank you for the fast response. I'll definitely look at your documentation and try to modify the code to fit my needs. (Great way to force myself to learn back-end :) )

Still, if there is a way in NodeJS to include a script that serve as an api (kinda similar to Goggle Cloud Function) it would help a ton of new developer that are trying to learn how to create back-end functions without struggling with creating a server. Could be a second file input in the servez setup window named "include server script".