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 .d.ts and a couple of questions #8

Open
formula1 opened this issue Feb 2, 2022 · 1 comment
Open

TypeScript .d.ts and a couple of questions #8

formula1 opened this issue Feb 2, 2022 · 1 comment

Comments

@formula1
Copy link

formula1 commented Feb 2, 2022

This is related to another issue therootcompany/greenlock.js#4

I have a few questions

  import {
    IncomingMessage, ServerResponse,
    Server as HttpServer
  } from "http";
  import {
    Server as HttpsServer,
    ServerOptions as HttpsServerOptions
  } from "https";
  import {
    Http2SecureServer,
    SecureServerOptions as Http2SecureServerOptions
  } from "http2";

  import Greenlock from "@root/greenlock";

  type ReqHandler = (req: IncomingMessage, res: ServerResponse)=>any;
  type ReqHandlerNext = (
    req: IncomingMessage, res: ServerResponse,
    next: (e?: any)=>any
  )=>any;

  /*
    Note: You can't use both https and http2s at the same time

  */

  interface Servers {
    httpServer(onReq?: ReqHandlerNext): HttpServer
    http2Server(
      secureOps: Http2SecureServerOptions, onReq?: ReqHandler
    ): Http2SecureServer
    httpsServer(
      secureOps: HttpsServerOptions, onReq?: ReqHandler
    ): HttpsServer
    serveApp(onReq: ReqHandler): Promise<void>
    id(): string | number
  }

  interface Master {
    ready(cb: (servers: Servers)=>any): Master;
    master(): Master;
    serve(onReq: ReqHandler): void;
  }


  type Options = {
    packageRoot: string,
    maintainerEmail: string,
    configDir: string
    cluster?: boolean

    greenlock?: Greenlock
    packageAgent?: string
    notify?: (ev: string, params: any)=>any
  };

  export function init(opts: Options | (()=>Options)): Master

}
@mmanishh
Copy link

mmanishh commented Jul 5, 2022

Hi Can you provide type file for greenlock-express or include it in npm or yarn , IT would be great .

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