Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hstarorg/node-git-webhooks
The webhooks lib for code repositories based on git.
https://github.com/hstarorg/node-git-webhooks
github gitlab webhooks
Last synced: about 1 month ago
JSON representation
The webhooks lib for code repositories based on git.
- Host: GitHub
- URL: https://github.com/hstarorg/node-git-webhooks
- Owner: hstarorg
- License: mit
- Created: 2017-10-22T09:54:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-26T12:56:08.000Z (about 7 years ago)
- Last Synced: 2024-04-23T23:46:50.393Z (9 months ago)
- Topics: github, gitlab, webhooks
- Language: TypeScript
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-git-webhooks
The webhooks lib for code repositories based on git.# Usage
```bash
# Local install
npm i -S node-git-webhooks
``````js
const gitWebhooks = require('node-git-webhooks').default;const options = {}; // The webhooks server optoions
// Gitlab Server
const server = new gitWebhooks.GitlabWebHooksServer(options);
// All gitlab webhooks type.
const gitlabEventType = gitWebhooks.GitlabEventType;
server.subscribe((evt, data) => {
if (evt === gitlabEventType.Push) {
console.log('push', data);
} else if (evt === gitlabEventType.IssueNote) {
console.log('issue note', data);
}
});// Also support Github Server
// const server = new gitWebhooks.GithubWebHooksServer(options);
// All github webhooks type.
// const githubEventType = gitWebhooks.GithubEventType;
// server.subscribe((evt, data) => {
// if (evt === githubEventType.Push) {
// console.log('push', data);
// } else if (evt === githubEventType.IssueNote) {
// console.log('issue note', data);
// }
// });server.onError(err => {
console.error('Error', err);
});// Run web hooks server at port 8000;
server.listen(8000).then(server => {
console.log('server started...');
});
```**options**
```
{
token: string // The webhooks Secret(github) or Secret Token(gitlab)
}
```**Note: If use github webhooks server, should choose the application/json content-type.**
# How to Develop
```bash
# Clone the project
git clone# Install deps
npm i# Run dev
npm run dev# Run build and generate declarations.
npm run build
```# [CHANGLOG](CHANGLOG.md)