lieko-express 1.0.1 → 1.0.21
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 +38 -30
- package/package.json +1 -1
package/lieko-express.js
CHANGED
|
@@ -1610,6 +1610,10 @@ ${cyan} (req, res, next) => {
|
|
|
1610
1610
|
return res.status(201).json({ data, message });
|
|
1611
1611
|
};
|
|
1612
1612
|
|
|
1613
|
+
res.notModified = () => {
|
|
1614
|
+
return res.status(304).end();
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1613
1617
|
res.noContent = () => {
|
|
1614
1618
|
return res.status(204).end();
|
|
1615
1619
|
};
|
|
@@ -1886,43 +1890,47 @@ ${cyan} (req, res, next) => {
|
|
|
1886
1890
|
}
|
|
1887
1891
|
|
|
1888
1892
|
printRoutes() {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
+
setImmediate(() => {
|
|
1894
|
+
if (this.routes.length === 0) {
|
|
1895
|
+
console.log('\nNo routes registered.\n');
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1893
1898
|
|
|
1894
|
-
|
|
1899
|
+
console.log(`\nRegistered Routes: ${this.routes.length}\n`);
|
|
1895
1900
|
|
|
1896
|
-
|
|
1901
|
+
const grouped = new Map();
|
|
1897
1902
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1903
|
+
for (const route of this.routes) {
|
|
1904
|
+
const key = `${route.method}|${route.handler}`;
|
|
1905
|
+
if (!grouped.has(key)) {
|
|
1906
|
+
grouped.set(key, {
|
|
1907
|
+
method: route.method,
|
|
1908
|
+
paths: [],
|
|
1909
|
+
mw: route.middlewares.length
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
const entry = grouped.get(key);
|
|
1913
|
+
const p = route.path || '/';
|
|
1914
|
+
if (!entry.paths.includes(p)) {
|
|
1915
|
+
entry.paths.push(p);
|
|
1916
|
+
}
|
|
1911
1917
|
}
|
|
1912
|
-
}
|
|
1913
1918
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1919
|
+
const sorted = Array.from(grouped.values()).sort((a, b) => {
|
|
1920
|
+
if (a.method !== b.method) return a.method.localeCompare(b.method);
|
|
1921
|
+
return a.paths[0].localeCompare(b.paths[0]);
|
|
1922
|
+
});
|
|
1918
1923
|
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1924
|
+
for (const r of sorted) {
|
|
1925
|
+
const pathStr = r.paths.length === 1
|
|
1926
|
+
? r.paths[0]
|
|
1927
|
+
: r.paths.join(', ');
|
|
1923
1928
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1929
|
+
console.log(` \x1b[36m${r.method.padEnd(7)}\x1b[0m \x1b[33m${pathStr}\x1b[0m \x1b[90m(mw: ${r.mw})\x1b[0m`);
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
|
|
1933
|
+
return this;
|
|
1926
1934
|
}
|
|
1927
1935
|
|
|
1928
1936
|
listen() {
|