1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.createProbot = void 0;
|
4 | const get_private_key_1 = require("@probot/get-private-key");
|
5 | const get_log_1 = require("./helpers/get-log");
|
6 | const probot_1 = require("./probot");
|
7 | const DEFAULTS = {
|
8 | APP_ID: "",
|
9 | WEBHOOK_SECRET: "",
|
10 | GHE_HOST: "",
|
11 | GHE_PROTOCOL: "",
|
12 | LOG_FORMAT: "",
|
13 | LOG_LEVEL: "warn",
|
14 | LOG_LEVEL_IN_STRING: "",
|
15 | LOG_MESSAGE_KEY: "msg",
|
16 | REDIS_URL: "",
|
17 | SENTRY_DSN: "",
|
18 | };
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | function createProbot({ overrides = {}, defaults = {}, env = process.env, } = {}) {
|
29 | const privateKey = get_private_key_1.getPrivateKey({ env });
|
30 | const envWithDefaults = { ...DEFAULTS, ...env };
|
31 | const envOptions = {
|
32 | logLevel: envWithDefaults.LOG_LEVEL,
|
33 | appId: Number(envWithDefaults.APP_ID),
|
34 | privateKey: (privateKey && privateKey.toString()) || undefined,
|
35 | secret: envWithDefaults.WEBHOOK_SECRET,
|
36 | redisConfig: envWithDefaults.REDIS_URL,
|
37 | baseUrl: envWithDefaults.GHE_HOST
|
38 | ? `${envWithDefaults.GHE_PROTOCOL || "https"}://${envWithDefaults.GHE_HOST}/api/v3`
|
39 | : "https://api.github.com",
|
40 | };
|
41 | const probotOptions = {
|
42 | ...defaults,
|
43 | ...envOptions,
|
44 | ...overrides,
|
45 | };
|
46 | const logOptions = {
|
47 | level: probotOptions.logLevel,
|
48 | logFormat: envWithDefaults.LOG_FORMAT,
|
49 | logLevelInString: envWithDefaults.LOG_LEVEL_IN_STRING === "true",
|
50 | logMessageKey: envWithDefaults.LOG_MESSAGE_KEY,
|
51 | sentryDsn: envWithDefaults.SENTRY_DSN,
|
52 | };
|
53 | const log = get_log_1.getLog(logOptions).child({ name: "server" });
|
54 | return new probot_1.Probot({
|
55 | log: log.child({ name: "probot" }),
|
56 | ...probotOptions,
|
57 | });
|
58 | }
|
59 | exports.createProbot = createProbot;
|
60 |
|
\ | No newline at end of file |