✨ route middleware test option

This commit is contained in:
Flam3rboy
2021-09-18 11:56:06 +02:00
parent a7bf295591
commit a3484e64e4
4 changed files with 12 additions and 13 deletions
+4 -2
View File
@@ -2,6 +2,7 @@ import { traverseDirectory } from "lambert-server";
import path from "path";
import express from "express";
import * as RouteUtility from "../dist/util/route";
import { RouteOptions } from "../dist/util/route";
const Router = express.Router;
const routes = new Map<string, RouteUtility.RouteOptions>();
@@ -12,9 +13,10 @@ const methods = ["get", "post", "put", "delete", "patch"];
function registerPath(file, method, prefix, path, ...args) {
const urlPath = prefix + path;
const sourceFile = file.replace("/dist/", "/src/").replace(".js", ".ts");
const opts = args.find((x) => typeof x === "object");
const opts: RouteOptions = args.find((x) => typeof x === "object");
if (opts) {
routes.set(urlPath + "|" + method, opts);
routes.set(urlPath + "|" + method, opts); // @ts-ignore
opts.file = sourceFile;
// console.log(method, urlPath, opts);
} else {
console.log(`${sourceFile}\nrouter.${method}("${path}") is missing the "route()" description middleware\n`, args);