From 062436f76da14c716d6ed5598ae69b9448358ffd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 7 Jul 2025 03:12:42 +0000 Subject: [PATCH 1/2] Initial plan From e7781fb644275cee8a3eadfb02fc3e636508e83d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 7 Jul 2025 03:20:07 +0000 Subject: [PATCH 2/2] Complete dashboard implementation with frontend, backend, and testing Co-authored-by: QBlockTech <212770657+QBlockTech@users.noreply.github.com> --- .env.example | 5 + .gitignore | 21 + README.md | 183 +++++++- package-lock.json | 985 ++++++++++++++++++++++++++++++++++++++++++ package.json | 26 ++ public/index.html | 71 +++ public/script.js | 220 ++++++++++ public/styles.css | 285 ++++++++++++ src/server.js | 128 ++++++ test/database-test.js | 260 +++++++++++ 10 files changed, 2183 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/index.html create mode 100644 public/script.js create mode 100644 public/styles.css create mode 100644 src/server.js create mode 100644 test/database-test.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2881dcd --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Database Configuration +PG_DB_URL=postgresql://username:password@hostname:port/database_name + +# Server Configuration +PORT=3000 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68800c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Environment variables +.env + +# Dependencies +node_modules/ + +# Logs +logs/ +*.log + +# Build artifacts +dist/ +build/ + +# IDE +.vscode/ +.idea/ + +# OS generated files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/README.md b/README.md index a69edcd..c49249e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,183 @@ # ShippedDataDashboard -Dashboard app that will server as a frontend to read and display shipped order data stored in the Neon database + +Dashboard app that serves as a frontend to read and display shipped order data stored in the Neon database. + +## Features + +- **Real-time Order Display**: View all shipped orders in a clean, tabular format +- **Automatic Sorting**: Orders are sorted by most recently shipped first +- **Data Formatting**: Decimal values are rounded to 2 decimal places +- **Responsive Design**: Works on desktop and mobile devices +- **Auto-refresh**: Dashboard updates every 5 minutes automatically +- **Health Monitoring**: Real-time database connection status +- **Error Handling**: Comprehensive error handling and validation + +## Prerequisites + +- Node.js (v14 or higher) +- Access to a Neon PostgreSQL database +- Database table with shipped order data + +## Installation + +1. Clone the repository: +```bash +git clone https://github.com/QBlockTech/ShippedDataDashboard.git +cd ShippedDataDashboard +``` + +2. Install dependencies: +```bash +npm install +``` + +3. Set up environment variables: +```bash +cp .env.example .env +``` + +4. Edit the `.env` file with your Neon database URL: +``` +PG_DB_URL=postgresql://username:password@hostname:port/database_name +PORT=3000 +``` + +## Database Setup + +The application expects a table named `orders` with the following structure: + +```sql +CREATE TABLE orders ( + id SERIAL PRIMARY KEY, + order_number VARCHAR(50) UNIQUE NOT NULL, + customer_name VARCHAR(100) NOT NULL, + product_name VARCHAR(200) NOT NULL, + quantity INTEGER NOT NULL DEFAULT 1, + unit_price DECIMAL(10, 2) NOT NULL, + total_amount DECIMAL(10, 2) NOT NULL, + shipped_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tracking_number VARCHAR(100), + status VARCHAR(20) DEFAULT 'shipped', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +``` + +## Running the Application + +### Development Mode +```bash +npm run dev +``` + +### Production Mode +```bash +npm start +``` + +The application will be available at `http://localhost:3000` + +## Testing + +### Test Database Connection +```bash +npm run test-db +``` + +This will: +- Test the database connection +- Verify the table structure +- Create sample data if the table is empty +- Validate data retrieval + +### Manual Testing Steps + +1. **Database Connection Test**: + ```bash + npm run test-db + ``` + Expected: All tests should pass and sample data should be created + +2. **Start the Application**: + ```bash + npm start + ``` + Expected: Server should start on port 3000 + +3. **Access the Dashboard**: + - Open `http://localhost:3000` in your browser + - Expected: Dashboard loads with "Fulfilled Orders" header + +4. **Check Health Status**: + - Visit `http://localhost:3000/api/health` + - Expected: JSON response with `{"status": "healthy"}` + +5. **Test API Endpoint**: + - Visit `http://localhost:3000/api/orders` + - Expected: JSON response with orders data + +6. **Verify Data Display**: + - Check that orders are displayed in the table + - Verify sorting (most recent first) + - Confirm decimal formatting (2 decimal places) + - Test refresh button functionality + +## API Endpoints + +- `GET /` - Dashboard homepage +- `GET /api/orders` - Retrieve all shipped orders +- `GET /api/health` - Health check endpoint + +## Project Structure + +``` +ShippedDataDashboard/ +├── public/ +│ ├── index.html # Dashboard frontend +│ ├── styles.css # Styling +│ └── script.js # Frontend JavaScript +├── src/ +│ └── server.js # Express server +├── test/ +│ └── database-test.js # Database testing +├── .env.example # Environment variables template +├── .gitignore # Git ignore rules +├── package.json # Project configuration +└── README.md # This file +``` + +## Environment Variables + +| Variable | Description | Required | +|----------|-------------|----------| +| `PG_DB_URL` | PostgreSQL connection string for Neon database | Yes | +| `PORT` | Port number for the server (default: 3000) | No | + +## Troubleshooting + +### Database Connection Issues +- Verify your `PG_DB_URL` is correct +- Check that your Neon database is accessible +- Run `npm run test-db` to diagnose connection problems + +### Application Won't Start +- Check that port 3000 is available +- Verify all dependencies are installed with `npm install` +- Check the console for error messages + +### No Data Displayed +- Ensure your orders table has data with `status = 'shipped'` +- Check the browser console for JavaScript errors +- Verify the API endpoint returns data at `/api/orders` + +## Contributing + +1. Fork the repository +2. Create a feature branch +3. Make your changes +4. Add tests for new functionality +5. Submit a pull request + +## License + +This project is licensed under the ISC License. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..82db27b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,985 @@ +{ + "name": "shippeddatadashboard", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "shippeddatadashboard", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "dotenv": "^17.0.1", + "express": "^5.1.0", + "pg": "^8.16.3" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dotenv": { + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.0.1.tgz", + "integrity": "sha512-GLjkduuAL7IMJg/ZnOPm9AnWKJ82mSE2tzXLaJ/6hD6DhwGfZaXG77oB8qbReyiczNxnbxQKyh0OE5mXq0bAHA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", + "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "license": "MIT", + "engines": { + "node": ">=16" + } + }, + "node_modules/pg": { + "version": "8.16.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", + "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.9.1", + "pg-pool": "^3.10.1", + "pg-protocol": "^1.10.3", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.2.7" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz", + "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz", + "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz", + "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz", + "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz", + "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.6.3", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..27ef753 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "shippeddatadashboard", + "version": "1.0.0", + "description": "Dashboard app that will server as a frontend to read and display shipped order data stored in the Neon database", + "main": "src/server.js", + "scripts": { + "start": "node src/server.js", + "dev": "node src/server.js", + "test": "node test/database-test.js", + "test-db": "node test/database-test.js" + }, + "keywords": [ + "dashboard", + "neon", + "postgresql", + "orders", + "shipped" + ], + "author": "", + "license": "ISC", + "dependencies": { + "dotenv": "^17.0.1", + "express": "^5.1.0", + "pg": "^8.16.3" + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..f1004af --- /dev/null +++ b/public/index.html @@ -0,0 +1,71 @@ + + + + + + Fulfilled Orders Dashboard + + + +
+
+

