index.js
/**
 * @brief This function is the starting point of the application.
 *
 * @return none
 */
@brief This function is the starting point of the application.
@return none
@brief This function is the starting point of the application . @return none
function initialize() {
    'use strict';
    const express = require('express');
    const bodyParser = require('body-parser');
    const mongoose = require('mongoose');
    const router = require('./lib/router');
    const config = require('./config');
    const slackUtil = require('./lib/slackutil');
    const log = require('./lib/logger.js');
    const logger = log.create();
    const locale = require('./locales').get(config.locale);
    function startApp() {
        mongoose.connect(config.db.DB_ADDRESS);
        let app = express();
        app.use(bodyParser.json());
        app.use(bodyParser.urlencoded({extended: false}));
        app.use(slackUtil.checkPostBody);
        app.use(slackUtil.verifyCommandToken);
        app.use(log.logRequest);
        app.use("/", router);
        app.listen(config.PORT, config.IP_ADDRESS, function (error) {
            if (error !== undefined) {
                throw error;
            }
        });
    }
    slackUtil.authenticateToken(function (error, info) {
        if (error !== undefined) {
            throw error;
        }
        logger.trace(locale, "Current locale messages");
        logger.trace(info, "Authenticated by Slack!");
        startApp();
    });
}
function initialize ( ) { 'use strict' ; const express = require ( 'express' ) ; const bodyParser = require ( 'body-parser' ) ; const mongoose = require ( 'mongoose' ) ; const router = require ( './lib/router' ) ; const config = require ( './config' ) ; const slackUtil = require ( './lib/slackutil' ) ; const log = require ( './lib/logger.js' ) ; const logger = log . create ( ) ; const locale = require ( './locales' ) . get ( config . locale ) ; function startApp ( ) { mongoose . connect ( config . db . DB_ADDRESS ) ; let app = express ( ) ; app . use ( bodyParser . json ( ) ) ; app . use ( bodyParser . urlencoded ( { extended : false } ) ) ; app . use ( slackUtil . checkPostBody ) ; app . use ( slackUtil . verifyCommandToken ) ; app . use ( log . logRequest ) ; app . use ( "/" , router ) ; app . listen ( config . PORT , config . IP_ADDRESS , function ( error ) { if ( error !== undefined ) { throw error ; } } ) ; } slackUtil . authenticateToken ( function ( error , info ) { if ( error !== undefined ) { throw error ; } logger . trace ( locale , "Current locale messages" ) ; logger . trace ( info , "Authenticated by Slack!" ) ; startApp ( ) ; } ) ; }
@brief This function is the starting point of the application.
@brief This function is the starting point of the application .
// Setup express router. // Get current configuration. // Setup slack api utility. // Setup bunyan logger // Setup locales config /**
     * @brief This function sets up the middleware and defines the express
     *        routers before starting the application on the configured port. It
     *        is called after the slack api token is verified.
     *
     * @return none
     */ // Connects the app to the mongodb server at the configured address. /* Uses body-parser middleware to parse the given request and populate
         * req.body
         */ // Middleware to check and verify request from slack. // Router middleware for the incoming POST requests. // Start the server on configured address. // Authenticate the slack api token. // Ready to start the application.