Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI for restaurant

on:
pull_request:
branches: [main]
branches: [main, development]

jobs:
build:
Expand All @@ -13,10 +13,11 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: "16"
node-version: "20"
- name: ci for app
working-directory: ./
run: |
npm i
npm run build
npm run format
npm run test:unit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.env
dist
coverage
coverage
.codebuddy
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@
"start:dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/index.js\"",
"format": "prettier --write \"src/**/*.ts\""
},
"keywords": [],
"keywords": [
"typescript",
"code-extractor",
"rag",
"code-analysis",
"embeddings",
"advanced-code-analysis",
"code-retrieval",
"code-generation",
"codebase",
"code-analyzer",
"code-embeddings",
"code-toolbox",
"code-tool",
"code-extraction",
"code-toolkit",
"code-tooling",
"code-utility",
"code-utilities",
"code-utility-tool",
"code-utility-toolkit"
],
"author": "Oyinlola Olasunkanmi Raymond",
"license": "ISC",
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions src/http/http-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("HttpClient", () => {
method: "GET",
path: "/test",
}),
expect.any(Function)
expect.any(Function),
);
expect(result).toEqual(mockData);
});
Expand All @@ -69,7 +69,7 @@ describe("HttpClient", () => {
method: "POST",
path: "/test",
}),
expect.any(Function)
expect.any(Function),
);
expect(result).toEqual(mockData);
});
Expand All @@ -90,7 +90,7 @@ describe("HttpClient", () => {
method: "PUT",
path: "/test",
}),
expect.any(Function)
expect.any(Function),
);
expect(result).toEqual({ statusCode: 200 });
});
Expand All @@ -110,7 +110,7 @@ describe("HttpClient", () => {
method: "DELETE",
path: "/test",
}),
expect.any(Function)
expect.any(Function),
);
expect(result).toEqual({ statusCode: 200 });
});
Expand All @@ -124,7 +124,7 @@ describe("HttpClient", () => {
});

await expect(httpClient.get({}, { path: "/test" })).rejects.toThrow(
"Request failed with status code 500"
"Request failed with status code 500",
);
});

Expand All @@ -135,7 +135,7 @@ describe("HttpClient", () => {
});

