npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hive-o/nest-probot

v1.6.0

Published

Integrate Probot with NestJS

Downloads

64

Readme

@hive-o/nest-probot

Integrate Probot with NestJS

Description

This module provides access to the Probot library which is used for building GitHub apps.

Motivation

NestJS and Probot are great frameworks that helps bootstrap projects for creating complex applications. That being said both have different configuration patterns and overall execution style. So to simplify Probot configuration and leverage the full extent of NestJS capabilities in such a way the building probot based github applications becomes declarative using decorators and event-handlers, we created this module.

Usage

Before you can start testing probot with nestjs you will need to create a github app Please follow the instructions: how to create a github app?

Install

# NPM
npm i --save @hive-o/nest-probot

# Yarn
yarn add @hive-o/nest-probot

Import

Import and add ProbotModule to the imports section of your nestjs app module. It's common to inject it directly into app Module's constructor so that it can be used during the onModuleInit lifecycle hook at application startup.

Using synchronous configuration

app.module.ts

import { ProbotModule } from '@hive-o/nest-probot';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    ProbotModule.forRoot({
      config: {
        appId: envConfig.GH_APP_ID,
        clientId: envConfig.GH_CLIENT_ID,
        clientSecret: envConfig.GH_CLIENT_SECRET,
        privateKey: envConfig.GH_PRIVATE_KEY, // base64 converted value of your github private key
        webhookSecret: envConfig.GH_WEBHOOK_SECRET, // optional
        webhookProxy: envConfig.GH_WEBHOOK_PROXY, // optional
        webhookPath: envConfig.GH_WEBHOOK_PATH, // optional
      },
    })
  ]
})
export class ExampleModule {}

app.controller.ts

import { Controller, Get, Req } from '@nestjs/common';
import { Hook, ProbotService } from '@hive-o/nest-probot';

@Controller()
export class AppController {
  constructor(private readonly probot: ProbotService) {}

  @Get()
  getHello(): string {
    return 'Hello World!';
  }

  // Add the handler to recieve github hook
  @Post("/hook")
  async hooks(@Req() req) {
    await this.probot.receiveHook(req);
  }

  @Hook(['issue_comment.created'])
  async hook(context) {
    console.log(context);
  }
}

Using asynchronous configuration

app.module.ts

import { ProbotModule } from '@hive-o/nest-probot';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    ProbotModule.forRootAsync({
      isGlobal: true, // (optional), defaults to true
      useFactory: (envConfig: ConfigService) => ({
        appId: envConfig.get('GH_APP_ID'),
        clientId: envConfig.get('GH_CLIENT_ID'),
        clientSecret: envConfig.get('GH_CLIENT_SECRET'),
        privateKey: envConfig.get('GH_PRIVATE_KEY'), // base64 converted value of your github private key
        webhookSecret: envConfig.get('GH_WEBHOOK_SECRET'), // optional
        webhookProxy: envConfig.get('GH_WEBHOOK_PROXY'), // optional
        webhookPath: envConfig.get('GH_WEBHOOK_PATH'), // optional
      }),
      inject: [ConfigService],
    })
  ]
})
export class ExampleModule {}

app.controller.ts

import { Controller, Get, Req } from '@nestjs/common';
import { Hook, ProbotService } from '@hive-o/nest-probot';

@Controller()
export class AppController {
  constructor(private readonly probot: ProbotService) {}

  @Get()
  getHello(): string {
    return 'Hello World!';
  }

  // Add the handler to recieve github hook
  @Post("/hook")
  async hooks(@Req() req) {
    await this.probot.receiveHook(req);
  }

  @Hook(['issue_comment.created'])
  async hook(context) {
    console.log(context);
  }
}