lieko-express 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lieko-express.js +34 -30
- package/package.json +1 -1
package/lieko-express.js
CHANGED
|
@@ -1886,43 +1886,47 @@ ${cyan} (req, res, next) => {
|
|
|
1886
1886
|
}
|
|
1887
1887
|
|
|
1888
1888
|
printRoutes() {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1889
|
+
setImmediate(() => {
|
|
1890
|
+
if (this.routes.length === 0) {
|
|
1891
|
+
console.log('\nNo routes registered.\n');
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1893
1894
|
|
|
1894
|
-
|
|
1895
|
+
console.log(`\nRegistered Routes: ${this.routes.length}\n`);
|
|
1895
1896
|
|
|
1896
|
-
|
|
1897
|
+
const grouped = new Map();
|
|
1897
1898
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1899
|
+
for (const route of this.routes) {
|
|
1900
|
+
const key = `${route.method}|${route.handler}`;
|
|
1901
|
+
if (!grouped.has(key)) {
|
|
1902
|
+
grouped.set(key, {
|
|
1903
|
+
method: route.method,
|
|
1904
|
+
paths: [],
|
|
1905
|
+
mw: route.middlewares.length
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
const entry = grouped.get(key);
|
|
1909
|
+
const p = route.path || '/';
|
|
1910
|
+
if (!entry.paths.includes(p)) {
|
|
1911
|
+
entry.paths.push(p);
|
|
1912
|
+
}
|
|
1911
1913
|
}
|
|
1912
|
-
}
|
|
1913
1914
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1915
|
+
const sorted = Array.from(grouped.values()).sort((a, b) => {
|
|
1916
|
+
if (a.method !== b.method) return a.method.localeCompare(b.method);
|
|
1917
|
+
return a.paths[0].localeCompare(b.paths[0]);
|
|
1918
|
+
});
|
|
1918
1919
|
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1920
|
+
for (const r of sorted) {
|
|
1921
|
+
const pathStr = r.paths.length === 1
|
|
1922
|
+
? r.paths[0]
|
|
1923
|
+
: r.paths.join(', ');
|
|
1923
1924
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1925
|
+
console.log(` \x1b[36m${r.method.padEnd(7)}\x1b[0m \x1b[33m${pathStr}\x1b[0m \x1b[90m(mw: ${r.mw})\x1b[0m`);
|
|
1926
|
+
}
|
|
1927
|
+
});
|
|
1928
|
+
|
|
1929
|
+
return this;
|
|
1926
1930
|
}
|
|
1927
1931
|
|
|
1928
1932
|
listen() {
|