await expect(httpClient.get({}, { path: "/test" })).rejects.toThrow(
"Failed to parse response data"
"Failed to parse response data",
);
});
});
Expand Down
26 changes: 13 additions & 13 deletions src/http/http-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class HttpClient implements IHttpClient {
**/
async post<TRequest, TResponse>(
payload: TRequest,
options?: https.RequestOptions
options?: https.RequestOptions,
): Promise<TResponse> {
return this.sendRequest<TResponse>("POST", options, payload);
}
Expand All @@ -44,7 +44,7 @@ export class HttpClient implements IHttpClient {
**/
async put<TRequest, TResponse>(
payload: TRequest,
options?: https.RequestOptions
options?: https.RequestOptions,
): Promise<TResponse> {
return this.sendRequest<TResponse>("PUT", options, payload);
}
Expand All @@ -69,7 +69,7 @@ export class HttpClient implements IHttpClient {
method: string,
options?: any,
payload?: any,
jwtToken?: string
jwtToken?: string,
): Promise<T> {
const defaultHeader = this.generateRequestHeader(jwtToken);
options.header = { ...options.header, ...defaultHeader };
Expand Down Expand Up @@ -102,20 +102,20 @@ export class HttpClient implements IHttpClient {
} catch (error: any) {
console.log(error);
reject(
new Error(`Failed to parse response data: ${error.message}`)
new Error(`Failed to parse response data: ${error.message}`),
);
throw error;
}
} else {
reject(
new Error(`Request failed with status code ${res.statusCode}`)
new Error(`Request failed with status code ${res.statusCode}`),
);
}
} catch (error: any) {
this.logger.error(
"An error occurred during the API request.",
JSON.stringify(error),
error
error,
);
throw error;
}
Expand All @@ -125,7 +125,7 @@ export class HttpClient implements IHttpClient {
this.logger.error(
"An error occurred during the API request.",
JSON.stringify(error),
error
error,
);
reject(error);
throw error;
Expand Down Expand Up @@ -153,7 +153,7 @@ export class HttpClient implements IHttpClient {
method: string,
path: string,
baseUrl: string,
jwtToken?: string
jwtToken?: string,
): IRequestOptions {
const headers = this.generateRequestHeader(jwtToken);
const options: IRequestOptions = {
Expand All @@ -178,26 +178,26 @@ export class HttpClient implements IHttpClient {
path: string,
baseUrl: string,
data: any,
jwtToken?: string
jwtToken?: string,
): Promise<T | undefined> {
try {
const requestOptions: IRequestOptions = this.generateRequestOptions(
method,
path,
baseUrl,
jwtToken
jwtToken,
);
let response: T | undefined;
switch (method) {
case HTTP_VERBS.GET:
response = await this.get(
Buffer.from(JSON.stringify({})),
requestOptions
requestOptions,
);
case HTTP_VERBS.POST:
response = await this.post(
Buffer.from(JSON.stringify(data)),
requestOptions
requestOptions,
);
break;
default:
Expand All @@ -211,7 +211,7 @@ export class HttpClient implements IHttpClient {
this.logger.error(
"An error occurred during the API request.",
JSON.stringify(error),
error
error,
);
throw error;
}
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/generic.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IFunctionInfo {
returnType?: string;
comments?: string;
summary?: string;
kind?: string;
}

export interface IClassInfo {
Expand Down Expand Up @@ -55,6 +56,7 @@ export interface IModuleInfo {
enums?: IEnumInfo[];
dependencies: string[];
properties?: IProperty[];
errors?: string[];
}

export interface ICodebaseMap {
Expand Down
16 changes: 8 additions & 8 deletions src/interfaces/ts.code.mapper.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ITypeScriptCodeMapper {
*/
extractClassMetaData(
node: ts.ClassDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IClassInfo>;

/**
Expand All @@ -32,7 +32,7 @@ export interface ITypeScriptCodeMapper {
*/
extractPropertyParameters(
node: ts.PropertyDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IProperty>;

/**
Expand All @@ -44,7 +44,7 @@ export interface ITypeScriptCodeMapper {
*/
extractFunctionParameters(
node: ts.FunctionDeclaration | ts.MethodDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IProperty[]>;

/**
Expand All @@ -56,7 +56,7 @@ export interface ITypeScriptCodeMapper {
*/
getFunctionDetails(
node: ts.FunctionDeclaration | ts.MethodDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IFunctionInfo> | null;

/**
Expand All @@ -71,7 +71,7 @@ export interface ITypeScriptCodeMapper {
| ts.MethodDeclaration
| ts.ParameterDeclaration
| ts.PropertyDeclaration
| ts.PropertySignature
| ts.PropertySignature,
): Result<string | undefined>;

/**
Expand All @@ -93,7 +93,7 @@ export interface ITypeScriptCodeMapper {
*/
getFunctionNodeText(
node: ts.FunctionDeclaration | ts.MethodDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): string;

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ export interface ITypeScriptCodeMapper {
*/
extractInterfaceInfo(
node: ts.InterfaceDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IInterfaceInfo>;

/**
Expand All @@ -138,7 +138,7 @@ export interface ITypeScriptCodeMapper {
*/
extractEnumInfo(
node: ts.EnumDeclaration,
sourceFile: ts.SourceFile
sourceFile: ts.SourceFile,
): Result<IEnumInfo>;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/logger/logger-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createLogger, transports, format, Logger } from "winston";
import { IContextAwareLogger } from "./logger-service.interface";

export class ApplicationLogger implements IContextAwareLogger {
private logger: Logger;
private readonly logger: Logger;

constructor() {
this.logger = createLogger({
Expand Down Expand Up @@ -31,11 +31,11 @@ export class ApplicationLogger implements IContextAwareLogger {
}

error(context: any, message: string, error: Error): void {
this.logger.error(message, {
this.logger.error(JSON.stringify(error), {
context,
error: {
name: error.name,
message: error.message,
message: JSON.stringify(error),
stack: error.stack,
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/result/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Result<T> {
isSuccess: boolean,
data?: any,
message?: string,
errorCode?: number
errorCode?: number,
) {
this.data = data;
this.isSuccess = isSuccess;
Expand Down
Loading