Skip to content

Commit

Permalink
Fix #3 emergently
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongho Nam committed Feb 15, 2021
1 parent 3f033ed commit e76e625
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 8 deletions.
1 change: 1 addition & 0 deletions api/functional/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * as performance from "./performance";
export * as consumers from "./consumers";
export * as sellers from "./sellers";

32 changes: 32 additions & 0 deletions api/functional/performance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { AesPkcs5 } from "./../../__internal/AesPkcs5";
import { Fetcher } from "./../../__internal/Fetcher";
import type { IConnection } from "./../../IConnection";
import type { Primitive } from "./../../Primitive";

import type { IPerformance } from "./../../structures/performance/IMemoryUsage";


// GET performance/
// PerformanceController.get()
export function get(connection: IConnection, ): Promise<get.Output>
{
return Fetcher.fetch
(
connection,
{"input_encrypted":false,"output_encrypted":true},
"GET",
`performance/`
);
}
export namespace get
{
export type Output = Primitive<IPerformance>;
}



//---------------------------------------------------------
// TO PREVENT THE UNUSED VARIABLE ERROR
//---------------------------------------------------------
AesPkcs5;
Fetcher;
5 changes: 5 additions & 0 deletions api/structures/performance/IMemoryUsage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IPerformance
{
cpu: NodeJS.CpuUsage;
memory: NodeJS.MemoryUsage;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nestia",
"version": "0.1.1",
"version": "0.1.2",
"description": "Automatic SDK and Document generator for the NestJS",
"main": "src/index.ts",
"bin": {
Expand Down
17 changes: 11 additions & 6 deletions src/analyses/ReflectAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ export namespace ReflectAnalyzer
};

// PARSE CHILDREN DATA
const nestParameters: NestParameters = Reflect.getMetadata("__routeArguments__", classProto.constructor, name);
for (const tuple of Object.entries(nestParameters))
const nestParameters: NestParameters | undefined = Reflect.getMetadata("__routeArguments__", classProto.constructor, name);
if (nestParameters === undefined)
meta.parameters = [];
else
{
const child: IController.IParameter | null = _Analyze_parameter(...tuple);
if (child !== null)
meta.parameters.push(child);
for (const tuple of Object.entries(nestParameters))
{
const child: IController.IParameter | null = _Analyze_parameter(...tuple);
if (child !== null)
meta.parameters.push(child);
}
meta.parameters = meta.parameters.sort((x, y) => x.index - y.index);
}
meta.parameters = meta.parameters.sort((x, y) => x.index - y.index);

// VALIDATE PATH ARGUMENTS
const funcPathArguments: string[] = StringUtil.betweens(path.join(controller.path, meta.path).split("\\").join("/"), ":", "/").sort();
Expand Down
1 change: 0 additions & 1 deletion src/bin/nestia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface ICommand

async function sdk(inputList: string[], command: ICommand): Promise<void>
{

// VALIDATE OUTPUT
if (command.out === null)
throw new Error(`Output directory is not specified. Add the "--out <output_directory>" option.`);
Expand Down
16 changes: 16 additions & 0 deletions src/test/controllers/PerformanceController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as nest from "@nestjs/common";
import * as helper from "encrypted-nestjs";
import { IPerformance } from "../../../api/structures/performance/IMemoryUsage";

@nest.Controller("performance")
export class PerformanceController
{
@helper.EncryptedRoute.Get()
public get(): IPerformance
{
return {
cpu: process.cpuUsage(),
memory: process.memoryUsage()
};
}
}

0 comments on commit e76e625

Please sign in to comment.