UNPKG

express-route-docs

Version:

Zero-config route documentation generator for Express.js APIs

98 lines (65 loc) โ€ข 2.14 kB
# ๐Ÿ“˜ express-route-docs <p align="center"> <a href="https://www.npmjs.com/package/express-route-docs"> <img alt="npm version" src="https://img.shields.io/npm/v/express-route-docs?cacheSeconds=60" /> </a> <a href="https://github.com/DeeapakSarun/express-route-docs/blob/main/LICENSE"> <img alt="license" src="https://img.shields.io/npm/l/express-route-docs?cacheSeconds=60" /> </a> </p> > Instantly document your Express routes with a clean and developer-friendly `/docs` page. --- ## ๐Ÿš€ Features - ๐Ÿ“„ Auto-generates a visual list of all your registered Express routes - ๐Ÿ” Clean and copyable format for developers - โš™๏ธ Works seamlessly in dev or production without hardcoding ports - ๐ŸŽจ Easy to customize CSS and layout --- ## ๐Ÿ“ฆ Installation ```bash npm install express-route-docs ```` --- ## ๐Ÿ”ง Usage 1. **Set up your Express server:** ```js // index.js const express = require("express"); const { setupRouteTracking, docsHandler } = require("express-route-docs"); const app = express(); // Track all routes dynamically setupRouteTracking(app); // Define your API routes app.get("/", (req, res) => res.send("Welcome")); app.post("/submit", (req, res) => res.send("Submitted")); app.delete("/user", (req, res) => res.send("User deleted")); // Serve docs app.get("/docs", docsHandler); // Start server const port = process.env.PORT || 3000; app.listen(port, () => { console.log(`๐Ÿš€ Docs available at http://localhost:${port}/docs`); }); ``` 2. **Optionally include CSS customization** You can override the default styles by placing a CSS file in a `public` directory. --- ## ๐Ÿ“ Folder Structure ``` project-root/ โ”œโ”€โ”€ index.js โ”œโ”€โ”€ public/ โ”‚ โ””โ”€โ”€ style.css (optional) ``` --- ## ๐Ÿงช Example Output > Go to `http://localhost:3000/docs` > Youโ€™ll see a clean, centered list of your routes, ideal for internal dev teams. --- ## ๐Ÿง‘โ€๐Ÿ’ป Author **Deepak Sarun Yuvachandran** [GitHub](https://github.com/DeeapakSarun) [Portfolio](https://jobquestgame.netlify.app/) --- ## ๐Ÿ“„ License This project is licensed under the [MIT License](LICENSE).