summary refs log tree commit diff
path: root/api/jest/getRouteDescriptions.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 11:56:06 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 11:56:06 +0200
commitaae7e8d7770f6d5f7d46c2263880c6c4e7ef6788 (patch)
treed1625d8ddd80fef1499d6beab4e26566cf8ee55d /api/jest/getRouteDescriptions.ts
parent:sparkles: jest automatic tests (diff)
downloadserver-aae7e8d7770f6d5f7d46c2263880c6c4e7ef6788.tar.xz
:sparkles: route middleware test option
Diffstat (limited to 'api/jest/getRouteDescriptions.ts')
-rw-r--r--api/jest/getRouteDescriptions.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/api/jest/getRouteDescriptions.ts b/api/jest/getRouteDescriptions.ts

index d7d6e0c6..33922899 100644 --- a/api/jest/getRouteDescriptions.ts +++ b/api/jest/getRouteDescriptions.ts
@@ -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);