Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// log4js.info(meta);
// await next();
// return;
// });
app.use(render(__dirname + '/view', {
map: {
html: 'underscore'
},
extension: 'ejs'
}));
app.use(router.routes())
.use(router.allowedMethods());
app.use(serveSass({
mountAt: '/static/css',
src: './static/scss',
dest: './static/css',
importPaths: ['./node_modules']
}))
app.use(serveStatic('./static', '/static'));
sequelize.rajio.sync()
sequelize.rajioInfo.sync()
gc.init()
info.init()
app.listen(4290);
log4js.info('Serving at http://localhost:4290');
referrerPolicy,
} from 'koa-helmet';
import logger from 'koa-logger';
import mount from 'koa-mount';
import enforceHttps from 'koa-sslify';
import Koa from 'koa';
import bugsnag from 'bugsnag';
import onerror from 'koa-onerror';
import updates from './utils/updates';
import auth from './auth';
import api from './api';
import emails from './emails';
import routes from './routes';
const app = new Koa();
app.use(compress());
if (process.env.NODE_ENV === 'development') {
/* eslint-disable global-require */
const convert = require('koa-convert');
const webpack = require('webpack');
const devMiddleware = require('koa-webpack-dev-middleware');
const hotMiddleware = require('koa-webpack-hot-middleware');
const config = require('../webpack.config.dev');
const compile = webpack(config);
/* eslint-enable global-require */
app.use(
convert(
devMiddleware(compile, {
)
Dispatcher.register(
'CheckIn',
CommandHandlers.makeCheckInHandler(store)
)
Dispatcher.register(
'Remove',
CommandHandlers.makeRemoveHandler(store)
)
Dispatcher.register(
'Deactivate',
CommandHandlers.makeDeactivateHandler(store)
)
// Set up a Koa app to expose our awesome app to the world.
const app = new Koa()
app.use(bodyParser())
app.use(async (ctx: any, next: any) => {
try {
await next()
} catch (err) {
ctx.status = 500
ctx.body = {
error: err.message
}
logger.error('Error in request', err)
}
})
const controller = {
// Writes
async createItem(ctx: any) {
_createKoa() {
const koa = new Koa();
koa.use(
logger(message => {
debug(message);
})
);
koa.use(jsonError());
koa.use(cors({maxAge: 900})); // 15 minutes
koa.use(bodyParser({enableTypes: ['json'], jsonLimit: '8mb'}));
koa.use(async ctx => {
if (ctx.method !== 'POST') {
throw new Error('Invalid HTTP request');
}
const layer = await this._layerCreator();
_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
}
});
function Kona(options) {
// call the koa constructor here
Koa.call(this);
options = options || {};
// setup kona root and application paths / helpers
this.setupPaths(options);
// setup env vars, logger, needed modules
this.setupEnvironment(options);
this.loadMixins(this.root.join('package.json'));
}
/*!
* Moajs Middle
* Copyright(c) 2015-2019 Alfred Sang
* MIT Licensed
*/
const api = require('koa.res.api')
// 检查用户会话
module.exports = api()
'use strict';
const requestProto = require('koa/lib/request');
const responseProto = require('koa/lib/response');
const contextProto = require('koa/lib/context');
const applicationProto = require('koa/lib/application').prototype;
const completeAssign = require('complete-assign');
const Loader = require('../core/Loader');
const baseClassProto = require('../core/base/BaseClass').prototype;
class AstroboyExtendLoader extends Loader {
load() {
// application extend
this.globDirs(this.config.applicationPattern, entries => {
entries.forEach(entry => {
completeAssign(applicationProto, require(entry));
});
});
// context extend
this.globDirs(this.config.contextPattern, entries => {
entries.forEach(entry => {