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.
Files changed (2) hide show
  1. package/lieko-express.js +38 -30
  2. 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
- if (this.routes.length === 0) {
1890
- console.log('\nNo routes registered.\n');
1891
- return;
1892
- }
1893
+ setImmediate(() => {
1894
+ if (this.routes.length === 0) {
1895
+ console.log('\nNo routes registered.\n');
1896
+ return;
1897
+ }
1893
1898
 
1894
- console.log(`\nRegistered Routes: ${this.routes.length}\n`);
1899
+ console.log(`\nRegistered Routes: ${this.routes.length}\n`);
1895
1900
 
1896
- const grouped = new Map();
1901
+ const grouped = new Map();
1897
1902
 
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);
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
- 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
- });
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
- for (const r of sorted) {
1920
- const pathStr = r.paths.length === 1
1921
- ? r.paths[0]
1922
- : r.paths.join(', ');
1924
+ for (const r of sorted) {
1925
+ const pathStr = r.paths.length === 1
1926
+ ? r.paths[0]
1927
+ : r.paths.join(', ');
1923
1928
 
1924
- console.log(` \x1b[36m${r.method.padEnd(7)}\x1b[0m \x1b[33m${pathStr}\x1b[0m \x1b[90m(mw: ${r.mw})\x1b[0m`);
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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lieko-express",
3
- "version": "1.0.1",
3
+ "version": "1.0.21",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/eiwSrvt/lieko-express"