moesif-nodejs icon indicating copy to clipboard operation
moesif-nodejs copied to clipboard

Provide concise TypeScript interfaces describing middleware options

Open igrek8 opened this issue 1 year ago • 5 comments

At the moment, the typescript definitions do not help integrating your library. Options to middleware have everything as any which prevents anybody from discovering the library and integrating with it. It would be great if you can provide more consice typescript interfaces that describe your API.

image

igrek8 avatar Jun 19 '23 12:06 igrek8

please upgrade to 3.3.5. it is updated now.

xinghengwang avatar Jun 21 '23 01:06 xinghengwang

Thank you for looking into the issue. However, the types are still too wide and do not bring any value. Can you please specify more concrete types so that instead of object there will be types express.Request, express.Response etc. At the moment, jsdoc does not offer same type definitions as typescript would have offered. Perhaps, consider bringing in typescript.

In addition eventModel: object does not tell what kind of object is there. Please specify exact fields and types. We use this typing internally to resolve issues that I am reporting.

export interface MoesifReporterEvent {
  request: {
    time: string;
    uri: string;
    verb: string;
    headers: Record<string, string>;
    body?: unknown;
  };
  response?: {
    time: string;
    status: number;
    headers?: Record<string, string>;
    body?: unknown;
  };
  user_id?: string;
  company_id?: string;
  metadata?: unknown;
}

igrek8 avatar Jun 22 '23 07:06 igrek8

Understood. Yes. agree that ultimately rebuild this library from ground up in Typescript is probably the best solution. Current type declaration is basically tacked on to this javascript library using auto generated tools. It is on our roadmap to have an typescript version, but migration is a big undertake, it will take time, hope you understand.

xinghengwang avatar Jun 22 '23 20:06 xinghengwang

@xinghengwang any update?

ihadabs avatar Oct 02 '23 17:10 ihadabs

Sorry, at this stage, still only basic Typescript types. Rebuiding is big undertake at this time.

xinghengwang avatar Oct 18 '23 04:10 xinghengwang