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

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(',') : [],
basicAuth: rawArgs['--basic-auth'] ? rawArgs['--basic-auth'].split(':') : [],
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);
});