app.js 740 Bytes
const express = require('express');
const bodyParser = require('body-parser');

const app = express();

const config = require('./common/config');

const logger = require('yoho-node-lib/lib/logger').init(config);
const crypto = require('yoho-node-lib/lib/crypto');

global.yoho = {
    logger,
    config,
    crypto
};

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

const middleware = require('./middleware');

app.post('/write', middleware.serverApm);

app.get('/yas.gif', middleware.apm);

app.use('*', (req, res) => {
    res.statusCode = 404;
    res.send();
});
app.use((err, req, res) => {
    logger.error('error:', err);
    res.send();
});

app.listen(config.port, () => {
    logger.info(`yoho apm start at ${config.port}`);
});