node.js - Gitlab webhook 系统
问题描述
我有一个问题:
我的应用程序使用端口 1337(我在sails.js 框架中使用),我必须从 gitlab 编写一个 webhook 系统。我没有找到很多关于“如何编写webhook系统”的教程,但我有以下代码:
const secret = "your_secret_here";
const repo = "~/your_repo_path_here/";
const http = require('http');
const crypto = require('crypto');
const exec = require('child_process').exec;
http.createServer(function (req, res) {
req.on('data', function(chunk) {
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
exec('cd ' + repo + ' && git pull');
}
});
res.end();
}).listen(8080);
此代码使用端口 8080,我的问题是:如何使用此代码,但不在端口 8080 上而是在我的应用程序端口 1337 上使用?,如何编辑此代码以成为sails 的正确版本?
感谢所有答案
解决方案
推荐阅读
- github - 如何获取 Github 管理员操作的 Slack 通知?
- php - Phalcon 停止视图在 dispatch() 后回显
- laravel - Laravel:如何将 pdf 文件直接上传到 Google Cloud Storage 存储桶而无需先保存在本地
- node.js - 使用 Sendgrid/mail 和 nodejs 防止未处理的承诺拒绝
- ruby-on-rails - 迁移变化
- python - 具有几乎相同代码的两个图形导致 matplotlib 中不同大小的饼图
- python - 如何将 Python IDE 中的串行输出数据转换为 C 中的整数?
- windows - 从 .bat 文件中关闭打开的 cmd 窗口打开应用程序并执行文件
- api - Vue警告]:渲染错误:“TypeError:无法读取未定义的属性'map'”Vue Google maps
- .net - ADAL 到 MSAL 迁移保护 Web API