@tsed/platform-http
Version:
A TypeScript Framework on top of Express
34 lines (33 loc) • 836 B
JavaScript
import { $log, colorize } from "@tsed/logger";
export function printRoutes(routes) {
const mapColor = {
GET: "green",
POST: "yellow",
PUT: "blue",
DELETE: "red",
PATCH: "magenta",
ALL: "cyan",
STATICS: "white"
};
const list = routes.map((route) => {
const method = route.method.toUpperCase();
return {
...route,
method: {
length: method.length,
toString: () => {
return colorize(method, mapColor[method]);
}
}
};
});
const str = $log.drawTable(list, {
padding: 1,
header: {
method: "Method",
url: "Endpoint",
name: "Class method"
}
});
return "\n" + str.trim();
}