Skip to content

Commit

Permalink
Feat: extend Rootle class with InterceptorRequestSources
Browse files Browse the repository at this point in the history
  • Loading branch information
mhd999 committed Aug 26, 2022
1 parent d27b22a commit c1adb14
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
example/main.js
main.js
main.js.map
main.js.map
example/node_modules
mock/server/node_modules/
2 changes: 1 addition & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rootle",
"version": "0.3.0",
"version": "0.4.0",
"description": "TS implementation of Rootle structured log",
"main": "dist/rootle.js",
"types": "./dist/rootle.d.ts",
Expand Down
25 changes: 23 additions & 2 deletions typescript/src/rootle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,27 @@ declare interface Logger {
(logJson: string): void;
}

declare interface InterceptorRequestSources {
useragent?: string;
referer?: string;
}

let localId: string;
let localApplication: string;
let localInterceptorRequestSources: InterceptorRequestSources | undefined;

export default class Rootle {
private id: string;
private application: string;
private interceptorRequestSources? : InterceptorRequestSources;

constructor(id: string, application: string) {
constructor(id: string, application: string, interceptorRequestSources?: InterceptorRequestSources) {
this.id = id;
this.application = application;
this.interceptorRequestSources = interceptorRequestSources;
localId = id;
localApplication = application;
localInterceptorRequestSources = interceptorRequestSources;
}

// @ts-ignore
Expand Down Expand Up @@ -166,4 +180,11 @@ export default class Rootle {
});
}

}
public getInterceptorRequestSources() {
return this.interceptorRequestSources
}
}

export const GetRootle = (): Rootle => {
return new Rootle(localId, localApplication, localInterceptorRequestSources);
}

0 comments on commit c1adb14

Please sign in to comment.