Fulfilled Orders

+
+ Connecting... + +
+
+ +
+
+ +
+ 0 orders found +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
Order IDOrder NumberCustomer NameProduct NameQuantityUnit PriceTotal AmountShipped DateTracking NumberStatus
+
+ + + + +
+ + +
+ + + + \ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..b0075ca --- /dev/null +++ b/public/script.js @@ -0,0 +1,220 @@ +// Dashboard functionality +class OrdersDashboard { + constructor() { + this.orders = []; + this.isLoading = false; + this.init(); + } + + init() { + this.bindEvents(); + this.loadOrders(); + this.checkHealthStatus(); + } + + bindEvents() { + const refreshBtn = document.getElementById('refresh-btn'); + if (refreshBtn) { + refreshBtn.addEventListener('click', () => this.loadOrders()); + } + + // Auto-refresh every 5 minutes + setInterval(() => this.loadOrders(), 5 * 60 * 1000); + } + + async checkHealthStatus() { + try { + const response = await fetch('/api/health'); + const data = await response.json(); + + const statusElement = document.getElementById('connection-status'); + if (data.status === 'healthy') { + statusElement.textContent = 'Connected'; + statusElement.className = 'status-connected'; + } else { + statusElement.textContent = 'Disconnected'; + statusElement.className = 'status-disconnected'; + } + } catch (error) { + console.error('Health check failed:', error); + const statusElement = document.getElementById('connection-status'); + statusElement.textContent = 'Connection Error'; + statusElement.className = 'status-disconnected'; + } + } + + async loadOrders() { + if (this.isLoading) return; + + this.isLoading = true; + this.showLoading(); + this.hideError(); + + try { + console.log('🔄 Loading orders...'); + const response = await fetch('/api/orders'); + const result = await response.json(); + + if (!response.ok) { + throw new Error(result.message || 'Failed to fetch orders'); + } + + if (result.success) { + this.orders = result.data || []; + console.log(`📊 Loaded ${this.orders.length} orders`); + this.renderOrders(); + this.updateLastUpdated(); + } else { + throw new Error(result.error || 'Unknown error occurred'); + } + + } catch (error) { + console.error('❌ Error loading orders:', error); + this.showError(`Failed to load orders: ${error.message}`); + } finally { + this.isLoading = false; + this.hideLoading(); + } + } + + renderOrders() { + const tbody = document.getElementById('orders-tbody'); + const orderCount = document.getElementById('order-count'); + const noDataElement = document.getElementById('no-data'); + const tableContainer = document.querySelector('.table-container'); + + // Update order count + orderCount.textContent = this.orders.length; + + if (this.orders.length === 0) { + // Show no data message + noDataElement.style.display = 'block'; + tableContainer.style.display = 'none'; + return; + } + + // Hide no data message and show table + noDataElement.style.display = 'none'; + tableContainer.style.display = 'block'; + + // Clear existing rows + tbody.innerHTML = ''; + + // Render each order + this.orders.forEach(order => { + const row = this.createOrderRow(order); + tbody.appendChild(row); + }); + + console.log(`✅ Rendered ${this.orders.length} orders in table`); + } + + createOrderRow(order) { + const row = document.createElement('tr'); + + // Validate and format data + const formatValue = (value, defaultValue = 'N/A') => { + return (value !== null && value !== undefined && value !== '') ? value : defaultValue; + }; + + const formatCurrency = (value) => { + if (value === null || value === undefined || value === '') return '$0.00'; + return `$${parseFloat(value).toFixed(2)}`; + }; + + const formatDate = (dateString) => { + if (!dateString) return 'N/A'; + try { + return new Date(dateString).toLocaleDateString(); + } catch (error) { + return dateString; + } + }; + + row.innerHTML = ` + ${formatValue(order.id)} + ${formatValue(order.order_number)} + ${formatValue(order.customer_name)} + ${formatValue(order.product_name)} + ${formatValue(order.quantity)} + ${formatCurrency(order.unit_price)} + ${formatCurrency(order.total_amount)} + ${formatDate(order.shipped_date)} + ${formatValue(order.tracking_number)} + ${formatValue(order.status)} + `; + + return row; + } + + showLoading() { + const loading = document.getElementById('loading'); + const refreshBtn = document.getElementById('refresh-btn'); + const btnText = refreshBtn.querySelector('.btn-text'); + const btnSpinner = refreshBtn.querySelector('.loading-spinner'); + + loading.style.display = 'flex'; + refreshBtn.disabled = true; + btnText.style.display = 'none'; + btnSpinner.style.display = 'inline-block'; + } + + hideLoading() { + const loading = document.getElementById('loading'); + const refreshBtn = document.getElementById('refresh-btn'); + const btnText = refreshBtn.querySelector('.btn-text'); + const btnSpinner = refreshBtn.querySelector('.loading-spinner'); + + loading.style.display = 'none'; + refreshBtn.disabled = false; + btnText.style.display = 'inline-block'; + btnSpinner.style.display = 'none'; + } + + showError(message) { + const errorElement = document.getElementById('error-message'); + errorElement.textContent = message; + errorElement.style.display = 'block'; + } + + hideError() { + const errorElement = document.getElementById('error-message'); + errorElement.style.display = 'none'; + } + + updateLastUpdated() { + const lastUpdatedElement = document.getElementById('last-updated'); + const now = new Date(); + const timeString = now.toLocaleTimeString(); + lastUpdatedElement.textContent = `Last updated: ${timeString}`; + } +} + +// Initialize dashboard when DOM is loaded +document.addEventListener('DOMContentLoaded', () => { + console.log('🚀 Initializing Orders Dashboard...'); + new OrdersDashboard(); +}); + +// Handle visibility change to refresh data when tab becomes active +document.addEventListener('visibilitychange', () => { + if (!document.hidden) { + console.log('👁️ Tab became visible, checking for updates...'); + // Small delay to ensure the tab is fully active + setTimeout(() => { + if (window.dashboard) { + window.dashboard.checkHealthStatus(); + } + }, 500); + } +}); + +// Global error handler +window.addEventListener('error', (event) => { + console.error('💥 Global error:', event.error); +}); + +// Handle unhandled promise rejections +window.addEventListener('unhandledrejection', (event) => { + console.error('💥 Unhandled promise rejection:', event.reason); +}); \ No newline at end of file diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..f1ef177 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,285 @@ +/* Reset and base styles */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; + line-height: 1.6; + color: #333; + background-color: #f5f5f5; +} + +.container { + max-width: 1400px; + margin: 0 auto; + padding: 20px; + min-height: 100vh; + display: flex; + flex-direction: column; +} + +/* Header styles */ +header { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; + padding: 2rem; + border-radius: 12px; + margin-bottom: 2rem; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; +} + +header h1 { + font-size: 2.5rem; + font-weight: 700; + margin: 0; +} + +.status-indicator { + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 0.5rem; +} + +.status-indicator span { + padding: 0.25rem 0.75rem; + border-radius: 20px; + font-size: 0.875rem; + font-weight: 600; +} + +.status-connected { + background-color: #10b981; + color: white; +} + +.status-disconnected { + background-color: #ef4444; + color: white; +} + +/* Main content */ +main { + flex: 1; + display: flex; + flex-direction: column; + gap: 1.5rem; +} + +/* Controls */ +.controls { + display: flex; + justify-content: space-between; + align-items: center; + background: white; + padding: 1.5rem; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + flex-wrap: wrap; + gap: 1rem; +} + +.btn { + padding: 0.75rem 1.5rem; + border: none; + border-radius: 6px; + font-size: 1rem; + font-weight: 600; + cursor: pointer; + transition: all 0.2s ease; + display: flex; + align-items: center; + gap: 0.5rem; +} + +.btn-primary { + background-color: #3b82f6; + color: white; +} + +.btn-primary:hover { + background-color: #2563eb; + transform: translateY(-1px); +} + +.btn:disabled { + background-color: #9ca3af; + cursor: not-allowed; + transform: none; +} + +.loading-spinner { + animation: spin 1s linear infinite; +} + +.order-count { + font-size: 1.1rem; + font-weight: 600; + color: #6b7280; +} + +/* Table styles */ +.table-container { + background: white; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + overflow: hidden; +} + +table { + width: 100%; + border-collapse: collapse; + font-size: 0.875rem; +} + +thead { + background-color: #f8fafc; +} + +th { + padding: 1rem; + text-align: left; + font-weight: 600; + color: #374151; + border-bottom: 2px solid #e5e7eb; + position: sticky; + top: 0; + background-color: #f8fafc; + z-index: 10; +} + +td { + padding: 1rem; + border-bottom: 1px solid #e5e7eb; + vertical-align: middle; +} + +tbody tr:hover { + background-color: #f9fafb; +} + +tbody tr:nth-child(even) { + background-color: #f8fafc; +} + +tbody tr:nth-child(even):hover { + background-color: #f1f5f9; +} + +/* Responsive table */ +@media (max-width: 1200px) { + .table-container { + overflow-x: auto; + } + + table { + min-width: 1000px; + } +} + +/* Error message */ +.error-message { + background-color: #fef2f2; + color: #dc2626; + padding: 1rem; + border-radius: 6px; + border: 1px solid #fecaca; + margin-bottom: 1rem; +} + +/* Loading states */ +.loading { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 3rem; + background: white; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.loading-spinner-large { + font-size: 3rem; + animation: spin 1s linear infinite; + margin-bottom: 1rem; +} + +.no-data { + text-align: center; + padding: 3rem; + background: white; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + color: #6b7280; + font-size: 1.1rem; +} + +/* Footer */ +footer { + margin-top: 2rem; + padding: 1rem; + text-align: center; + color: #6b7280; + font-size: 0.875rem; +} + +/* Animations */ +@keyframes spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } +} + +/* Responsive design */ +@media (max-width: 768px) { + .container { + padding: 1rem; + } + + header { + flex-direction: column; + text-align: center; + gap: 1rem; + } + + header h1 { + font-size: 2rem; + } + + .controls { + flex-direction: column; + align-items: stretch; + } + + .btn { + justify-content: center; + } +} + +/* Data formatting */ +.currency { + text-align: right; + font-weight: 600; + color: #059669; +} + +.date { + white-space: nowrap; +} + +.status { + padding: 0.25rem 0.75rem; + border-radius: 12px; + font-size: 0.75rem; + font-weight: 600; + text-transform: uppercase; + background-color: #10b981; + color: white; +} \ No newline at end of file diff --git a/src/server.js b/src/server.js new file mode 100644 index 0000000..0f9f5f0 --- /dev/null +++ b/src/server.js @@ -0,0 +1,128 @@ +const express = require('express'); +const { Pool } = require('pg'); +const path = require('path'); +require('dotenv').config(); + +const app = express(); +const PORT = process.env.PORT || 3000; + +// Database connection pool +const pool = new Pool({ + connectionString: process.env.PG_DB_URL, + ssl: { + rejectUnauthorized: false + } +}); + +// Middleware +app.use(express.static(path.join(__dirname, '..', 'public'))); +app.use(express.json()); + +// Test database connection +async function testDatabaseConnection() { + try { + const client = await pool.connect(); + console.log('✅ Database connected successfully'); + client.release(); + } catch (err) { + console.error('❌ Database connection failed:', err.message); + } +} + +// API endpoint to get shipped orders +app.get('/api/orders', async (req, res) => { + try { + console.log('📊 Fetching shipped orders from database...'); + + // Query to get all orders sorted by most recent first + // Assuming there's a table named 'orders' with appropriate columns + const query = ` + SELECT + id, + order_number, + customer_name, + product_name, + quantity, + unit_price, + total_amount, + shipped_date, + tracking_number, + status + FROM orders + WHERE status = 'shipped' + ORDER BY shipped_date DESC, id DESC + `; + + const result = await pool.query(query); + + // Format the data - round decimal values to 2 decimal places + const formattedOrders = result.rows.map(order => ({ + ...order, + unit_price: order.unit_price ? parseFloat(order.unit_price).toFixed(2) : '0.00', + total_amount: order.total_amount ? parseFloat(order.total_amount).toFixed(2) : '0.00', + shipped_date: order.shipped_date ? new Date(order.shipped_date).toLocaleDateString() : 'N/A' + })); + + console.log(`📦 Retrieved ${formattedOrders.length} shipped orders`); + + // Log each order for debugging + formattedOrders.forEach((order, index) => { + console.log(`Order ${index + 1}:`, { + id: order.id, + order_number: order.order_number, + customer_name: order.customer_name, + total_amount: order.total_amount, + shipped_date: order.shipped_date + }); + }); + + res.json({ + success: true, + data: formattedOrders, + count: formattedOrders.length + }); + + } catch (error) { + console.error('❌ Error fetching orders:', error.message); + res.status(500).json({ + success: false, + error: 'Failed to fetch orders', + message: error.message + }); + } +}); + +// Health check endpoint +app.get('/api/health', async (req, res) => { + try { + const client = await pool.connect(); + client.release(); + res.json({ + status: 'healthy', + database: 'connected', + timestamp: new Date().toISOString() + }); + } catch (error) { + res.status(500).json({ + status: 'unhealthy', + database: 'disconnected', + error: error.message, + timestamp: new Date().toISOString() + }); + } +}); + +// Serve the dashboard +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, '..', 'public', 'index.html')); +}); + +// Start server +app.listen(PORT, () => { + console.log(`🚀 Server running on port ${PORT}`); + console.log(`📱 Dashboard available at: http://localhost:${PORT}`); + console.log(`🔧 Health check: http://localhost:${PORT}/api/health`); + testDatabaseConnection(); +}); + +module.exports = app; \ No newline at end of file diff --git a/test/database-test.js b/test/database-test.js new file mode 100644 index 0000000..681085f --- /dev/null +++ b/test/database-test.js @@ -0,0 +1,260 @@ +const { Pool } = require('pg'); +require('dotenv').config(); + +/** + * Test Database Connection and Data Retrieval + * This script tests the connection to the Neon database and validates data retrieval + */ + +class DatabaseTester { + constructor() { + this.pool = new Pool({ + connectionString: process.env.PG_DB_URL, + ssl: { + rejectUnauthorized: false + } + }); + } + + async testConnection() { + console.log('🔍 Testing database connection...'); + console.log('Database URL:', process.env.PG_DB_URL ? 'Configured' : 'Not configured'); + + try { + const client = await this.pool.connect(); + console.log('✅ Database connection successful'); + + // Test basic query + const result = await client.query('SELECT NOW() as current_time'); + console.log('⏰ Database time:', result.rows[0].current_time); + + client.release(); + return true; + } catch (error) { + console.error('❌ Database connection failed:', error.message); + return false; + } + } + + async testTableStructure() { + console.log('\n🔍 Testing table structure...'); + + try { + const client = await this.pool.connect(); + + // Check if orders table exists + const tableCheck = await client.query(` + SELECT table_name + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'orders' + `); + + if (tableCheck.rows.length === 0) { + console.log('⚠️ Orders table not found. Creating sample table structure...'); + await this.createSampleTable(client); + } else { + console.log('✅ Orders table exists'); + } + + // Get table structure + const columnsQuery = await client.query(` + SELECT column_name, data_type, is_nullable + FROM information_schema.columns + WHERE table_name = 'orders' + ORDER BY ordinal_position + `); + + console.log('📊 Table structure:'); + columnsQuery.rows.forEach(col => { + console.log(` - ${col.column_name}: ${col.data_type} (${col.is_nullable === 'YES' ? 'nullable' : 'not null'})`); + }); + + client.release(); + return true; + } catch (error) { + console.error('❌ Table structure test failed:', error.message); + return false; + } + } + + async createSampleTable(client) { + console.log('🏗️ Creating sample orders table...'); + + const createTableQuery = ` + CREATE TABLE IF NOT EXISTS orders ( + id SERIAL PRIMARY KEY, + order_number VARCHAR(50) UNIQUE NOT NULL, + customer_name VARCHAR(100) NOT NULL, + product_name VARCHAR(200) NOT NULL, + quantity INTEGER NOT NULL DEFAULT 1, + unit_price DECIMAL(10, 2) NOT NULL, + total_amount DECIMAL(10, 2) NOT NULL, + shipped_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tracking_number VARCHAR(100), + status VARCHAR(20) DEFAULT 'shipped', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + `; + + await client.query(createTableQuery); + console.log('✅ Sample table created'); + + // Insert sample data + await this.insertSampleData(client); + } + + async insertSampleData(client) { + console.log('📝 Inserting sample data...'); + + const sampleOrders = [ + { + order_number: 'ORD-2024-001', + customer_name: 'John Doe', + product_name: 'Laptop Computer', + quantity: 1, + unit_price: 999.99, + total_amount: 999.99, + tracking_number: 'TRK123456789', + shipped_date: new Date(Date.now() - 24 * 60 * 60 * 1000) // Yesterday + }, + { + order_number: 'ORD-2024-002', + customer_name: 'Jane Smith', + product_name: 'Wireless Mouse', + quantity: 2, + unit_price: 29.99, + total_amount: 59.98, + tracking_number: 'TRK987654321', + shipped_date: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000) // 2 days ago + }, + { + order_number: 'ORD-2024-003', + customer_name: 'Bob Johnson', + product_name: 'USB-C Cable', + quantity: 3, + unit_price: 15.50, + total_amount: 46.50, + tracking_number: 'TRK456789123', + shipped_date: new Date() // Now + } + ]; + + for (const order of sampleOrders) { + try { + await client.query(` + INSERT INTO orders ( + order_number, customer_name, product_name, quantity, + unit_price, total_amount, tracking_number, shipped_date, status + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) + ON CONFLICT (order_number) DO NOTHING + `, [ + order.order_number, order.customer_name, order.product_name, + order.quantity, order.unit_price, order.total_amount, + order.tracking_number, order.shipped_date, 'shipped' + ]); + console.log(`✅ Inserted order: ${order.order_number}`); + } catch (error) { + console.log(`⚠️ Order ${order.order_number} might already exist: ${error.message}`); + } + } + } + + async testDataRetrieval() { + console.log('\n🔍 Testing data retrieval...'); + + try { + const client = await this.pool.connect(); + + // Test the same query used by the API + const query = ` + SELECT + id, order_number, customer_name, product_name, quantity, + unit_price, total_amount, shipped_date, tracking_number, status + FROM orders + WHERE status = 'shipped' + ORDER BY shipped_date DESC, id DESC + `; + + const result = await client.query(query); + + console.log(`📦 Found ${result.rows.length} shipped orders`); + + if (result.rows.length > 0) { + console.log('\n📊 Sample data:'); + result.rows.forEach((order, index) => { + console.log(`Order ${index + 1}:`); + console.log(` - ID: ${order.id}`); + console.log(` - Order Number: ${order.order_number}`); + console.log(` - Customer: ${order.customer_name}`); + console.log(` - Product: ${order.product_name}`); + console.log(` - Quantity: ${order.quantity}`); + console.log(` - Unit Price: $${parseFloat(order.unit_price).toFixed(2)}`); + console.log(` - Total: $${parseFloat(order.total_amount).toFixed(2)}`); + console.log(` - Shipped: ${order.shipped_date ? new Date(order.shipped_date).toLocaleDateString() : 'N/A'}`); + console.log(` - Tracking: ${order.tracking_number || 'N/A'}`); + console.log(` - Status: ${order.status}`); + console.log(''); + }); + } + + client.release(); + return true; + } catch (error) { + console.error('❌ Data retrieval test failed:', error.message); + return false; + } + } + + async runAllTests() { + console.log('🧪 Starting Database Tests'); + console.log('=' * 50); + + const connectionTest = await this.testConnection(); + if (!connectionTest) { + console.log('\n❌ Database connection failed. Please check your PG_DB_URL configuration.'); + return false; + } + + const structureTest = await this.testTableStructure(); + if (!structureTest) { + console.log('\n❌ Table structure test failed.'); + return false; + } + + const dataTest = await this.testDataRetrieval(); + if (!dataTest) { + console.log('\n❌ Data retrieval test failed.'); + return false; + } + + console.log('\n✅ All database tests passed!'); + console.log('🚀 Your database is ready for the dashboard application.'); + return true; + } + + async close() { + await this.pool.end(); + } +} + +// Run tests if this file is executed directly +if (require.main === module) { + const tester = new DatabaseTester(); + + tester.runAllTests() + .then(() => { + console.log('\n🏁 Test completed'); + process.exit(0); + }) + .catch(error => { + console.error('\n💥 Test failed:', error); + process.exit(1); + }) + .finally(() => { + tester.close(); + }); +} + +module.exports = DatabaseTester; \ No newline at end of file