Node + MySQL + JSON
✓ Published0🌍 Public
Mmbostock
Last edited Dec 12, 2011
Created on Dec 12, 2011
This example demonstrates a Node.js server that serves JSON data from a MySQL database to a front-end visualization. It sets the server’s timezone to UTC and uses Express to handle HTTP requests, with the `connect-gzip` middleware compressing responses. A GET endpoint for `/things/:id.json` queries a MySQL table named `things` via the `mysql` client, selecting fields like `name`, `favorite_color`, and `airspeed_velocity` based on the numeric ID from the URL, then returns the result as JSON. The code shows a direct pipeline from database query to API response, ready for consumption by a client-side chart.
AI-generated description