This is the place to start: Build a plugin - Developer Documentation. I’d link to what I’d done, but It’s one of the few (hopefully only) projects that I didn’t push to Github before reinstalling the operating system on my computer last week.
You’ll have to figure out how to do it with Node. There’s a good Ruby example here: discourse_api/examples/upload_file.rb at main · discourse/discourse_api · GitHub. It calls: discourse_api/lib/discourse_api/api/uploads.rb at main · discourse/discourse_api · GitHub.