app.js 609 Bytes
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const config = require('./common/config');

require('yoho-node-lib').global(config);

const {logger} = global.yoho;

app.use(bodyParser.text({
    limit: '1024kb'
}));

try {
    require('./dispatch')(app);

    // error handle
    app.use('*', (req, res) => {
        res.statusCode = 404;
        res.send();
    });

    app.use((err, req, res, next) => { // eslint-disable-line
        logger.error('error:', err);
        res.send();
    });
} catch (e) {
    logger.error(e);
}

module.exports = app;