this post was submitted on 01 Jan 2024
3 points (100.0% liked)

Node.js

216 readers
3 users here now

founded 1 year ago
MODERATORS
 

Hi y'all, sorry if these are really basic questions, but I'm just starting out learning node. I've been developing software for a long time, and web sites / apps for a couple of years, but nothing too advanced yet, mostly in vanilla HTML/JS and a little PHP. I swear I am trying to keep an open mind on all of this but some of these ideas are really new / different for me.

  1. Is Express really just for API development, or can I use it to create a basic web app as well? (I've read others saying this but I find this idea confusing -- e.g.: https://alternativeto.net/software/expressjs/ "Express is for building REST APIs (backend). Meteor is for building the full stack webapp")

  2. Do you get used to the idea of incorporating other people's code into your node projects? (Because as an older developer, all this "just add this framework which has 122 dependencies of its own" seems like mania. How could you ever say a project built on hundreds of other projects [which all have their own dependencies too] could ever be said to be safe or secure? And won't changes in those projects break my project eventually?)

  3. Is there no way to process a POSTed form with just the built-in Node functions when the form enctype is "multipart" -- without adding in Express or some other framework? (I've searched and searched and all the examples I found for doing this without Express assume the form's enctype is "x-www-form-urlencoded" but my form will be used to upload a file.)

Thanks for any advice / info!

top 2 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 10 months ago
  1. Someone already mentioned it, but serving static files is possible

  2. It is unsafe, but everyone is doing it regardless.

And won't changes in those projects break my project eventually?

A new version of a dependency could be incompatible, but you shouldn't update your dependencies (expect vulnerabilities or important features, ...)

  1. Didn't understand it quite, but why are you not using express? It's way better than the built-in http server
[–] [email protected] 1 points 10 months ago* (last edited 10 months ago)

Express does handle static files.

https://expressjs.com/en/starter/static-files.html

I’ve never done it in nodejs specifically but years ago I did parse a multipart encoded form in perl. So as long as you can get the underlying raw data and parse it sure. But, unless you want to do it for the fun of it there’s a lot of value both in performance and security/edgecase handling to letting a library do it.