MA
mit-maschinen-kommunizieren
This folder contains several small example servers that demonstrate different API styles for a simple "menu" service (REST, GraphQL, gRPC, MQTT, SOAP). The code is intentionally minimal and meant for learning or small local experiments.
Contents
graphql/— GraphQL demo (includesgraphql.server.mjs,menu.server.mjs,waiter.server.mjs)grpc/— gRPC demo (includesgrpc.server.mjs,menu.proto,menu.server.mjs,waiter.server.mjs)intro/— small REST/demo servers (includesmenu.server.mjs,waiter.server.mjs)mqtt/,rest/,soap/— placeholders or additional demostest-apis.sh— convenience script to exercise the example APIspackage.json— top-level npm metadata (some demos may have their own package.json)
Quick start
- From this directory, install dependencies (if needed):
cd "mit-maschinen-kommunizieren copy"
npm install- Run one of the example servers (files are ESM
.mjs) — examples:
# REST intro demo
node intro/waiter.server.mjs
# GraphQL demo
node graphql/graphql.server.mjs
# gRPC demo (may start both server and waiter proxy)
node grpc/grpc.server.mjs- Use the included
test-apis.shto run a quick smoke-check against the examples:
./test-apis.shAPI Examples
Once a server is running, try these example calls from another terminal:
REST / Intro demo
Start with: node intro/waiter.server.mjs (typically runs on http://localhost:3000)
# Get the full menu
curl http://localhost:3000/menu
# Query the menu with a filter maxPrice
curl "http://localhost:3000/menu?maxPrice=5"
# Query the vegetarian menu
curl "http://localhost:3000/menu/vegetarian"GraphQL demo
Start with: node graphql/graphql.server.mjs (typically runs on http://localhost:4000/graphql)
# Query via curl (or use GraphQL Playground in the browser)
curl -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-d '{"query":"{ menu { name vegetarian } }"}'gRPC demo
Start with: node grpc/grpc.server.mjs (typically runs on localhost:50051)
Use a gRPC client tool like grpcurl:
# List available services
grpcurl -plaintext localhost:50051 list
# Call a menu RPC
grpcurl -plaintext localhost:50051 menu.Menu/GetMenuMQTT demo
If available, start with: node mqtt/mqtt.server.mjs
Use an MQTT client like mosquitto_pub / mosquitto_sub:
# Subscribe to menu updates
mosquitto_sub -h localhost -t "menu/#"
# Publish a menu request (in another terminal)
mosquitto_pub -h localhost -t "menu/request" -m "get"Notes
- These scripts use
.mjsESM modules — use a modern Node.js (16+) that supports ESM. - Some subfolders have their own
package.json;npm installthere may be required for demo-specific dependencies. test-apis.shmay need execute permission:chmod +x test-apis.sh.- Default ports may vary — check server output for the actual port and endpoint.
- This repository is for demo/learning purposes; review configs before reusing in production.