Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_startServer() {
var args = this.args;
var {port, host} = this.args;
var app = koa();
routes({app, args});
app.listen(Number(port), host);
var clientConnect = this._clientConnect.bind(this);
var clientDisconnect = this._clientDisconnect.bind(this);
// Connect flux to socket.io channel
app.io.use(function *(next) {
clientConnect(this.socket);
yield* next;
clientDisconnect(this.socket);
});
}
import koa from 'koa.io';
import http from 'http';
import routes from './routes';
import Cli from './components/cli';
import TuiReact from './lib/tui-react';
import env from '../shared/env';
import ServerFlux from './flux';
var app = koa();
routes(app);
app.listen(env.PORT);
// Connect flux to socket.io channel
var flux = new ServerFlux();
app.io.use(function *(next) {
// on connect
flux.connect(this.socket);
sendWindowSize();
yield* next;
// on disconnect
flux.disconnect(this.socket);
});
export default function createViews(args) {
var app = koa();
// Add jade rendering
app.use(views(__dirname, {
cache: true,
default: 'jade'
}));
app.use(router(app));
app.get('/', function *() {
yield this.render('index', {
title: 'mc',
env: {
NODE_ENV: args.nodeEnv
}
});
export default function api() {
var app = koa();
app.use(json());
app.use(router(app));
app.get('/ls', function *() {
var dirName = this.query.dir_name || process.cwd();
if (dirName === '~') {
dirName = homedir();
}
this.body = ls(dirName);
});
app.get('/cat', function *() {
this.body = cat(this.query.file_name);
});