Compare commits
22 Commits
b52a4dcee6
...
backend
| Author | SHA1 | Date | |
|---|---|---|---|
| c5abf60bff | |||
| 75581a9ddc | |||
| 2771b5ea74 | |||
| eeb63fa510 | |||
|
|
06f3129fb9 | ||
| bfe47fb443 | |||
| a5fceda42f | |||
|
|
eaf76f94a1 | ||
| 7cb29179a2 | |||
| 8a5db40d1d | |||
| 9c51163505 | |||
| ba32d9d482 | |||
| a7aff8e169 | |||
| b9a63aa6d7 | |||
|
|
6ace1fe30a | ||
|
|
59eaef6803 | ||
|
|
24e4b699d6 | ||
|
|
0f80dec459 | ||
|
|
a8fc313af3 | ||
| 0d33259f1e | |||
|
|
0e8f43f686 | ||
| 9ec154c511 |
41
.gitea/workflows/deploy.yaml
Normal file
41
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Deploy Express API
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- backend
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: linux_amd64
|
||||
|
||||
steps:
|
||||
# Checkout code
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Pull latest code
|
||||
- name: Pull latest code
|
||||
run: |
|
||||
cd /var/www/myapp/Project
|
||||
git reset --hard
|
||||
git pull origin main
|
||||
|
||||
# Install dependencies
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd /var/www/myapp/Project
|
||||
npm install
|
||||
|
||||
# Kill existing process (optional)
|
||||
- name: Stop previous instance
|
||||
run: |
|
||||
pkill -f "node .*app.js" || true
|
||||
pkill -f "node .*start.js" || true
|
||||
|
||||
# Start app in background
|
||||
- name: Start app
|
||||
run: |
|
||||
cd /var/www/myapp/Project
|
||||
nohup npm start > app.log 2>&1 &
|
||||
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
/traxer_api/.codeedit
|
||||
4059
alerts.json
Normal file
4059
alerts.json
Normal file
File diff suppressed because it is too large
Load Diff
22
app.js
Normal file
22
app.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import vehiclesRouter from "./src/routes/vehicles.js";
|
||||
import routesRouter from "./src/routes/routes.js";
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
const base = "/api/v0";
|
||||
|
||||
app.get(`${base}/`, (req, res) => {
|
||||
res.json({status: "ok", version: "v0", ts: new Date().toISOString()});
|
||||
});
|
||||
|
||||
app.use(`${base}/vehicles`, vehiclesRouter);
|
||||
|
||||
app.use(base, routesRouter);
|
||||
|
||||
app.get("/", (req, res) => res.redirect(`${base}/`));
|
||||
|
||||
export default app;
|
||||
846
package-lock.json
generated
Normal file
846
package-lock.json
generated
Normal file
@@ -0,0 +1,846 @@
|
||||
{
|
||||
"name": "project",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "project",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"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.1",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz",
|
||||
"integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"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/cors": {
|
||||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"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/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-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"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.3.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz",
|
||||
"integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"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.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz",
|
||||
"integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.7.0",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body/node_modules/iconv-lite": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
||||
"integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"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/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/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"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "project",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node start.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.nathanspackman.com/PRO150-Group/Project"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
}
|
||||
208
public/app.js
Normal file
208
public/app.js
Normal file
@@ -0,0 +1,208 @@
|
||||
|
||||
var streets = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
});
|
||||
|
||||
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
|
||||
}).addTo(map);
|
||||
|
||||
const API_URL = "http://localhost:7653/api/v0/";
|
||||
const ROUTE_STYLES = {
|
||||
"701": { color: "#0074D9", train: "🔵", stop: "🔹" },
|
||||
"704": { color: "#2ECC40", train: "🟢", stop: "🟩" },
|
||||
"703": { color: "#FF4136", train: "🔴", stop: "🔺" },
|
||||
"750": { color: "#B10DC9", train: "🟣", stop: "🔮" },
|
||||
"720": { color: "#000000", train: "⚪", stop: "🔷" }
|
||||
};
|
||||
|
||||
|
||||
function buildIcon(emoji, bearing) {
|
||||
const svg = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
|
||||
<text x="50%" y="50%" text-anchor="middle"
|
||||
dominant-baseline="central" font-size="26"
|
||||
font-family="Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, sans-serif"
|
||||
>
|
||||
${emoji}
|
||||
</text>
|
||||
</svg>`;
|
||||
|
||||
return L.divIcon({
|
||||
html: svg,
|
||||
className: "emoji-icon",
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -16]
|
||||
});
|
||||
}
|
||||
|
||||
function addMarker(lat, lon, content, icon) {
|
||||
if (!isNaN(lat) && !isNaN(lon)) {
|
||||
const marker = L.marker([lat, lon], { icon: icon }).addTo(map);
|
||||
if (content) marker.bindPopup(content);
|
||||
} else {
|
||||
console.warn("Invalid coordinates:", latitude, longitude);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function drawPolyLine(polylinePoints, color) {
|
||||
L.polyline(polylinePoints, { color, weight: 4, opacity: 0.8 }).addTo(map);
|
||||
}
|
||||
|
||||
function drawLine(route) {
|
||||
fetch(API_URL + "routepaths/" + route)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const trains = data.data;
|
||||
const filtered = route ? trains.filter(t => t.routeId == route) : trains;
|
||||
filtered.forEach(t => {
|
||||
addMarker(t.location.latitude, t.location.longitude, t.routeName + ": Vehicle " + t.vehicleId, trainEmojiIcon);
|
||||
});
|
||||
})
|
||||
.catch(err => console.error("Error fetching trains:", err));
|
||||
}
|
||||
|
||||
function drawLines() {
|
||||
MJR_LINES.forEach(drawLine);
|
||||
}
|
||||
|
||||
|
||||
let stopMarkers = {};
|
||||
function getStopsByRoute(route) {
|
||||
fetch(API_URL + 'stops/' + route)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stops = data.data;
|
||||
stops.forEach(s => {
|
||||
const lat = parseFloat(s.stop_lat);
|
||||
const lon = parseFloat(s.stop_lon);
|
||||
addMarker(lat,lon, s.stop_name + " - " + s.stop_desc, stopsEmojiIcon);
|
||||
});
|
||||
})
|
||||
.catch(err => console.error("Error fetching stops:", err));
|
||||
}
|
||||
|
||||
let trainMarkers = {};
|
||||
let filterType = "all";
|
||||
|
||||
const filterSelect = document.getElementById("filterSelect");
|
||||
if (filterSelect) {
|
||||
filterSelect.addEventListener("change", (e) => {
|
||||
filterType = e.target.value;
|
||||
});
|
||||
}
|
||||
|
||||
function refreshVehicles() {
|
||||
fetch(API_URL + "vehicles")
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
let vehicles = data.data;
|
||||
|
||||
if (filterType === "lrt") {
|
||||
vehicles = vehicles.filter(v => LRT_LINES.includes(v.routeNum) || FRONTRUNNER.includes(v.routeNum));
|
||||
}
|
||||
|
||||
vehicles = vehicles.filter(v => MJR_LINES.includes(v.routeNum));
|
||||
|
||||
Object.keys(trainMarkers).forEach(id => {
|
||||
if (!vehicles.find(v => v.vehicleId == id)) {
|
||||
map.removeLayer(trainMarkers[id]);
|
||||
delete trainMarkers[id];
|
||||
}
|
||||
});
|
||||
|
||||
vehicles.forEach(v => {
|
||||
const { vehicleId, routeNum, routeName, speed, bearing } = v;
|
||||
const lat = v.location.latitude;
|
||||
const lon = v.location.longitude;
|
||||
const icon = buildIcon(ROUTE_STYLES[routeNum].train, bearing);
|
||||
|
||||
if (!trainMarkers[vehicleId]) {
|
||||
const marker = L.marker([lat, lon], { icon })
|
||||
.bindPopup(`${routeName}<br>Vehicle ${vehicleId}<br>Speed: ${(speed*2.23694).toFixed(1)} mph`)
|
||||
.addTo(map);
|
||||
marker.vehicleData = v;
|
||||
trainMarkers[vehicleId] = marker;
|
||||
} else {
|
||||
if (trainMarkers[vehicleId].slideTo) {
|
||||
trainMarkers[vehicleId].slideTo([lat, lon], { duration: 1000 });
|
||||
} else {
|
||||
trainMarkers[vehicleId].setLatLng([lat, lon]);
|
||||
}
|
||||
trainMarkers[vehicleId].setIcon(icon);
|
||||
trainMarkers[vehicleId].vehicleData = v;
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(err => console.error("Error refreshing vehicles:", err));
|
||||
}
|
||||
|
||||
|
||||
let userMarker, accuracyCircle;
|
||||
const ON_BOARD_RADIUS = 50; // meters
|
||||
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(position) => {
|
||||
const lat = position.coords.latitude;
|
||||
const lon = position.coords.longitude;
|
||||
|
||||
userMarker = L.circleMarker([lat, lon], {
|
||||
radius: 8,
|
||||
fillColor: "#007AFF",
|
||||
color: "#fff",
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
fillOpacity: 0.9
|
||||
}).addTo(map);
|
||||
userMarker.bindPopup("You are here").openPopup();
|
||||
|
||||
accuracyCircle = L.circle([lat, lon], {
|
||||
radius: position.coords.accuracy,
|
||||
color: "#007AFF",
|
||||
fillColor: "#007AFF",
|
||||
fillOpacity: 0.2
|
||||
}).addTo(map);
|
||||
|
||||
map.setView([lat, lon], 13);
|
||||
},
|
||||
(err) => console.warn("Geolocation error:", err.message),
|
||||
{ enableHighAccuracy: true, timeout: 500, maximumAge: 0 }
|
||||
);
|
||||
|
||||
navigator.geolocation.watchPosition(
|
||||
(position) => {
|
||||
const userLat = position.coords.latitude;
|
||||
const userLon = position.coords.longitude;
|
||||
|
||||
if (userMarker) userMarker.setLatLng([userLat, userLon]);
|
||||
if (accuracyCircle) accuracyCircle.setLatLng([userLat, userLon]).setRadius(position.coords.accuracy);
|
||||
|
||||
const vehicles = Object.values(trainMarkers).map(m => m.vehicleData);
|
||||
let closest = null, minDistance = Infinity;
|
||||
|
||||
vehicles.forEach(v => {
|
||||
const distance = map.distance([userLat, userLon], [v.location.latitude, v.location.longitude]);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
closest = v;
|
||||
}
|
||||
});
|
||||
|
||||
if (closest && minDistance <= ON_BOARD_RADIUS) {
|
||||
console.log(`User is on vehicle ${closest.vehicleId} (${closest.routeNum})`);
|
||||
}
|
||||
},
|
||||
(err) => console.warn("Geolocation watch error:", err.message),
|
||||
{ enableHighAccuracy: true, maximumAge: 0 }
|
||||
);
|
||||
} else {
|
||||
console.warn("Geolocation not supported by this browser.");
|
||||
}
|
||||
|
||||
drawLines();
|
||||
MJR_LINES.forEach(r => getStopsByRoute(r));
|
||||
refreshVehicles();
|
||||
setInterval(refreshVehicles, 1000);
|
||||
24
public/index.html
Normal file
24
public/index.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Traxer</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||
crossorigin=""
|
||||
/>
|
||||
<script
|
||||
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
||||
crossorigin=""
|
||||
></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" class="w-full h-screen"></div>
|
||||
|
||||
</body>
|
||||
<script src="app.js"></script>
|
||||
|
||||
</html>
|
||||
0
scripts/validateData.js
Normal file
0
scripts/validateData.js
Normal file
46062
src/dal/data/routePath.json
Normal file
46062
src/dal/data/routePath.json
Normal file
File diff suppressed because it is too large
Load Diff
27
src/dal/data/routes.json
Normal file
27
src/dal/data/routes.json
Normal file
@@ -0,0 +1,27 @@
|
||||
[
|
||||
{
|
||||
"route_id": "701",
|
||||
"start_location": "Draper City Center",
|
||||
"end_location": "Salt Lake Central"
|
||||
},
|
||||
{
|
||||
"route_id": "703",
|
||||
"start_location": "Airport Station",
|
||||
"end_location": "West Valley Central Station"
|
||||
},
|
||||
{
|
||||
"route_id": "704",
|
||||
"start_location": "Daybreak Parkway Station",
|
||||
"end_location": "U. Of U. Medical Center Station"
|
||||
},
|
||||
{
|
||||
"route_id": "720",
|
||||
"start_location": "Provo Central Station",
|
||||
"end_location": "Ogden Station"
|
||||
},
|
||||
{
|
||||
"route_id": "750",
|
||||
"start_location": "Fairmont Station",
|
||||
"end_location": "Central Pointe Station"
|
||||
}
|
||||
]
|
||||
1494
src/dal/data/stations.json
Normal file
1494
src/dal/data/stations.json
Normal file
File diff suppressed because it is too large
Load Diff
68
src/dal/data/vehicles.json
Normal file
68
src/dal/data/vehicles.json
Normal file
@@ -0,0 +1,68 @@
|
||||
[
|
||||
{
|
||||
"vehicleId": "1003B",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Salt Lake Central",
|
||||
"bearing": 0.3,
|
||||
"location": {
|
||||
"latitude": 40.67723,
|
||||
"longitude": -111.8941
|
||||
}
|
||||
},
|
||||
{
|
||||
"vehicleId": "1016B",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Draper",
|
||||
"bearing": 89.9,
|
||||
"location": {
|
||||
"latitude": 40.76929,
|
||||
"longitude": -111.9005
|
||||
}
|
||||
},
|
||||
{
|
||||
"vehicleId": "1006A",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Salt Lake Central",
|
||||
"bearing": 358.6,
|
||||
"location": {
|
||||
"latitude": 40.76017,
|
||||
"longitude": -111.8911
|
||||
}
|
||||
},
|
||||
{
|
||||
"vehicleId": "1028A",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Draper",
|
||||
"bearing": 179.9,
|
||||
"location": {
|
||||
"latitude": 40.74292,
|
||||
"longitude": -111.8969
|
||||
}
|
||||
},
|
||||
{
|
||||
"vehicleId": "1004A",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Salt Lake Central",
|
||||
"bearing": 349,
|
||||
"location": {
|
||||
"latitude": 40.57289,
|
||||
"longitude": -111.8852
|
||||
}
|
||||
},
|
||||
{
|
||||
"vehicleId": "1008A",
|
||||
"routeNum": "701",
|
||||
"routeName": "Blue Line",
|
||||
"destination": "To Draper",
|
||||
"bearing": 180.6,
|
||||
"location": {
|
||||
"latitude": 40.65089,
|
||||
"longitude": -111.8982
|
||||
}
|
||||
}
|
||||
]
|
||||
159
src/dal/postgresDAL.js
Normal file
159
src/dal/postgresDAL.js
Normal file
@@ -0,0 +1,159 @@
|
||||
import pg from "pg";
|
||||
|
||||
const pool = new pg.Pool({
|
||||
connectionString: "postgresql://nate@localhost:5432/gtfs"
|
||||
});
|
||||
|
||||
async function dbQuery(sql, params = []) {
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
const res = await client.query(sql, params);
|
||||
return res.rows;
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
function toNumber(v) {
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : undefined;
|
||||
}
|
||||
|
||||
|
||||
export async function getVehicles() {
|
||||
const rows = await dbQuery(
|
||||
`SELECT vehicle_id, route_num, route_name, destination,
|
||||
bearing, speed, latitude, longitude
|
||||
FROM vehicles`
|
||||
);
|
||||
|
||||
return rows.map((v) => ({
|
||||
vehicleId: v.vehicle_id,
|
||||
routeNum: v.route_num,
|
||||
routeName: v.route_name,
|
||||
destination: v.destination,
|
||||
bearing: v.bearing == null ? undefined : toNumber(v.bearing),
|
||||
speed: v.speed == null ? undefined : toNumber(v.speed),
|
||||
location: {
|
||||
latitude: toNumber(v.latitude),
|
||||
longitude: toNumber(v.longitude),
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getVehicleById(id) {
|
||||
if (id == null) return null;
|
||||
|
||||
const rows = await dbQuery(
|
||||
`SELECT vehicle_id, route_num, route_name, destination,
|
||||
bearing, speed, latitude, longitude
|
||||
FROM vehicles
|
||||
WHERE vehicle_id = $1`,
|
||||
[String(id)]
|
||||
);
|
||||
|
||||
if (!rows.length) return null;
|
||||
const v = rows[0];
|
||||
|
||||
return {
|
||||
vehicleId: v.vehicle_id,
|
||||
routeNum: v.route_num,
|
||||
routeName: v.route_name,
|
||||
destination: v.destination,
|
||||
bearing: v.bearing == null ? undefined : toNumber(v.bearing),
|
||||
speed: v.speed == null ? undefined : toNumber(v.speed),
|
||||
location: {
|
||||
latitude: toNumber(v.latitude),
|
||||
longitude: toNumber(v.longitude),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export async function getRoutes() {
|
||||
const rows = await dbQuery(`SELECT data FROM routes ORDER BY route_id`);
|
||||
return rows.map((r) => r.data);
|
||||
}
|
||||
|
||||
export async function getRouteById(routeId) {
|
||||
if (routeId == null) return null;
|
||||
|
||||
const rows = await dbQuery(
|
||||
`SELECT data FROM routes WHERE route_id = $1`,
|
||||
[String(routeId)]
|
||||
);
|
||||
|
||||
return rows[0]?.data || null;
|
||||
}
|
||||
|
||||
|
||||
export async function getRoutePathsMap() {
|
||||
const rows = await dbQuery(`SELECT route_id, path FROM route_paths`);
|
||||
const map = {};
|
||||
for (const row of rows) {
|
||||
map[String(row.route_id)] = row.path;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
export async function getRoutePath(routeId) {
|
||||
if (routeId == null) return null;
|
||||
|
||||
const rows = await dbQuery(
|
||||
`SELECT path FROM route_paths WHERE route_id = $1`,
|
||||
[String(routeId)]
|
||||
);
|
||||
|
||||
return rows[0]?.path || null;
|
||||
}
|
||||
|
||||
|
||||
function transformationStationRow(row) {
|
||||
return {
|
||||
stop_id: row.stop_id,
|
||||
stop_code: row.stop_code,
|
||||
stop_name: row.stop_name,
|
||||
stop_desc: row.stop_desc,
|
||||
location: {
|
||||
latitude: toNumber(row.latitude),
|
||||
longitude: toNumber(row.longitude),
|
||||
},
|
||||
stop_url: row.stop_url,
|
||||
location_type: row.location_type,
|
||||
parent_station: row.parent_station,
|
||||
lines: row.lines, // text[]
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStationsRaw() {
|
||||
const rows = await dbQuery(`SELECT * FROM stations`);
|
||||
return rows;
|
||||
}
|
||||
|
||||
export async function getStations() {
|
||||
const rows = await dbQuery(`SELECT * FROM stations`);
|
||||
return rows.map(transformationStationRow);
|
||||
}
|
||||
|
||||
export async function getStopsByRoute(routeId) {
|
||||
if (routeId == null) return [];
|
||||
const rows = await dbQuery(
|
||||
`SELECT * FROM stations WHERE lines @> ARRAY[$1]::text[]`,
|
||||
[String(routeId)]
|
||||
);
|
||||
return rows.map(transformationStationRow);
|
||||
}
|
||||
|
||||
export async function getStationById(id) {
|
||||
if (id == null) return null;
|
||||
|
||||
const rows = await dbQuery(
|
||||
`SELECT * FROM stations WHERE stop_id = $1`,
|
||||
[String(id)]
|
||||
);
|
||||
|
||||
if (!rows.length) return null;
|
||||
return transformationStationRow(rows[0]);
|
||||
}
|
||||
|
||||
|
||||
192
src/dal/staticDal.js
Normal file
192
src/dal/staticDal.js
Normal file
@@ -0,0 +1,192 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const dataDir = path.join(process.cwd(), "src", "dal", "data");
|
||||
|
||||
function readJSON(name) {
|
||||
try {
|
||||
const p = path.join(dataDir, name);
|
||||
|
||||
if (!fs.existsSync(p)) return null;
|
||||
return JSON.parse(fs.readFileSync(p, "utf8"));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function toNumber(v) {
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : undefined;
|
||||
}
|
||||
|
||||
export function getVehicles() {
|
||||
const raw = readJSON("vehicles.json");
|
||||
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw.map(v => {
|
||||
const loc = v.location || {};
|
||||
|
||||
return {
|
||||
vehicleId: v.vehicleId,
|
||||
routeNum: v.routeNum,
|
||||
routeName: v.routeName,
|
||||
destination: v.destination,
|
||||
bearing: v.bearing == null ? undefined : toNumber(v.bearing),
|
||||
speed: v.speed == null ? undefined : toNumber(v.speed),
|
||||
location: {
|
||||
latitude: toNumber(loc.latitude),
|
||||
longitude: toNumber(loc.longitude)
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function getVehicleById(id) {
|
||||
if (id == null) return null;
|
||||
const vehicles = getVehicles();
|
||||
|
||||
return vehicles.find(v => String(v.vehicleId) === String(id)) || null;
|
||||
}
|
||||
|
||||
export function getRoutes() {
|
||||
const raw = readJSON("routes.json");
|
||||
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw;
|
||||
}
|
||||
|
||||
export function getRouteById(routeId) {
|
||||
if (routeId == null) return null;
|
||||
const routes = getRoutes();
|
||||
|
||||
return routes.find(r => String(r.route_id) === String(routeId)) || null;
|
||||
}
|
||||
|
||||
function readRoutepathsRaw() {
|
||||
const raw = readJSON("routePath.json");
|
||||
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw;
|
||||
}
|
||||
|
||||
export function getRoutePathsMap() {
|
||||
const raw = readRoutepathsRaw();
|
||||
const map = {};
|
||||
|
||||
for (const item of raw) {
|
||||
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
||||
const keys = Object.keys(item);
|
||||
|
||||
if (keys.length !== 1) continue;
|
||||
const k = String(keys[0]);
|
||||
|
||||
if (Array.isArray(item[k])) map[k] = item[k];
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
export function getRoutePath(routeId) {
|
||||
if (routeId == null) return null;
|
||||
const map = getRoutePathsMap();
|
||||
const key = String(routeId);
|
||||
|
||||
return Object.prototype.hasOwnProperty.call(map, key) ? map[key] : null;
|
||||
}
|
||||
|
||||
export function getStationsRaw() {
|
||||
return readJSON("stations.json") || null;
|
||||
}
|
||||
|
||||
export function getStations() {
|
||||
const raw = getStationsRaw();
|
||||
|
||||
if (raw == null) return [];
|
||||
if (Array.isArray(raw)) {
|
||||
const isArrayOfMaps = raw.every(item => typeof item === "object" && !Array.isArray(item) && Object.values(item).every(v => Array.isArray(v)));
|
||||
if (isArrayOfMaps) return raw.flatMap(item => Object.values(item).flat());
|
||||
return raw;
|
||||
}
|
||||
if (typeof raw === "object") {
|
||||
return Object.values(raw).flat();
|
||||
}
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
function transformationStation(s) {
|
||||
return {
|
||||
stop_id: s.stop_id,
|
||||
stop_code: s.stop_code,
|
||||
stop_name: s.stop_name,
|
||||
stop_desc: s.stop_desc,
|
||||
location: { latitude: toNumber(s.stop_lat), longitude: toNumber(s.stop_lon) },
|
||||
stop_url: s.stop_url,
|
||||
location_type: s.location_type,
|
||||
parent_station: s.parent_station,
|
||||
lines: s.lines
|
||||
};
|
||||
}
|
||||
|
||||
export function getStopsByRoute(routeId) {
|
||||
if (routeId == null) return [];
|
||||
const raw = getStationsRaw();
|
||||
|
||||
if (raw == null) return [];
|
||||
if (typeof raw === "object" && !Array.isArray(raw)) {
|
||||
const arr = raw[routeId];
|
||||
if (!Array.isArray(arr)) return [];
|
||||
return arr.map(transformationStation);
|
||||
}
|
||||
|
||||
if (Array.isArray(raw)) {
|
||||
const matchesFromArrayMaps = [];
|
||||
for (const item of raw) {
|
||||
if (typeof item === "object" && !Array.isArray(item) && Object.prototype.hasOwnProperty.call(item, routeId)) {
|
||||
const arr = item[routeId];
|
||||
if (Array.isArray(arr)) matchesFromArrayMaps.push(...arr.map(transformationStation));
|
||||
}
|
||||
}
|
||||
if (matchesFromArrayMaps.length) return matchesFromArrayMaps;
|
||||
|
||||
return raw.filter(s => Array.isArray(s.lines) && s.lines.map(String).includes(String(routeId))).map(transformationStation);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
export function getStationById(id) {
|
||||
if (id == null) return null;
|
||||
const raw = getStationsRaw();
|
||||
if (raw == null) return null;
|
||||
|
||||
if (typeof raw === "object" && !Array.isArray(raw)) {
|
||||
for (const key of Object.keys(raw)) {
|
||||
const arr = raw[key];
|
||||
if (!Array.isArray(arr)) continue;
|
||||
const found = arr.find(s => String(s.stop_id) === String(id) || String(s.stationId) === String(id));
|
||||
if (found) return transformationStation(found);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(raw)) {
|
||||
const isArrayOfMaps = raw.every(item => typeof item === "object" && !Array.isArray(item) && Object.values(item).every(v => Array.isArray(v)));
|
||||
if (isArrayOfMaps) {
|
||||
for (const item of raw) {
|
||||
for (const key of Object.keys(item)) {
|
||||
const arr = item[key];
|
||||
const found = arr.find(s => String(s.stop_id) === String(id));
|
||||
if (found) return transformationStation(found);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const found = raw.find(s => String(s.stop_id) === String(id) || String(s.stationId) === String(id));
|
||||
return found ? transformationStation(found) : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
69
src/routes/routes.js
Normal file
69
src/routes/routes.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import express from "express";
|
||||
import * as dal from "../dal/staticDal.js";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/routes", (req, res) => {
|
||||
const routes = dal.getRoutes();
|
||||
|
||||
res.json({meta: {returned: routes.length}, data: routes});
|
||||
});
|
||||
|
||||
router.get("/routes/:routeId", (req, res) => {
|
||||
const routeId = req.params.routeId;
|
||||
const route = dal.getRouteById(routeId);
|
||||
|
||||
if (!route) return res.status(404).json({error: "Route Was Not Found"});
|
||||
const stations = dal.getStopsByRoute(routeId);
|
||||
|
||||
res.json({data: {route, stations}});
|
||||
});
|
||||
|
||||
router.get("/route/:routeId", (req, res) => {
|
||||
const routeId = req.params.routeId;
|
||||
const route = dal.getRouteById(routeId);
|
||||
|
||||
if (!route) return res.status(404).json({error: "Route Was Not Found"});
|
||||
const stations = dal.getStopsByRoute(routeId);
|
||||
|
||||
res.json({data: {route, stations}});
|
||||
});
|
||||
|
||||
router.get("/routepaths/:routeId", (req, res) => {
|
||||
const routeId = req.params.routeId;
|
||||
const rp = dal.getRoutePath(routeId);
|
||||
|
||||
if (!rp) return res.status(404).json({error: "RoutePath Was Not Found"});
|
||||
res.json({meta: {routeId: String(routeId), returned: Array.isArray(rp) ? rp.length : 0}, data: rp});
|
||||
});
|
||||
|
||||
router.get("/routes/:routeId/stations", (req, res) => {
|
||||
const routeId = req.params.routeId;
|
||||
const stations = dal.getStopsByRoute(routeId);
|
||||
|
||||
res.json({meta: {routeId: String(routeId), returned: stations.length}, data: stations});
|
||||
});
|
||||
|
||||
router.get("/stops/:routeId", (req, res) => {
|
||||
const routeId = req.params.routeId;
|
||||
const stations = dal.getStopsByRoute(routeId);
|
||||
|
||||
res.json({meta: {routeId: String(routeId), returned: stations.length}, data: stations});
|
||||
});
|
||||
|
||||
router.get("/stations", (req, res) => {
|
||||
const route = req.query.route;
|
||||
const stations = route ? dal.getStopsByRoute(route) : dal.getStations();
|
||||
|
||||
res.json({meta: {returned: stations.length}, data: stations});
|
||||
});
|
||||
|
||||
router.get("/station/:stationId", (req, res) => {
|
||||
const stationId = req.params.stationId;
|
||||
const station = dal.getStationById(stationId);
|
||||
|
||||
if (!station) return res.status(404).json({error: "Station Was Not Found"});
|
||||
res.json({data: station});
|
||||
});
|
||||
|
||||
export default router;
|
||||
48
src/routes/vehicles.js
Normal file
48
src/routes/vehicles.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import express from "express";
|
||||
import * as dal from "../dal/staticDal.js";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
let vehicles = dal.getVehicles();
|
||||
|
||||
const {routeNum, routeName, destination, minLat, maxLat, minLng, maxLng, limit} = req.query;
|
||||
|
||||
if (routeNum) vehicles = vehicles.filter(v => String(v.routeNum) === String(routeNum));
|
||||
if (routeName) vehicles = vehicles.filter(v => v.routeName && v.routeName.toLowerCase().includes(String(routeName).toLowerCase()));
|
||||
if (destination) vehicles = vehicles.filter(v => v.destination && v.destination.toLowerCase().includes(String(destination).toLowerCase()));
|
||||
|
||||
if (minLat || maxLat || minLng || maxLng) {
|
||||
const minLatN = parseFloat(minLat ?? -90);
|
||||
const maxLatN = parseFloat(maxLat ?? 90);
|
||||
const minLngN = parseFloat(minLng ?? -180);
|
||||
const maxLngN = parseFloat(maxLng ?? 180);
|
||||
|
||||
vehicles = vehicles.filter(v => {
|
||||
const lat = parseFloat(v.location?.latitude);
|
||||
const lng = parseFloat(v.location?.longitude);
|
||||
|
||||
return lat >= minLatN && lat <= maxLatN && lng >= minLngN && lng <= maxLngN;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
let returned = vehicles.length;
|
||||
if (limit) {
|
||||
const lim = Math.max(1, Math.min(1000, parseInt(limit, 10) || 100));
|
||||
|
||||
vehicles = vehicles.slice(0, lim);
|
||||
returned = vehicles.length;
|
||||
}
|
||||
|
||||
res.json({meta: {returned}, data: vehicles});
|
||||
});
|
||||
|
||||
router.get("/:id", (req, res) => {
|
||||
const v = dal.getVehicleById(req.params.id);
|
||||
if (!v) return res.status(404).json({error: "Vehicle Was Not Found"});
|
||||
|
||||
res.json({data: v});
|
||||
});
|
||||
|
||||
export default router;
|
||||
12
start.js
Normal file
12
start.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import express from "express";
|
||||
import app from "./app.js";
|
||||
|
||||
const PORT = process.env.PORT || 7653;
|
||||
|
||||
// Serve static files from "public" folder
|
||||
app.use(express.static('public'));
|
||||
|
||||
// Start the server
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Transit API running at http://localhost:${PORT}`);
|
||||
});
|
||||
69024
tripUpdates.json
Normal file
69024
tripUpdates.json
Normal file
File diff suppressed because it is too large
Load Diff
6689
vehicles.json
Normal file
6689
vehicles.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user