1.0.6 • Published 7 years ago

deploy-hook-server v1.0.6

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

Library for create deploy hook server

Server listen port and check headers, if headers correct, server execute custom script

Usage

install library npm i deploy-hook-server
start server:

const serverLib = require('../lib/server');
const server = serverLib.Server({
    port: 40312,
    accessHeaderName: 'deploy-token',
    accessHeaderValue: 'meex0c8wdmcpjhjsssrfbeveasarhydnoe9g0bxot8fojk708kaiegbo091oaaybl',
    handlerOptions: {
        executeScriptPath: './tests/test-deploy-script.sh',
        formatExecuteScriptFn: function (currentPath, deployParams) {
            console.log('formatExecuteScriptFn', `currentPath:${currentPath}`, 'deployParams:', deployParams);
            currentPath += ' ' + deployParams['deployService'];
            currentPath += ' ' + deployParams['deployVersion'];
            return currentPath;
        },
    },
    extractRequestDataFn: function (req, res) {
        return new Promise( (resolve, reject) => {
            if ( req.headers['content-type'] !== 'application/json' ) {
                return reject(new Error('Content type must be application/json'));
            }
            let totalData = '';
            req.on('data', function (data) {
                totalData+= data;
            });
            req.on('end', function () {
                resolve( JSON.parse(totalData) );
            });
        });
    }
});
1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago