cds-snc/elenchos

View on GitHub
src/lib/util/getInstallationId.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { RequestBody } from "../../interfaces";

let warned = false;

export const getInstallationId = (event: RequestBody) => {
  if (!event || !event.installation || !event.installation.id) {
    const GITHUB_INSTALLATION_ID = process.env.GITHUB_INSTALLATION_ID;

    !warned && console.warn(`event.installation.id missing using ENV`);
    warned = true;
    return GITHUB_INSTALLATION_ID;
  }

  return event.installation.id;
};