kwyjibo
Advanced tools
Comparing version 1.0.28 to 1.0.29
@@ -0,1 +1,2 @@ | ||
/// <reference types="express" /> | ||
/// <reference types="node" /> | ||
@@ -28,2 +29,3 @@ /********************************************************************************* | ||
import * as Express from "express"; | ||
import * as U from "./utils"; | ||
import * as Stream from "stream"; | ||
@@ -227,1 +229,2 @@ export interface IDisposable { | ||
export declare function getActionRoute<T>(controller: KwyjiboControllerConstructor<T>, methodName: string, httpMethod?: string): string; | ||
export declare function getRoutes(replacements?: U.Dictionary<string>): any; |
@@ -27,8 +27,16 @@ /********************************************************************************* | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments)).next()); | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
@@ -38,2 +46,3 @@ }; | ||
const U = require("./utils"); | ||
const D = require("./documentation"); | ||
const T = require("./testing"); | ||
@@ -692,2 +701,31 @@ const FS = require("fs"); | ||
exports.getActionRoute = getActionRoute; | ||
function controllerDocToRoutes(controllers, baseUrl, replacements) { | ||
if (baseUrl == undefined) { | ||
baseUrl = ""; | ||
} | ||
if (replacements == undefined) { | ||
replacements = {}; | ||
} | ||
let routes = {}; | ||
for (let controller of controllers) { | ||
routes[controller.name] = {}; | ||
for (let method of controller.methods) { | ||
routes[controller.name][method.name] = {}; | ||
for (let mountPoint of method.mountpoints) { | ||
let url = baseUrl + controller.path + mountPoint.path; | ||
for (let key in replacements) { | ||
url = url.replace(new RegExp(key, "g"), replacements[key]); | ||
} | ||
routes[controller.name][method.name][mountPoint.httpMethod] = url; | ||
} | ||
} | ||
let childRoutes = controllerDocToRoutes(controller.childs, controller.path); | ||
routes = __assign({}, routes, childRoutes); | ||
} | ||
return routes; | ||
} | ||
function getRoutes(replacements) { | ||
return controllerDocToRoutes(D.getDocs(), undefined, replacements); | ||
} | ||
exports.getRoutes = getRoutes; | ||
//# sourceMappingURL=controller.js.map |
@@ -30,5 +30,5 @@ /********************************************************************************* | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments)).next()); | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
@@ -35,0 +35,0 @@ }; |
@@ -35,2 +35,3 @@ /// <reference types="express-serve-static-core" /> | ||
$render_view: string; | ||
[key: string]: any; | ||
} | ||
@@ -41,1 +42,4 @@ export declare function addErrorHandler(eh: ExpressErrorRequestHandler): void; | ||
export declare function setDefaultInfoLogger(logger: (toLog: any) => void): void; | ||
export interface Dictionary<T> { | ||
[key: string]: T; | ||
} |
{ | ||
"name": "kwyjibo", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "A set of Typescript Decorators and helpers to write better node.js+Express applications.", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
125466
18
1895