This is a way to create a callback url forwarder for services that uses callback urls. It's similar to ngrok and localtunnel.
You have a server that can connect to your clients through WebSockets. Whenever a request hits the webserver from somewhere else, it checks the clients to see if any are listening for that url.
This was created mostly to test callback urls.
- Your own server and domain to run the server part of the code on
- It's preferred that you're on node 6 and npm 3
- git clone
- npm install
- modify config.sample.js
- npm run config
- npm start
Goto the Client README to get more details about the api
// create the client first
const client = new Client({
hostname: 'yourdomain.com',
port: 80, // or you can do baseUrl: 'http://yourdomain.com:80'
sharedSecret: 'YOURSECRET'
});
// connect to the server
client.connect();
// create a listener on http://yourdomain.com/test
client.createListener('test', (req, res) => {
res.status(200); // default is already 200
res.header('Content-Type', 'text/plain');
res.end('OK');
})
.then((listener) => {
// now whenever you hit http://yourdomain.com/test, you
// will get a status 200 and body of 'OK'
request.get({
uri: listener.uri,
}, function(err, res) {
// response will be 'OK'
});
});
To run tests with internal server, you can do this:
SERVER=true npm test
Run tests with external server from config
run server
Run tests with debug logs
LOGLEVEL=debug npm test