express-route-docs
Version:
Zero-config route documentation generator for Express.js APIs
98 lines (65 loc) โข 2.14 kB
Markdown
# ๐ 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).