{"size": 803, "ext": "js", "max_stars_repo_path": "src/server/index.js", "max_stars_repo_name": "alex-saunders/cli-gui", "max_stars_repo_stars_event_min_datetime": "2019-04-17T18:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T11:02:38.000Z", "max_issues_repo_path": "src/server/index.js", "max_issues_repo_name": "alex-saunders/cli-gui", "max_issues_repo_issues_event_min_datetime": "2019-04-16T21:32:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T10:11:37.000Z", "max_forks_repo_path": "src/server/index.js", "max_forks_repo_name": "alex-saunders/cli-gui", "max_forks_repo_forks_event_min_datetime": "2019-04-18T10:32:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-01T04:52:59.000Z"}
{"max_stars_count": 901, "max_issues_count": 31, "max_forks_count": 32, "avg_line_length": 25.09375, "max_line_length": 70, "alphanum_fraction": 0.6525529265}
// @flow
import path from 'path';
import http from 'http';
import express from 'express';

import minimist from 'minimist';

import ClientHandler from './clientHandler';

const app = express();
const server = http.createServer(app);

const args = minimist(process.argv.slice(2));
const port = args.port || 5000;

new ClientHandler(server);

if (process.env.GLICKY_ENV === 'production') {
  app.use(express.static(path.join(__dirname, '../', 'client')));

  app.get('*', (req, res: express$Response) => {
    res.sendFile(path.join(__dirname, '../', 'client', 'index.html'));
  });
}

if (typeof port === 'string' || typeof port === 'number') {
  server.listen(parseInt(port), undefined, undefined, () => {
    // eslint-disable-next-line
    console.log(`🚀 Glicky is running on port ${port}!`);
  });
}
