{"id":20430647,"url":"https://github.com/xudaolong/oschina-webhook-handler","last_synced_at":"2026-07-01T12:31:28.966Z","repository":{"id":57316462,"uuid":"102310841","full_name":"xudaolong/oschina-webhook-handler","owner":"xudaolong","description":"support oschina multiple webhook with all events","archived":false,"fork":false,"pushed_at":"2017-09-09T02:03:00.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-31T07:38:35.334Z","etag":null,"topics":["oschina","webhook","webhook-handler"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xudaolong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-04T02:34:10.000Z","updated_at":"2017-09-11T07:36:40.000Z","dependencies_parsed_at":"2022-08-25T21:11:03.954Z","dependency_job_id":null,"html_url":"https://github.com/xudaolong/oschina-webhook-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xudaolong/oschina-webhook-handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xudaolong%2Foschina-webhook-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xudaolong%2Foschina-webhook-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xudaolong%2Foschina-webhook-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xudaolong%2Foschina-webhook-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xudaolong","download_url":"https://codeload.github.com/xudaolong/oschina-webhook-handler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xudaolong%2Foschina-webhook-handler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35007274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oschina","webhook","webhook-handler"],"created_at":"2024-11-15T08:08:13.774Z","updated_at":"2026-07-01T12:31:28.934Z","avatar_url":"https://github.com/xudaolong.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oschina-webhook-handler\n\n[![NPM](https://nodei.co/npm/oschina-webhook-handler.png?downloads=true\u0026downloadRank=true)](https://nodei.co/npm/oschina-webhook-handler/)\n[![NPM](https://nodei.co/npm-dl/oschina-webhook-handler.png?months=6\u0026height=3)](https://nodei.co/npm/oschina-webhook-handler/)\n\nThe oschina allows you to register Webhooks for your repositories. Each time an event occurs on your repository, whether it be pushing code, filling issues or creating pull requests, the webhook address you register can be configured to be pinged with details.\n\nThis library is a small handler (or \"middleware\" if you must) fornode.jsweb servers that handles all the logic of receiving and verifying webhook requests from the oschina.\n\n(The base code with https://github.com/rvagg/github-webhook-handler)\n\n## Event Links\n\nYou can see the url(http://git.mydoc.io/?t=154711) and find events.\n\n- note_hooks\n- merge_request_hooks\n- issue_hooks\n- push_hooks\n- tag_push_hooks\n\n## Installation\n\n- npm install oschina-webhook-handler@latest\n\n## Example\n\n```\n\nconst http = require('http');\nconst createHandler = require('../lib/index');\nconst handler = createHandler([\n    {path: '/incoming', secret: 'xudaolong'},\n    {path: '/sucheye', secret: 'xudaolong'},\n]);\n\n// 上面的 secret 保持和 oschina 后台设置的一致\nfunction run_cmd(cmd, args, callback) {\n    const spawn = require('child_process').spawn;\n    const child = spawn(cmd, args);\n    let resp = '';\n\n    child.stdout.on('data', function (buffer) {\n        resp += buffer.toString();\n    });\n    child.stdout.on('end', function () {\n        callback(resp);\n    });\n}\n\nhttp.createServer(function (req, res) {\n    handler(req, res, function (err) {\n        res.statusCode = 404;\n        res.end('no such location ke pa');\n    });\n}).listen(5555);\n\nhandler.on('error', function (err) {\n    console.error('Error:', err.message);\n});\n\n// 去官网查看相关的事件:http://git.mydoc.io/?t=154711\nhandler.on('push_hooks', function (event) {\n    console.log('Received a push event for %s to %s', event.payload.repository.name, event.url);\n    switch (event.url) {\n        case '/incoming':\n            // do sth about\n            // run_cmd('sh', ['./prod.sh'], function (text) {\n            //     console.log(text);\n            // });\n            console.log('incoming');\n            break;\n        case '/sucheye':\n            console.log('sucheye');\n            // do sth about webhook2\n            break;\n        default:\n            console.log('default');\n            // do sth else or nothing\n            break\n    }\n});\n\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxudaolong%2Foschina-webhook-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxudaolong%2Foschina-webhook-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxudaolong%2Foschina-webhook-handler/lists"}