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.
Files changed (2) hide show
  1. package/lieko-express.js +34 -30
  2. 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
- if (this.routes.length === 0) {
1890
- console.log('\nNo routes registered.\n');
1891
- return;
1892
- }
1889
+ setImmediate(() => {
1890
+ if (this.routes.length === 0) {
1891
+ console.log('\nNo routes registered.\n');
1892
+ return;
1893
+ }
1893
1894
 
1894
- console.log(`\nRegistered Routes: ${this.routes.length}\n`);
1895
+ console.log(`\nRegistered Routes: ${this.routes.length}\n`);
1895
1896
 
1896
- const grouped = new Map();
1897
+ const grouped = new Map();
1897
1898
 
1898
- for (const route of this.routes) {
1899
- const key = `${route.method}|${route.handler}`;
1900
- if (!grouped.has(key)) {
1901
- grouped.set(key, {
1902
- method: route.method,
1903
- paths: [],
1904
- mw: route.middlewares.length
1905
- });
1906
- }
1907
- const entry = grouped.get(key);
1908
- const p = route.path || '/';
1909
- if (!entry.paths.includes(p)) {
1910
- entry.paths.push(p);
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
- const sorted = Array.from(grouped.values()).sort((a, b) => {
1915
- if (a.method !== b.method) return a.method.localeCompare(b.method);
1916
- return a.paths[0].localeCompare(b.paths[0]);
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
- for (const r of sorted) {
1920
- const pathStr = r.paths.length === 1
1921
- ? r.paths[0]
1922
- : r.paths.join(', ');
1920
+ for (const r of sorted) {
1921
+ const pathStr = r.paths.length === 1
1922
+ ? r.paths[0]
1923
+ : r.paths.join(', ');
1923
1924
 
1924
- console.log(` \x1b[36m${r.method.padEnd(7)}\x1b[0m \x1b[33m${pathStr}\x1b[0m \x1b[90m(mw: ${r.mw})\x1b[0m`);
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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lieko-express",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/eiwSrvt/lieko-express"