Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript types for judoscale-express #21

Open
pedro-mass opened this issue Dec 1, 2023 · 3 comments
Open

Typescript types for judoscale-express #21

pedro-mass opened this issue Dec 1, 2023 · 3 comments

Comments

@pedro-mass
Copy link

Is there a timeline for types to be provided for judoscale-express?

Getting this error:

Could not find a declaration file for module 'judoscale-express'. 
'node_modules/judoscale-express/dist/index.js' implicitly has an 'any' type.

  Try `npm i --save-dev @types/judoscale-express` if it exists or add a new declaration (.d.ts) file containing `declare module 'judoscale-express';`
@adamlogic
Copy link
Contributor

Not right now. I'd gladly take a PR for it, but we don't have the TypeScript knowledge in house.

@pedro-mass
Copy link
Author

pedro-mass commented Dec 1, 2023

I temporarily added this for my local, but it could be improved:

// src: https://github.com/judoscale/judoscale-node/tree/main/express
declare module "judoscale-express" {
  import { RequestHandler } from "express";

  function initialize({
    report_interval_seconds = 10,
  }: {
    // Specify how frequently data is sent to Judoscale.
    // Default: 10
    report_interval_seconds?: number;

    // Specify the API endpoint.
    // Default: process.env.JUDOSCALE_URL
    api_base_url?: string;

    // Use a custom logger instance
    // Default: Winston logger instance (simple format)
    logger?: any; // todo: make this type better

    // Override the log level of the default logger (ignored if logger is overridden)
    // Default: process.env.JUDOSCALE_LOG_LEVEL || 'info'
    log_level?: string; // todo: make this type better
  }): RequestHandler;

  export = initialize;
}

@adamlogic
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants