- Migration 100: adds `description` column to standards (plain-language
DE·EN for non-technical colleagues), fills all 63 standards incl.
complete 200G tier (SR4/DR4/FR4/LR4/ER4/CR4), copper DAC variants,
PON family (GPON/XG-PON1/NG-PON2/25G-PON), 1.6T emerging standard
- Migration 101: new form_factors table — 20 entries covering SFP family
(SFP→SFP112), QSFP family (QSFP+→QSFP-DD800), OSFP family (OSFP→OSFP224),
CFP family, legacy XFP/CXP with full_name, speed, channels, status,
supersedes chain, and bilingual plain-language descriptions
- GET /api/form-factors — new endpoint, returns all form factors with
transceiver_count join
- GET /api/form-factors/:name — single form factor detail
Dashboard Standards tab:
- DB description shown as subtitle in standards table rows
- Full DE + EN description in standard detail panel
- New Form Factors grid section with status badges, speed, channel info,
family color coding, supersedes chain
- openFormFactorDetail() panel with full specs + transceiver link
- Search extended to match description + notes fields
153 lines
5.8 KiB
TypeScript
153 lines
5.8 KiB
TypeScript
import express from "express";
|
|
import cors from "cors";
|
|
import helmet from "helmet";
|
|
import rateLimit from "express-rate-limit";
|
|
import { join } from "path";
|
|
import { cfg } from "./config";
|
|
import { authRouter } from "./routes/auth";
|
|
import { requireAuth } from "./middleware/require-auth";
|
|
import { transceiverRouter } from "./routes/transceivers";
|
|
import { switchRouter } from "./routes/switches";
|
|
import { vendorRouter } from "./routes/vendors";
|
|
import { standardRouter } from "./routes/standards";
|
|
import { healthRouter } from "./routes/health";
|
|
import { hypeCycleRouter } from "./routes/hype-cycle";
|
|
import { searchRouter } from "./routes/search";
|
|
import { documentRouter } from "./routes/documents";
|
|
import { blogRouter } from "./routes/blog";
|
|
import { blogSllRouter } from "./routes/blog-sll";
|
|
import { scraperRouter } from "./routes/scrapers";
|
|
import { finderRouter } from "./routes/finder";
|
|
import { competitorRouter } from "./routes/competitor-alerts";
|
|
import { forecastRouter } from "./routes/forecast";
|
|
import { transportRouter } from "./routes/transport";
|
|
import { datasheetRouter } from "./routes/datasheets";
|
|
import { hotTopicsRouter } from "./routes/hot-topics";
|
|
import { adoptionRouter } from "./routes/adoption";
|
|
import { procurementRouter } from "./routes/procurement";
|
|
import { changelogRouter } from "./routes/changelog";
|
|
import { newsRouter } from "./routes/news";
|
|
import { proxyRouter } from "./routes/proxy";
|
|
import { reviewRouter } from "./routes/review";
|
|
import { stockRouter } from "./routes/stock";
|
|
import { priceComparisonRouter } from "./routes/price-comparison";
|
|
import { selflearningRouter } from "./routes/selflearning";
|
|
import { internalDemandRouter } from "./routes/internal-demand";
|
|
import { formFactorsRouter } from "./routes/form-factors";
|
|
|
|
const app = express();
|
|
|
|
// Trust Cloudflare proxy (required for express-rate-limit with X-Forwarded-For)
|
|
app.set("trust proxy", 1);
|
|
|
|
// Middleware
|
|
app.use(helmet({ contentSecurityPolicy: false }));
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
app.use(
|
|
rateLimit({
|
|
windowMs: 60 * 1000,
|
|
max: 200,
|
|
standardHeaders: true,
|
|
legacyHeaders: false,
|
|
})
|
|
);
|
|
|
|
// Auth (public — no requireAuth here)
|
|
app.use("/api/auth", authRouter);
|
|
|
|
// Proxy public endpoints (register + heartbeat + stats + next — no auth)
|
|
app.use("/api/proxy", proxyRouter);
|
|
|
|
// All other API routes require a valid token
|
|
app.use("/api", (req, res, next) => {
|
|
// Always allow: health check, auth endpoints, proxy public routes, hot-topics (public market data)
|
|
if (req.path.startsWith("/health") || req.path.startsWith("/auth")) return next();
|
|
if (req.path.startsWith("/proxy")) return next();
|
|
if (req.path.startsWith("/hot-topics")) return next();
|
|
if (req.path.startsWith("/price-comparison")) return next();
|
|
requireAuth(req, res, next);
|
|
});
|
|
|
|
// Routes
|
|
app.use("/api/transceivers", transceiverRouter);
|
|
app.use("/api/switches", switchRouter);
|
|
app.use("/api/vendors", vendorRouter);
|
|
app.use("/api/standards", standardRouter);
|
|
app.use("/api/health", healthRouter);
|
|
app.use("/api/hype-cycle", hypeCycleRouter);
|
|
app.use("/api/search", searchRouter);
|
|
app.use("/api/documents", documentRouter);
|
|
app.use("/api/blog", blogSllRouter);
|
|
app.use("/api/blog", blogRouter);
|
|
app.use("/api/scrapers", scraperRouter);
|
|
app.use("/api/finder", finderRouter);
|
|
app.use("/api/competitor-alerts", competitorRouter);
|
|
app.use("/api/forecast", forecastRouter);
|
|
app.use("/api/transport", transportRouter);
|
|
app.use("/api/datasheets", datasheetRouter);
|
|
app.use("/api/adoption", adoptionRouter);
|
|
app.use("/api/hot-topics", hotTopicsRouter);
|
|
app.use("/api/procurement", procurementRouter);
|
|
app.use("/api/changelog", changelogRouter);
|
|
app.use("/api/news", newsRouter);
|
|
app.use("/api/review", reviewRouter);
|
|
app.use("/api/stock", stockRouter);
|
|
app.use("/api/price-comparison", priceComparisonRouter);
|
|
app.use("/api/selflearning", selflearningRouter);
|
|
// Form Factors reference
|
|
app.use("/api/form-factors", formFactorsRouter);
|
|
// Internal-only — restricted to localhost / LAN by the router itself
|
|
app.use("/api/internal/demand", internalDemandRouter);
|
|
|
|
// Dashboard (static HTML)
|
|
app.use("/dashboard", express.static(join(__dirname, "..", "..", "dashboard")));
|
|
|
|
// Root — redirect to dashboard
|
|
app.get("/", (_req, res) => {
|
|
res.redirect("/dashboard/");
|
|
});
|
|
|
|
// API info
|
|
app.get("/api", (_req, res) => {
|
|
res.json({
|
|
name: "Transceiver Intelligence Platform",
|
|
version: "0.3.0",
|
|
endpoints: [
|
|
"GET /api/transceivers?q=&form_factor=&speed=&category=&fiber_type=&wdm_type=&coherent=",
|
|
"GET /api/transceivers/:id",
|
|
"GET /api/switches?q=&category=",
|
|
"GET /api/switches/:id",
|
|
"GET /api/switches/:id/compatibility",
|
|
"GET /api/vendors?type=",
|
|
"GET /api/standards?speed=",
|
|
"GET /api/health",
|
|
"GET /api/hype-cycle",
|
|
"GET /api/hype-cycle/:tech",
|
|
"GET /api/search?q=&collection=&limit=",
|
|
"GET /api/search/products?q=&form_factor=&speed_gbps=&fiber_type=",
|
|
"GET /api/search/documents?q=&doc_type=&vendor=&collection=",
|
|
"GET /api/search/news?q=&source=",
|
|
"GET /api/search/stats",
|
|
"POST /api/documents/process {url, title?, doc_type?, vendor?, collection?}",
|
|
"GET /api/documents",
|
|
"GET /api/documents/:id",
|
|
"POST /api/blog/generate {topic, speed?, form_factor?, use_case?}",
|
|
"GET /api/blog",
|
|
"GET /api/blog/:id",
|
|
"PUT /api/blog/:id/status {status: draft|review|approved|published}",
|
|
"GET /api/selflearning/status",
|
|
"POST /api/selflearning/build",
|
|
"POST /api/selflearning/publish-hf",
|
|
"POST /api/selflearning/train {lane, provider, seed_only?, max_steps?}",
|
|
],
|
|
});
|
|
});
|
|
|
|
// Start
|
|
app.listen(cfg.port, () => {
|
|
console.log(`\n TIP API running on http://localhost:${cfg.port}`);
|
|
console.log(` Environment: ${cfg.nodeEnv}`);
|
|
console.log(` Database: ${cfg.db.host}:${cfg.db.port}/${cfg.db.database}\n`);
|
|
});
|