📘 How to Use This Repository

Example 1 - Endpoint Generator

node ./test/v15/forEndPoints.js

The generator reads end-points.js, collects import statements, router.get(), router.post(), router.put(), and router.delete() methods, calculates the insertion position, and updates the file automatically.

Before

import funcFromfind from "./find/controller.js";

router.get("/find/:ledgerName", ...);

After

import funcFromfind from "./find/controller.js";
import funcFromshowAll from "./showAll/controller.js";

router.get("/find/:ledgerName", ...);
router.get("/funcFromshowAll", ...);

Example 2 - Routes Generator

node ./test/v15/forRoutesEnd.js

The generator reads routes.js, finds router imports and router.use() statements, determines the correct insertion location, and updates the routing file automatically.

Before

import { router as routerFromFold1 } from "./Fold1/end-points.js";

router.use("/table1", routerFromFold1);

After

import { router as routerFromFold2 } from "./Fold2/end-points.js";

router.use("/routerFromFold2", Fold2);

Internal Flow


Read Source
   ↓
Pattern Collector
   ↓
Regex Matching
   ↓
Story Builder
   ↓
Return Indexes
   ↓
Generator Updates File

💡 How This Repository Solves the Problem

pattern-collector-anyjs-story acts like a smart code reader.

Instead of blindly searching text, it understands the structure of JavaScript routing files and identifies exactly where new code should be inserted.

📥 Finds Import Statements
🛣️ Finds router.use()
⚡ Finds GET / POST / PUT / DELETE Methods
📍 Calculates Correct Line Numbers
🚫 Prevents Duplicate Code
💾 Returns Safe Insert Positions