This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/src/index.ts

29 lines
855 B
TypeScript
Raw Normal View History

2017-02-17 09:24:29 +00:00
import { docopt } from 'docopt';
import { readFileSync } from 'fs';
import { join } from 'path';
import { Options } from './types';
import createServer from './server';
const ARG_DATA = readFileSync(join(__dirname, '..', 'src', 'cli.txt')).toString();
function getArgs() : Options {
const rawArgs = docopt(ARG_DATA, {
version: require('../package.json').version,
help: true
});
return {
allowed_ips: rawArgs['--ips'] ? rawArgs['--ips'].split(',') : [],
2017-02-17 20:27:30 +00:00
basicAuth: rawArgs['--basic-auth'] ? rawArgs['--basic-auth'].split(':') : [],
2017-02-17 09:24:29 +00:00
dirList: rawArgs['--list-dir'],
serveDir: rawArgs['<dir>'],
opbeat: rawArgs['--opbeat']
}
}
const app = createServer(getArgs());
const server = app.listen(5000, function () {
console.log("Server started on port " + server.address().port);
});