dummy-http-server.js 868 Bytes
#!/usr/bin/env node
"use strict";

/*eslint no-console: "off" */

const express = require('express')
const app = express();
const argv = require('yargs').argv

const port = argv.port || 8080;

app.use(function(req, res, next) {
    if (req.path === '/favicon.ico') {
        res.end('');
        return;
    }

    console.log('');
    console.log('** Incoming request from ' + req.ip);
    console.log('Path: ' + req.path);

    next();
})

app.get('/', function(req, res, next) {
    console.log('Method: GET');
    console.log('Query string:', JSON.stringify(req.query, null, 2));

    next();
})

app.post('/', function(req, res, next) {
    console.log('Method: POST');
    console.log('Body: ' + req.body);
    next();
})

app.use(function(req, res) {
    res.end('');
})

app.listen(port, () => {
    console.log('Dummy HTTP server listen on port ' + port);
})