app.js 707 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);

    // eslint-disable-next-line no-unused-vars
    app.use('*', (req, res) => {
        res.statusCode = 404;
        res.send();
    });

    // eslint-disable-next-line no-unused-vars
    app.use((err, req, res, next) => {
        logger.error('express error-handling:', err);
        res.send();
    });
} catch (e) {
    logger.error('express route registering:', e);
}

module.exports = app;