UNPKG

2.58 kBTypeScriptView Raw
1import { Router } from "express";
2import Redis from "ioredis";
3import LRUCache from "lru-cache";
4import { Webhooks } from "@octokit/webhooks";
5import { Logger } from "pino";
6import { Context } from "./context";
7import { ProbotOctokit } from "./octokit/probot-octokit";
8import { DeprecatedLogger, ProbotWebhooks, ApplicationFunction } from "./types";
9export interface Options {
10 privateKey?: string;
11 githubToken?: string;
12 id?: number;
13 Octokit?: typeof ProbotOctokit;
14 log?: Logger;
15 redisConfig?: Redis.RedisOptions;
16 secret?: string;
17 webhookPath?: string;
18 cache?: LRUCache<number, string>;
19 octokit?: InstanceType<typeof ProbotOctokit>;
20 webhooks?: Webhooks;
21 /**
22 * @deprecated "app.router" is deprecated, use "getRouter()" from the app function instead: "({ app, getRouter }) => { ... }"
23 */
24 router?: Router;
25 /**
26 * @deprecated set `Octokit` to `ProbotOctokit.defaults({ throttle })` instead
27 */
28 throttleOptions?: any;
29}
30export declare type OnCallback<T> = (context: Context<T>) => Promise<void>;
31/**
32 * The `app` parameter available to `ApplicationFunction`s
33 *
34 * @property {logger} log - A logger
35 */
36export declare class Application {
37 log: DeprecatedLogger;
38 on: ProbotWebhooks["on"];
39 receive: ProbotWebhooks["receive"];
40 load: (appFn: ApplicationFunction | ApplicationFunction[]) => Application;
41 auth: (installationId?: number, log?: Logger) => Promise<InstanceType<typeof ProbotOctokit>>;
42 private webhooks;
43 private state;
44 private internalRouter;
45 constructor(options: Options);
46 /**
47 * @deprecated "app.router" is deprecated, use "getRouter()" from the app function instead: "({ app, getRouter }) => { ... }"
48 */
49 get router(): Router;
50 /**
51 * Get an {@link http://expressjs.com|express} router that can be used to
52 * expose HTTP endpoints
53 *
54 * ```
55 * module.exports = ({ app, getRouter }) => {
56 * // Get an express router to expose new HTTP endpoints
57 * const router = getRouter('/my-app');
58 *
59 * // Use any middleware
60 * router.use(require('express').static(__dirname + '/public'));
61 *
62 * // Add a new route
63 * router.get('/hello-world', (req, res) => {
64 * res.end('Hello World');
65 * });
66 * };
67 * ```
68 *
69 * @param path - the prefix for the routes* @param path
70 *
71 * @deprecated "app.route()" is deprecated, use the "getRouter()" argument from the app function instead: "({ app, getRouter }) => { ... }"
72 */
73 route(path?: string): Router;
74}