node-boot-core
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -107,4 +107,14 @@ "use strict"; | ||
exports.getRouter = getRouter; | ||
function content(path) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, fs.readFileSync(path, 'utf8')]; | ||
case 1: return [2, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
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, controllerMetadata, componentMetadata, serviceMetadata, repositoryMetadata; | ||
var controllerInstances, _i, allFiles_1, item, text, fileData, _a, _b, name_1, controller, controllerMetadata, componentMetadata, serviceMetadata, repositoryMetadata; | ||
return tslib_1.__generator(this, function (_c) { | ||
@@ -117,8 +127,12 @@ switch (_c.label) { | ||
case 1: | ||
if (!(_i < allFiles_1.length)) return [3, 4]; | ||
if (!(_i < allFiles_1.length)) return [3, 5]; | ||
item = allFiles_1[_i]; | ||
if (!(item.indexOf(".ts") != -1 || item.indexOf(".js") != -1)) return [3, 3]; | ||
if (!(item.indexOf(".js.map") == -1)) return [3, 3]; | ||
if (!(item.indexOf(".ts") != -1 || item.indexOf(".js") != -1)) return [3, 4]; | ||
if (!(item.indexOf(".js.map") == -1)) return [3, 4]; | ||
return [4, content(item)]; | ||
case 2: | ||
text = _c.sent(); | ||
if (!(text.indexOf("@Controller") != -1 || text.indexOf("@Repository") != -1 || text.indexOf("@Service") != -1 || text.indexOf("@Component") != -1)) return [3, 4]; | ||
return [4, Promise.resolve("".concat(item)).then(function (s) { return require(s); })]; | ||
case 2: | ||
case 3: | ||
fileData = _c.sent(); | ||
@@ -159,7 +173,7 @@ for (_a = 0, _b = Object.keys(fileData); _a < _b.length; _a++) { | ||
} | ||
_c.label = 3; | ||
case 3: | ||
_c.label = 4; | ||
case 4: | ||
_i++; | ||
return [3, 1]; | ||
case 4: return [2, controllerInstances]; | ||
case 5: return [2, controllerInstances]; | ||
} | ||
@@ -166,0 +180,0 @@ }); |
@@ -129,45 +129,51 @@ import { | ||
}; | ||
async function content(path: any) { | ||
return await fs.readFileSync(path, 'utf8'); | ||
} | ||
export const readFiles = async (allFiles: any[]) => { | ||
const controllerInstances:any = []; | ||
const controllerInstances: any = []; | ||
for (const item of allFiles) { | ||
if (item.indexOf(".ts") != -1 || item.indexOf(".js") != -1) { | ||
if (item.indexOf(".js.map") == -1) { | ||
const fileData = await import(item); | ||
for (const name of Object.keys(fileData)) { | ||
const controller = (fileData as any)[name]; | ||
if (typeof controller === "function") { | ||
const controllerMetadata: IClassMetadata | undefined = | ||
Reflect.getOwnMetadata(classMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (controllerMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
const text = await content(item); | ||
if (text.indexOf("@Controller") != -1 || text.indexOf("@Repository") != -1 || text.indexOf("@Service") != -1 || text.indexOf("@Component") != -1) { | ||
const fileData = await import(item); | ||
for (const name of Object.keys(fileData)) { | ||
const controller = (fileData as any)[name]; | ||
if (typeof controller === "function") { | ||
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 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 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(), | ||
}); | ||
const repositoryMetadata: IRepositoryMetadata | undefined = | ||
Reflect.getOwnMetadata(repositoryMetadataKey, Object.getPrototypeOf(new controller())); | ||
if (repositoryMetadata) { | ||
controllerInstances.push({ | ||
name: name, | ||
controller: new controller(), | ||
}); | ||
} | ||
} | ||
@@ -181,9 +187,9 @@ } | ||
}; | ||
export const readProperties = ()=> { | ||
export const readProperties = () => { | ||
const fileName = `${process.cwd()}/application.properties`; | ||
if (fs.existsSync(fileName)) { | ||
return PropertiesReader( | ||
fileName, | ||
"utf-8" | ||
).getAllProperties(); | ||
return PropertiesReader( | ||
fileName, | ||
"utf-8" | ||
).getAllProperties(); | ||
} | ||
@@ -190,0 +196,0 @@ } |
{ | ||
"name": "node-boot-core", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158846
2866