Skip to main content
Glama
routeIntrospector.test.ts809 B
import express from "express"; import { describe, expect, it } from "vitest"; import { RouteIntrospector } from "../src/routeIntrospector"; describe("RouteIntrospector", () => { it("discovers routes and methods", () => { const app = express(); app.get("/hello", (_req, res) => res.send("ok")); // Express lazily creates the router, so we need to trigger it // by calling app.handle or by accessing the internal router const router = (app as unknown as { _router?: unknown })._router; if (!router) { // Force router creation by calling lazyrouter (app as unknown as { lazyrouter: () => void }).lazyrouter(); } const ri = new RouteIntrospector(app); const routes = ri.listRoutes(); expect(routes.some((r) => r.method === "GET" && r.path === "/hello")).toBe( true, ); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bowen31337/expressjs_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server