$ 1_nodes_in_cluster> node src/main.js
$ 1_nodes_in_cluster> docker run -d -p 8080:8080 ghcr.io/cynicdog/cloudnative-node.js-templates/node-cluster-app:latest
$ 1_nodes_in_cluster> http :8080/
HTTP/1.1 200 OK
Connection: keep-alive
Date: Mon, 16 Dec 2024 05:34:56 GMT
Keep-Alive: timeout=5
Transfer-Encoding: chunked
Hello World
$ 2_DNS_lookup_service_discovery_on_k8s> node src/main.js
$ 2_DNS_lookup_service_discovery_on_k8s> kind create cluster --name=node-dns
$ 2_DNS_lookup_service_discovery_on_k8s> docker exec -it node-dns-control-plane /bin/bash
$ root@node-dns-control-plane:/# kubectl create -f k8s/
Ensure Kubernetes resource files are located in the
k8s
directory within the container, matching the repository'sk8s
directory.
If deployed successfully, the list of exposed endpoints by the headless service should look like this:
root@node-dns-control-plane:/# kubectl get endpoints
NAME ENDPOINTS AGE
kubernetes 172.18.0.4:6443 85m
node-app 10.244.0.17:8080,10.244.0.18:8080,10.244.0.19:8080 8m28s
$ 2_DNS_lookup_service_discovery_on_k8s> kubectl port-forward service/node-app 8080:8080
$ 2_DNS_lookup_service_discovery_on_k8s> http :8080/
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json
Date: Mon, 16 Dec 2024 08:04:39 GMT
Keep-Alive: timeout=5
Transfer-Encoding: chunked
{
"discoveredPodIP": "10.244.0.17",
"message": "Hello World."
}
Run these commands in separate terminal windows.
Criteria | Express.js | Koa.js | Nest.js | Fastify |
---|---|---|---|---|
Ease of Use | Very beginner-friendly, minimalistic | Requires more setup, uses modern JavaScript | Steeper learning curve, structured & modular | Simple, developer-friendly with a learning curve |
Architecture | Minimal structure, flexible | Modular, unopinionated | Opinionated, modular, TypeScript-focused | Structured, modular with plugin support |
Extensibility | Highly extensible with many plugins | Flexible, but fewer built-in features | Highly extensible with built-in tools | Built-in plugins, highly extensible |
Community | Largest community, vast ecosystem | Smaller community, fewer third-party packages | Growing, especially in TypeScript/enterprise | Rapidly growing, strong support for modern use |
Popularity (GitHub Stars) | 65.9k ⭐⭐⭐⭐ | 35.3k ⭐⭐⭐ | 68.4k ⭐⭐⭐⭐⭐ | 32.6k ⭐⭐⭐ |
For Koa.js:
$ 1_koa_js> node src/main.js
For Nest.js:
$ 2_nest_js> npm run start
For Express.js:
$ 3_express_js> node src/main.js
For Fastify:
$ 4_fastify> npm run dev
For Koa.js:
$ 1_koa_js> docker run -p 3000:3000 ghcr.io/cynicdog/cloudnative-node.js-templates/middleware_koa_js:latest
For Nest.js:
$ 2_nest_js> docker run -p 3000:3000 ghcr.io/cynicdog/cloudnative-node.js-templates/middleware_nest_js:latest
For Express.js:
$ 3_express_js> docker run -p 3000:3000 ghcr.io/cynicdog/cloudnative-node.js-templates/middleware_express_js:latest
For Fastify:
$ 4_fastify> docker run -p 3000:3000 ghcr.io/cynicdog/cloudnative-node.js-templates/middleware_fastify:latest
The server endpoints are the same for all the frameworks:
-
Create an Item
$ > http POST :3000/items name="Item1" description="This is Item1"
-
Get All Items
$ > http :3000/items
-
Update an Item
$ > http PUT :3000/items/1 name="Item1 - Updated"
-
Delete an Item
$ > http DELETE :3000/items/1