node-boot-core
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -13,2 +13,3 @@ "use strict"; | ||
var dependency_manager_1 = require("./util/dependency-manager"); | ||
var error_util_1 = require("./util/error-util"); | ||
exports.EnableServer = (0, types_1.createClassDecorator)(function (constructor) { | ||
@@ -62,2 +63,3 @@ var CtorArgs = []; | ||
if (app) { | ||
app.use(error_util_1.errorHandler); | ||
var port_1 = (0, util_1.getPropertiesData)(properties, "server.port", 3000); | ||
@@ -64,0 +66,0 @@ app.listen(port_1, function () { |
@@ -25,2 +25,3 @@ import "reflect-metadata"; | ||
import dependencyManager from "./util/dependency-manager"; | ||
import { errorHandler } from "./util/error-util"; | ||
@@ -69,2 +70,3 @@ export const EnableServer = createClassDecorator( | ||
if (app) { | ||
app.use(errorHandler); | ||
const port = getPropertiesData(properties, "server.port", 3000); | ||
@@ -71,0 +73,0 @@ app.listen(port, () => { |
@@ -5,1 +5,5 @@ export * from "./enable-server"; | ||
export * from "./util/dependency-manager"; | ||
export * from "./util/type-util"; | ||
export * from "./util/date-util"; | ||
export * from "./util/json-util"; | ||
export * from "./util/response-util"; |
@@ -8,2 +8,6 @@ "use strict"; | ||
tslib_1.__exportStar(require("./util/dependency-manager"), exports); | ||
tslib_1.__exportStar(require("./util/type-util"), exports); | ||
tslib_1.__exportStar(require("./util/date-util"), exports); | ||
tslib_1.__exportStar(require("./util/json-util"), exports); | ||
tslib_1.__exportStar(require("./util/response-util"), exports); | ||
//# sourceMappingURL=index.js.map |
export * from "./enable-server"; | ||
export * from "./decorators"; | ||
export * from "./util/util"; | ||
export * from "./util/dependency-manager"; | ||
export * from "./util/dependency-manager"; | ||
export * from "./util/type-util"; | ||
export * from "./util/date-util"; | ||
export * from "./util/json-util"; | ||
export * from "./util/response-util"; |
import { RequestHandler } from "express"; | ||
import { Controller, ErrorMiddleware, IRouterAndPath, RouterLib } from "../decorators/types"; | ||
import PropertiesReader = require("properties-reader"); | ||
import * as PropertiesReader from "properties-reader"; | ||
export declare function listDirectories(root: any): any; | ||
@@ -14,1 +14,2 @@ export declare const dir: string; | ||
export declare const getPropertiesData: (properties: any, key: any, fix: any) => any; | ||
export declare const createRandomCode: (length?: number) => Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPropertiesData = exports.readProperties = exports.readFiles = exports.getRouter = exports.print = exports.wrapErrorMiddleware = exports.dir = exports.listDirectories = void 0; | ||
exports.createRandomCode = exports.getPropertiesData = exports.readProperties = exports.readFiles = exports.getRouter = exports.print = exports.wrapErrorMiddleware = exports.dir = exports.listDirectories = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -108,3 +108,3 @@ var fs = require("fs"); | ||
var readFiles = function (allFiles) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var controllerInstances, _i, allFiles_1, item, fileData, _a, _b, name_1, controller; | ||
var controllerInstances, _i, allFiles_1, item, fileData, _a, _b, name_1, controller, controllerMetadata, componentMetadata, serviceMetadata, repositoryMetadata; | ||
return tslib_1.__generator(this, function (_c) { | ||
@@ -128,6 +128,30 @@ switch (_c.label) { | ||
if (typeof controller === "function") { | ||
controllerInstances.push({ | ||
name: name_1, | ||
controller: new controller(), | ||
}); | ||
controllerMetadata = Reflect.getOwnMetadata(types_1.classMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (controllerMetadata) { | ||
controllerInstances.push({ | ||
name: name_1, | ||
controller: new controller(), | ||
}); | ||
} | ||
componentMetadata = Reflect.getOwnMetadata(types_1.componentMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (componentMetadata) { | ||
controllerInstances.push({ | ||
name: name_1, | ||
controller: new controller(), | ||
}); | ||
} | ||
serviceMetadata = Reflect.getOwnMetadata(types_1.serviceMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (serviceMetadata) { | ||
controllerInstances.push({ | ||
name: name_1, | ||
controller: new controller(), | ||
}); | ||
} | ||
repositoryMetadata = Reflect.getOwnMetadata(types_1.repositoryMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (repositoryMetadata) { | ||
controllerInstances.push({ | ||
name: name_1, | ||
controller: new controller(), | ||
}); | ||
} | ||
} | ||
@@ -157,2 +181,18 @@ } | ||
exports.getPropertiesData = getPropertiesData; | ||
var createRandomCode = function (length) { | ||
if (length === void 0) { length = 6; } | ||
return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var result, characters, charactersLength, i; | ||
return tslib_1.__generator(this, function (_a) { | ||
result = ""; | ||
characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
charactersLength = characters.length; | ||
for (i = 0; i < length; i++) { | ||
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
} | ||
return [2, result]; | ||
}); | ||
}); | ||
}; | ||
exports.createRandomCode = createRandomCode; | ||
//# sourceMappingURL=util.js.map |
@@ -11,5 +11,5 @@ import { | ||
import * as fs from "fs"; | ||
import { classMetadataKey, Controller, ErrorMiddleware, IClassMetadata, IHttpRoute, IMethodMetadata, IRouterAndPath, RouterLib } from "../decorators/types"; | ||
import { classMetadataKey, componentMetadataKey, Controller, ErrorMiddleware, IClassMetadata, IComponentMetadata, IHttpRoute, IMethodMetadata, IRepositoryMetadata, IRouterAndPath, IServiceMetadata, repositoryMetadataKey, RouterLib, serviceMetadataKey } from "../decorators/types"; | ||
import * as path from "path"; | ||
import PropertiesReader = require("properties-reader"); | ||
import * as PropertiesReader from "properties-reader"; | ||
export function listDirectories(root: any): any { | ||
@@ -139,6 +139,37 @@ return fs.readdirSync(root, { withFileTypes: true }).flatMap((file: any) => { | ||
if (typeof controller === "function") { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
const controllerMetadata: IClassMetadata | undefined = | ||
Reflect.getOwnMetadata(classMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (controllerMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
const componentMetadata: IComponentMetadata | undefined = | ||
Reflect.getOwnMetadata(componentMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (componentMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
const serviceMetadata: IServiceMetadata | undefined = | ||
Reflect.getOwnMetadata(serviceMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (serviceMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
const repositoryMetadata: IRepositoryMetadata | undefined = | ||
Reflect.getOwnMetadata(repositoryMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (repositoryMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
} | ||
@@ -164,2 +195,13 @@ } | ||
: fix; | ||
}; | ||
}; | ||
export const createRandomCode = async (length: number = 6) => { | ||
var result = ""; | ||
var characters = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
var charactersLength = characters.length; | ||
for (var i = 0; i < length; i++) { | ||
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
} | ||
return result; | ||
}; |
{ | ||
"name": "node-boot-core", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "", | ||
"main": "index.js", | ||
"typings": "index.d.ts", | ||
"keywords": ["node-boot-core", "node-boot-framework", "node-boot", "spring-boot"], | ||
"keywords": [ | ||
"node-boot-core", | ||
"node-boot-framework", | ||
"node-boot", | ||
"spring-boot" | ||
], | ||
"author": "Codequality Technologies", | ||
@@ -41,2 +46,3 @@ "license": "ISC", | ||
"express": "^4.18.2", | ||
"express-validator": "^6.15.0", | ||
"properties-reader": "^2.2.0", | ||
@@ -43,0 +49,0 @@ "reflect-metadata": "^0.1.13", |
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
157473
95
2846
5
+ Addedexpress-validator@^6.15.0
+ Addedexpress-validator@6.15.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedvalidator@13.12.0(transitive)