Another reason I prefer vanilla JS to NodeJS or any framework is its simplicity, flexibility, and reliability. I didn't want to worry about updated node modules and framework documentation. MDN is enough for me, you can keep your frameworks for thee!
The features I needed were:
- A permanent database I can write to and read data from in JSON format.
- Support of HTTP methods PUT, POST, GET and DELETE.
- Support of URL parameters
- File storage - but at the time this wasn't necessary, I had other options.
My search brought me to Google Apps Script.
Apps Script is a scripting platform developed by Google for lightweight application development in the Google Workspace platform. Scripts are created as part of an Apps Script project. See the figure below for how a basic HTTP GET request would work in an Apps Script setup.
When a GET request is initiated on the web app, the inbuilt function doGet is run. The doGet function has to be defined in the Code.gs file. doGet is passed the request event whose properties are defined here. doGet along with another inbuilt function, doPost are the only functions that will be called when an HTTP request is sent to your web app. doGet responds to HTTP GET and doPost responds to HTTP POST.
Google allows you up to 6 hours of script runtime per day on a free account. In my opinion, that is plenty to get a project in the real world off the ground. That is, off the ground to earn enough to pay for services.
To get a clearer picture, let's take a walk through my first real-world project. Below are screenshots of a full-stack website I made for a local swimming club. The site allows log in via Google, uploading pictures, posting stories with full HTML support, and updating some front-end site details - addresses, locations, contacts e.t.c. You can go through the code here.
So, let's see how I'm implementing each of the features I listed above.
Right now, I'm using Google Sheets as my database, and it's doing pretty good! See waterfall test results below (takes about 4 seconds to finish). But, from Apps Script you can hook up to Big Query and other various database solutions available in Google Cloud. Apps Script itself serves the responses a stringified JSONs.
Apps Script does support URL parameters, but it only supports HTTP GET and HTTP POST. Depending on the database solution you end up using, you'll have to write your own custom PUT and DELETE server-side based in url parameters.
Anyway, let me know what you think of all this in the comments.