Serverless vs Node.js: A Civic Technologist’s Breakdown
In civic tech deployments, clarity and modularity are essential. Whether you're building hashtag rotators, webhook listeners, or diagnostics endpoints, understanding the difference between serverless functions and traditional Node.js servers is key to remixability and public trust.
Serverless APIs on Vercel
When deploying serverless functions like /api/github-webhook.js, Vercel automatically provides the Node.js runtime. Your code executes only when triggered — no manual server setup required.
You write modular JavaScript, Vercel handles the execution. No need to run node manually.
What Is webhook-listener.js?
If your file uses Express like this:
const express = require('express');
const app = express();
app.post('/webhook', (req, res) => {
// handle webhook
});
app.listen(3000, () => console.log('Listening'));
Then it’s a full Node.js server. You run it manually using node webhook-listener.js. It stays active, listening for requests — unlike serverless functions, which spin up only when needed.
What Is a Server (for Non-Technical Readers)
A server is just a computer that listens for requests and sends back responses. Think of it like a reception desk: you ask for something, and it gives you what you need — whether it’s a webpage, data, or confirmation.
Is Node.js the Server? ๐ซ๐
Not quite. Node.js is the runtime — the engine that runs JavaScript outside the browser. It lets you build server apps, but it’s not the server itself.
| Concept | What It Is | Analogy |
|---|---|---|
| Node.js | A JavaScript engine that runs code | A chef who knows how to cook recipes |
| Express.js | A framework built on Node.js | A cookbook for making web servers |
| Your server file | The actual app that listens and responds | The restaurant serving meals |
So when you write webhook-listener.js using Express, you’re building a server using Node.js as the engine. Node.js powers the logic, Express structures the routes, and your file becomes the server app that listens for webhooks.
No comments:
Post a Comment