Git Product home page Git Product logo

hookserver's Introduction

view on npm npm module downloads per month Analytics

Hookserver

Usage

# install it as a cli tool
npm install -g hookserver

# start the server daemonized and redirect log to ./hookserver.log
# 6086 is the default port, you can use -p or --port option to override it
hookserver start -d -l ./hookserver.log

# switch to the examples folder shipped with the package
cd /usr/local/lib/node_modules/hookserver/examples  

# register a webhook with the name 'hello' 
# that will trigger the bash script found at './hello.sh' to be executed
hookserver add hook hello ./hello.sh

# register a new security key 'my-test-key' to allow access to the registered webhooks via http requests
hookserver add key my-test-key

# test it out: send a get request to 'http://localhost:6086/hello?my-test-key'
curl "http://localhost:6086/hello?my-test-key"

# the output:
# {"status":"success","result":"Hello Webhooks!\n"}

For more information, run hookserver help or take a look at help.md.

Note on permissions: Hookserver uses /var/lib/hookserver to store hook scripts and security keys. Usually only the root user is allowed to make changes in that directory, so probably you'll have to use sudo. If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the --unsafe-perm flag to run scripts with root privileges and let Hookserver register its working folders.

# so instead of this...
npm install -g hookserver

# ...maybe you will have to use this
sudo npm i -g hookserver --unsafe-perm

Application data

Keep in mind that registered hooks and security keys will not be deleted if you uninstall or update Hookserver. You have to run hookserver cleanup before uninstalling it to remove all the saved application data.

License

MIT license.

hookserver's People

Contributors

schwarzkopfb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ccgview

hookserver's Issues

env variables & key issue

Hi schwarzkopfb, your tool is great and the exactly what I want. I have two problem when using it.

  1. Function runHook call prepareEnv, but when the data is null will cause child_process exec the bash with the env an empty object, which will lead to losing the enviroment variables such as node version (I use nvm to manage node so I come to this problem). I think call a plain merge with the process.env will fix it
  2. According to the doc the key will use as a query param such as "xxxx:6086/build?test-key". When I use setup the github webhook service, github will send the url PING as "xxxx xxxx:6086/build?test-key=", adding an "=" to the url, which will cause the key matching failed. I guess github run a serialization for the url, so I have to set the key to "test-key=1" to prevent it. My question is, can the url make an adjustment such as "xxxx:6086/build?key=test-key" ?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.