timetable-api-node 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +32 -7
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -35,11 +35,20 @@ import {
|
|
|
35
35
|
|
|
36
36
|
const app = express();
|
|
37
37
|
|
|
38
|
+
app.set("trust proxy", true);
|
|
39
|
+
|
|
38
40
|
app.use(cors());
|
|
39
41
|
|
|
40
42
|
app.use((req, res, next) => {
|
|
41
|
-
const baseUrl =
|
|
42
|
-
res.set(
|
|
43
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
44
|
+
res.set(
|
|
45
|
+
"Link",
|
|
46
|
+
[
|
|
47
|
+
`<${baseUrl}/.well-known/oauth-protected-resource>; rel="oauth-protected-resource"`,
|
|
48
|
+
`<${baseUrl}/.well-known/mcp/server-card.json>; rel="service-desc"`,
|
|
49
|
+
`<${baseUrl}/mcp>; rel="mcp-server"`,
|
|
50
|
+
].join(", "),
|
|
51
|
+
);
|
|
43
52
|
res.set("X-MCP-Server", `${baseUrl}/.well-known/mcp/server-card.json`);
|
|
44
53
|
next();
|
|
45
54
|
});
|
|
@@ -74,7 +83,7 @@ app.get("/.well-known/openapi.yaml", (req, res) => {
|
|
|
74
83
|
});
|
|
75
84
|
|
|
76
85
|
app.get("/.well-known/ai-plugin.json", (req, res) => {
|
|
77
|
-
const baseUrl =
|
|
86
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
78
87
|
res.set("Cache-Control", `public, max-age=0, s-maxage=${3600 * 24}`);
|
|
79
88
|
res.json({
|
|
80
89
|
schema_version: "v1",
|
|
@@ -96,7 +105,7 @@ app.get("/.well-known/ai-plugin.json", (req, res) => {
|
|
|
96
105
|
});
|
|
97
106
|
|
|
98
107
|
app.get("/.well-known/agent.json", (req, res) => {
|
|
99
|
-
const baseUrl =
|
|
108
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
100
109
|
res.set("Cache-Control", `public, max-age=0, s-maxage=${3600 * 24}`);
|
|
101
110
|
res.json({
|
|
102
111
|
name: "Lviv Public Transport",
|
|
@@ -219,8 +228,24 @@ app.all("/mcp", (req, res) => {
|
|
|
219
228
|
});
|
|
220
229
|
});
|
|
221
230
|
|
|
231
|
+
app.get("/.well-known/oauth-protected-resource", (req, res) => {
|
|
232
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
233
|
+
res.set("Cache-Control", `public, max-age=0, s-maxage=${3600 * 24}`);
|
|
234
|
+
res.json({
|
|
235
|
+
resource: baseUrl,
|
|
236
|
+
authorization_required: false,
|
|
237
|
+
authorization_servers: [],
|
|
238
|
+
scopes_supported: [],
|
|
239
|
+
bearer_methods_supported: [],
|
|
240
|
+
resource_signing_alg_values_supported: [],
|
|
241
|
+
x_no_auth_required: true,
|
|
242
|
+
x_public_access:
|
|
243
|
+
"All API endpoints are open and do not require authentication. Agents and clients may call them directly without obtaining tokens.",
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
222
247
|
app.get("/.well-known/mcp/server-card.json", (req, res) => {
|
|
223
|
-
const baseUrl =
|
|
248
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
224
249
|
res.json(buildMcpServerCard(baseUrl));
|
|
225
250
|
});
|
|
226
251
|
|
|
@@ -231,7 +256,7 @@ app.get("/mcp-icon.svg", (req, res) => {
|
|
|
231
256
|
});
|
|
232
257
|
|
|
233
258
|
app.get("/robots.txt", (req, res) => {
|
|
234
|
-
const baseUrl =
|
|
259
|
+
const baseUrl = `${req.protocol}://${req.hostname}`;
|
|
235
260
|
const lines = [
|
|
236
261
|
"User-agent: *",
|
|
237
262
|
"Disallow: /private/",
|
|
@@ -274,7 +299,7 @@ Sentry.setupExpressErrorHandler(app);
|
|
|
274
299
|
|
|
275
300
|
app.use(function (err, req, res, next) {
|
|
276
301
|
console.error(err.stack);
|
|
277
|
-
res.status(500).
|
|
302
|
+
res.status(500).json({ error: "Internal server error" });
|
|
278
303
|
});
|
|
279
304
|
|
|
280
305
|
app.on("ready", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timetable-api-node",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Lviv (Ukraine) public transport REST API and read-only Model Context Protocol (MCP) server: stops, timetables, routes, live vehicle positions, GTFS/GTFS-RT. No API key required.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dotenv": "^17.4",
|
|
36
36
|
"express": "^5.2.1",
|
|
37
37
|
"gtfs": "^4.18.5",
|
|
38
|
-
"gtfs-realtime-bindings": "^
|
|
38
|
+
"gtfs-realtime-bindings": "^2.0.0",
|
|
39
39
|
"lokijs": "^1.5.12",
|
|
40
40
|
"npm-config": "^0.2.0",
|
|
41
41
|
"protobufjs": ">=8.2.0",
|