#!/usr/bin/env node
const http = require('http');
const path = require('path');
const handler = require('serve-handler');
const yargs = require('yargs');

yargs.option('port', {
  alias: 'p',
  describe: 'Port number',
  demandOption: false,
  type: 'number',
  default: 3000,
});

const argv = yargs.argv;
const port = argv.port;

const server = http.createServer((request, response) => {
  return handler(request, response, {
    public: path.resolve(__dirname, '../dist'),
  });
});

server.listen(port, () => {
  console.log(`Running at http://localhost:${port}`);
});
