Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arlac77/koa-github-hook-handler
handle github/gitea Webhook requests
https://github.com/arlac77/koa-github-hook-handler
gitea github koa webhook
Last synced: 2 months ago
JSON representation
handle github/gitea Webhook requests
- Host: GitHub
- URL: https://github.com/arlac77/koa-github-hook-handler
- Owner: arlac77
- License: bsd-2-clause
- Created: 2019-04-18T08:08:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T09:13:24.000Z (3 months ago)
- Last Synced: 2024-09-17T00:16:37.463Z (3 months ago)
- Topics: gitea, github, koa, webhook
- Language: JavaScript
- Homepage:
- Size: 1.96 MB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/koa-github-hook-handler.svg)](https://www.npmjs.com/package/koa-github-hook-handler)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
[![bundlejs](https://deno.bundlejs.com/?q=koa-github-hook-handler\&badge=detailed)](https://bundlejs.com/?q=koa-github-hook-handler)
[![downloads](http://img.shields.io/npm/dm/koa-github-hook-handler.svg?style=flat-square)](https://npmjs.org/package/koa-github-hook-handler)
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/koa-github-hook-handler.svg?style=flat-square)](https://github.com/arlac77/koa-github-hook-handler/issues)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fkoa-github-hook-handler%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/koa-github-hook-handler/goto)
[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/koa-github-hook-handler/badge.svg)](https://snyk.io/test/github/arlac77/koa-github-hook-handler)
[![Coverage Status](https://coveralls.io/repos/arlac77/koa-github-hook-handler/badge.svg)](https://coveralls.io/github/arlac77/koa-github-hook-handler)## koa-github-hook-handler
handle github/gitea/bitbucket requests
```js
import Koa from "koa";
import Router from "koa-better-router";
import { createGithubHookHandler } from "koa-github-hook-handler";...
const router = Router();
const secret = "...";router.addRoute(
"POST",
"/hook",
createGithubHookHandler(
{
push: async request => {
console.log("PUSH",request);
return { ok: true };
}
},
{ secret }
)
);
```# API
### Table of Contents
* [Context](#context)
* [KoaHandler](#koahandler)
* [Parameters](#parameters)
* [WebhookHandler](#webhookhandler)
* [Parameters](#parameters-1)
* [createGithubHookHandler](#creategithubhookhandler)
* [Parameters](#parameters-2)
* [createGiteaHookHandler](#creategiteahookhandler)
* [Parameters](#parameters-3)
* [createBitbucketHookHandler](#createbitbuckethookhandler)
* [Parameters](#parameters-4)## Context
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
## KoaHandler
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
### Parameters
* `ctx` **[Context](#context)**
* `next` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**## WebhookHandler
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
### Parameters
* `request` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** decoded request body
* `event` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** from 'x-github-event' header
* `ctx` **[Context](#context)** from koa## createGithubHookHandler
Create a koa middleware suitable to bridge github webhook requests to KoaHandlers
### Parameters
* `actions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** holding all the handles for the events (event is the key)
* `actions.default` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** default action
* `actions.event` **[WebhookHandler](#webhookhandler)** (event is the key)
* `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)*** `config.secret` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** to decode signature
Returns **[KoaHandler](#koahandler)** suitable as koa middleware
## createGiteaHookHandler
Create a koa middleware suitable to bridge gitea webhook requests to KoaHandlers
### Parameters
* `actions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** holding all the handles for the events (event is the key)
* `actions.default` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** default action
* `actions.event` **[WebhookHandler](#webhookhandler)** (event is the key)
* `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)*** `config.secret` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** to decode signature
Returns **[KoaHandler](#koahandler)** suitable as koa middleware
## createBitbucketHookHandler
Create a koa middleware suitable to bridge gitea webhook requests to KoaHandlers
### Parameters
* `actions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** holding all the handles for the events (event is the key)
* `actions.default` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** default action
* `actions.event` **[WebhookHandler](#webhookhandler)** (event is the key)
* `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)*** `config.secret` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** to decode signature
Returns **[KoaHandler](#koahandler)** suitable as koa middleware
# install
With [npm](http://npmjs.org) do:
```shell
npm install koa-github-hook-handler
```# license
BSD-2-Clause