Socket
Socket
Sign inDemoInstall

kwyjibo

Package Overview
Dependencies
64
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

6

js/controller.d.ts

@@ -119,2 +119,3 @@ import * as Express from "express";

childController: boolean;
node: KwyjiboControllerTreeNode;
/**

@@ -134,2 +135,3 @@ * Set to true by the Controller decorator to assert that

childs: KwyjiboControllerTreeNode[];
fullPath: string;
constructor(controller: KwyjiboController);

@@ -152,2 +154,4 @@ }

}
export declare function addControllersToExpressApp(app: Express.Application, rootPath?: string): void;
export declare function addControllersToExpressApp(app: Express.Application, ...requiredDirectories: string[]): void;
export declare function addControllersToExpressAppAtRoute(rootPath: string, app: Express.Application, ...requiredDirectories: string[]): void;
export declare function getActionRoute<T>(controller: KwyjiboControllerConstructor<T>, methodName: string, httpMethod?: string): string;

@@ -13,2 +13,3 @@ "use strict";

const T = require("./testing");
const FS = require("fs");
/**

@@ -226,2 +227,3 @@ * Contains context for the current call .

this.childController = false;
this.node = undefined;
/**

@@ -249,2 +251,3 @@ * Set to true by the Controller decorator to assert that

this.controller = controller;
this.fullPath = controller.path;
}

@@ -278,2 +281,3 @@ }

function addChildsToTreeNode(node) {
node.controller.node = node;
for (let mp of exports.globalKCState.mountpoints) {

@@ -372,2 +376,3 @@ if (node.controller.ctr.toString() === mp.dstCtr.toString()) {

let controller = controllerNode.controller;
controllerNode.fullPath = controller.path;
if (controller.mountCondition === false) {

@@ -391,2 +396,3 @@ return undefined;

useRouterAtPathStrict(controller.router, nc.path, nc.router);
child.fullPath = U.UrlJoin(controllerNode.fullPath, "/", child.fullPath);
}

@@ -402,3 +408,24 @@ }

}
function addControllersToExpressApp(app, rootPath) {
function addControllersToExpressApp(app, ...requiredDirectories) {
addControllersToExpressAppAtRoute("/", app, ...requiredDirectories);
}
exports.addControllersToExpressApp = addControllersToExpressApp;
function addControllersToExpressAppAtRoute(rootPath, app, ...requiredDirectories) {
for (let requiredDirectory of requiredDirectories) {
let path = "";
if (requiredDirectory.charAt(0) == "/") {
path = requiredDirectory;
}
else {
path = U.UrlJoin(process.cwd(), "/", requiredDirectory);
}
try {
FS.accessSync(path);
}
catch (err) {
U.defaultWarn("Cannot access path: " + path);
continue;
}
require('require-all')(path);
}
rootPath = rootPath || "/";

@@ -410,2 +437,3 @@ buildControllersTree();

useRouterAtPathStrict(app, U.UrlJoin(rootPath, nc.path), nc.router);
node.fullPath = U.UrlJoin(rootPath, "/", node.fullPath);
}

@@ -417,3 +445,19 @@ }

}
exports.addControllersToExpressApp = addControllersToExpressApp;
exports.addControllersToExpressAppAtRoute = addControllersToExpressAppAtRoute;
function getActionRoute(controller, methodName, httpMethod) {
if (httpMethod == undefined) {
httpMethod = "get";
}
let kc = exports.globalKCState.getOrInsertController(controller);
if (kc.methods[methodName] != undefined) {
let method = kc.methods[methodName];
for (let mp of method.methodMountpoints) {
if (mp.httpMethod.toLowerCase() === httpMethod.toLowerCase()) {
return U.UrlJoin(kc.node.fullPath, "/", mp.path);
}
}
}
return "";
}
exports.getActionRoute = getActionRoute;
//# sourceMappingURL=controller.js.map
"use strict";
const controller_1 = require("./controller");
const U = require("./utils");
class MethodDoc {
}
exports.MethodDoc = MethodDoc;
class ControllerDocNode {
}
exports.ControllerDocNode = ControllerDocNode;
function getControllerDocNodeAndChilds(rootCdns, node) {
let cdn = new ControllerDocNode();
cdn.name = node.controller.ctr.name;
cdn.docString = node.controller.docString;
cdn.path = node.fullPath;
cdn.parent = undefined;
cdn.childs = [];
cdn.methods = [];
for (let methodKey in node.controller.methods) {
let m = new MethodDoc();
let method = node.controller.methods[methodKey];
m.name = methodKey;
m.docString = method.docString;
m.mountpoints = method.methodMountpoints;
cdn.methods.push(m);
}
for (let child of node.childs) {
let childCdn = getControllerDocNodeAndChilds(rootCdns, child);
childCdn.parent = cdn;
cdn.childs.push(childCdn);
}
rootCdns.push(cdn);
return cdn;
}
function getDocs() {
let cdns = [];
for (let node of controller_1.globalKCState.controllersTree) {
getControllerDocNodeAndChilds(cdns, node);
}
return cdns;
}
exports.getDocs = getDocs;
function crlfToBr(str) {
return str.replace(/\n|\r/g, "<br />");
}
function getControllerId(cdns, cdn) {
for (let idx in cdns) {
if (cdns[idx] == cdn) {
return "ci_" + idx;
}
}
return "";
}
const defaultCSS = `
/**
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
* http://www.cssportal.com
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.wrapper{
width: 100%;
min-width: 1000px;
max-width: 2000px;
margin: 0 auto;
}
.left{
background: #91AA9D;
width: 250px;
padding:8px;
position:fixed;
top: 0;
left:0;
}
.left h1{
font-weight: bold;
font-size: 20px;
text-decoration: underline;
margin-bottom:5px;
}
.rightFluid{
float: left;
width: 100%;
}
.right{
background: #FFFFFF;
margin-left: 270px;
}
.controller{
background: #91AA9D;
border-radius: 25px;
margin-top:3px;
margin-bottom:3px;
padding: 10px;
padding-top: 15px;
padding-bottom: 15px;
}
.controller h1{
font-weight: bold;
font-size: 24px;
text-decoration: underline;
margin-bottom:5px;
}
.controller h2{
font-weight: bold;
font-size: 18px;
margin-bottom:5px;
}
.controller h3{
font-size: 16px;
margin-bottom:5px;
}
.controller a{
text-decoration: underline;
}
.method {
background: #AFB2B2;
border-radius: 25px;
margin-top:3px;
margin-bottom:3px;
padding: 10px;
padding-top: 15px;
padding-bottom: 15px;
}
.method h1{
font-weight: bold;
font-size: 20px;
text-decoration: underline;
margin-bottom:8px;
}
.method h2{
font-weight: bold;
font-size: 15px;
margin-bottom:10px;
}
.method p{
background: #DDDDDD;
}
a {
text-decoration: none;
color:0;
}
ul {
font-size: 18px;
list-style-type: square;
}
p {
padding: 10px;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
color:#333
}
`;
function getDocsAsHTML() {
let content = `
<html>
<head>
<style>
${defaultCSS}
</style>
</head>
<body><div class="wrapper">
`;
let cdns = getDocs();
content += `<div class="rightFluid"><div class="right">`;
for (let cdn of cdns) {
content += `<div id="${getControllerId(cdns, cdn)}" class="controller">
<div>
<h1>${cdn.name}</h1>
<h2>Path: ${cdn.path}</h2>
`;
if (cdn.parent != undefined) {
content += `<div>
<h3>Parent: <a href="#${getControllerId(cdns, cdn.parent)}">${cdn.parent.name}</a></h3>
</div>`;
}
if (cdn.childs.length > 0) {
content += `<div><h3>Childs: `;
let childLinks = [];
for (let child of cdn.childs) {
childLinks.push(`<a href="#${getControllerId(cdns, child)}">${child.name}</a>`);
}
content += `${childLinks.join(", ")}</h3></div>`;
}
content += `<p>${crlfToBr(cdn.docString)}</p>
</div>
`;
if (cdn.methods.length > 0) {
content += `<div>`;
for (let method of cdn.methods) {
content += `<div class="method"><h1>${method.name}</h1>`;
for (let mp of method.mountpoints) {
content += `<h2> ${mp.httpMethod.toUpperCase()} : ${U.UrlJoin(cdn.path, "/", mp.path)} </h2>`;
}
content += `<p>${crlfToBr(method.docString)}</p></div>`;
}
content += `</div>`;
}
content += `</div>`;
}
content += `</div></div>`;
// Sidebar
content += `<div class="left"><ul>`;
for (let cdn of cdns) {
content += `<li><a href="#${getControllerId(cdns, cdn)}">${cdn.name}</a></li>`;
}
content += `</div>`;
content += `<ul></div></body></html>`;
return content;
}
exports.getDocsAsHTML = getDocsAsHTML;
//# sourceMappingURL=documentation.js.map
export * from "./controller";
export * from "./testing";
export * from "./utils";
export * from "./documentation";

@@ -8,2 +8,3 @@ "use strict";

__export(require("./utils"));
__export(require("./documentation"));
//# sourceMappingURL=index.js.map

6

js/utils.d.ts
export declare function UrlJoin(...parts: string[]): string;
export declare let defaultError: (str: string) => void;
export declare let defaultWarn: (str: string) => void;
export declare let defaultLog: (str: string) => void;
export declare let defaultError: (toLog: any) => void;
export declare let defaultWarn: (toLog: any) => void;
export declare let defaultLog: (toLog: any) => void;

@@ -15,5 +15,5 @@ "use strict";

exports.UrlJoin = UrlJoin;
exports.defaultError = (str) => { console.error(str); };
exports.defaultWarn = (str) => { console.warn(str); };
exports.defaultLog = (str) => { console.log(str); };
exports.defaultError = (toLog) => { console.error(toLog.toString()); };
exports.defaultWarn = (toLog) => { console.warn(toLog.toString()); };
exports.defaultLog = (toLog) => { console.log(toLog.toString()); };
//# sourceMappingURL=utils.js.map
{
"name": "kwyjibo",
"version": "1.0.4",
"version": "1.0.5",
"description": "A set of Typescript Decorators and helpers to write better node.js+Express applications.",

@@ -37,4 +37,5 @@ "main": "js/index.js",

"dependencies": {
"express": "^4.14.0"
"express": "^4.14.0",
"require-all": "^2.0.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc