Small Express API for exporting meteorological wind data from a MySQL database as CSV.
- Starts an HTTP server with CORS enabled.
- Connects to the
MRAPIDMySQL database. - Exposes a health-style root route at
/. - Exposes a CSV export route at
/meteorological_data/csv.
Current implementation lives in API.js.
- Node.js
- Express
- MySQL
json2csvcors
.
├── API.js # Server startup, env config, routes, DB helpers
├── API.test.js # Minimal config tests
├── kriging.js # Kriging helper code, not currently used by any route
├── .env.example # Example environment variables
├── package.json
└── README.md
- Node.js 18+ recommended
- npm
- Access to the
MRAPIDMySQL database - A valid MySQL connection for your environment
npm installcp .env.example .env
# then export the values you want to use in your shell
npm startBy default the server listens on port 8080.
The server now supports PORT and falls back to lowercase port for compatibility.
npm testSimple readiness check.
Example response:
{
"status": "Ready! :)"
}Exports rows from MRAPID.meteorological_data where both wind_speed and wind_direction are present and the reconstructed timestamp falls between the requested bounds.
start_daterequired, format like2017-01-01 00:00:00end_daterequired, format like2017-01-31 23:59:59
http://localhost:8080/meteorological_data/csv?start_date=2017-01-01%2000:00:00&end_date=2017-01-31%2023:59:59
- Status:
200 OK - Content-Type:
text/csv - Attachment filename:
meteorological_data.csv
400whenstart_dateorend_dateis missing404when no matching data is found500when the database query fails
Set these environment variables before starting the server:
DB_USERDB_PASSWORDDB_NAMEDB_HOSTand optionallyDB_PORT
If you are connecting through a Cloud SQL Unix socket, set this instead of DB_HOST:
DB_SOCKET_PATH
kriging.jsis included in the repo but not currently connected to the API surface.- The API currently supports CSV export only.
- The SQL query assumes
MRAPID.meteorological_dataexists withyear,month,day,hour,wind_speed, andwind_directioncolumns.
- Add one route-level smoke test for the CSV endpoint
- Document the database schema expected by
meteorological_data