API.js
function init() {

        require('dotenv').load();

        app.port = process.env.PORT || 3002;

        // Default route
        app.get('/', function (req, res) {
            res.json({
                name: 'League of Legends eSports API',
                version: "0.9.0",
                author: "Robert Manolea <manolea.robert@gmail.com>",
                repository: "https://github.com/Pupix/lol-esports-api"
            });
        });

        // Dynamic API routes
        XP.forEach(routes, function (func, route) {
            app.get(route, requestHandler);
        });

        //Error Handling
        app.use(function (req, res) { res.status(404).json({error: 404, message: "Not Found"}); });
        app.use(function (req, res) { res.status(500).json({error: 500, message: 'Internal Server Error'}); });

        // Listening
        app.listen(app.port, function () { console.log('League of Legends eSports API is listening on port ' + app.port); });
    }
function init() {

        require('dotenv').load();

        app.port = process.env.PORT || 3002;

        // Default route
        app.get('/', function (req, res) {
            res.json({
                name: 'League of Legends eSports API',
                version: "0.9.0",
                author: "Robert Manolea <manolea.robert@gmail.com>",
                repository: "https://github.com/Pupix/lol-esports-api"
            });
        });

        // Dynamic API routes
        XP.forEach(routes, function (func, route) {
            app.get(route, requestHandler);
        });

        //Error Handling
        app.use(function (req, res) { res.status(404).json({error: 404, message: "Not Found"}); });
        app.use(function (req, res) { res.status(500).json({error: 500, message: 'Internal Server Error'}); });

        // Listening
        app.listen(app.port, function () { console.log('League of Legends eSports API is listening on port ' + app.port); });
    }
function init ( ) { require ( 'dotenv' ) . load ( ) ; app . port = process . env . PORT || 3002 ; // Default route app . get ( '/' , function ( req , res ) { res . json ( { name : 'League of Legends eSports API' , version : "0.9.0" , author : "Robert Manolea <manolea.robert@gmail.com>" , repository : "https://github.com/Pupix/lol-esports-api" } ) ; } ) ; // Dynamic API routes XP . forEach ( routes , function ( func , route ) { app . get ( route , requestHandler ) ; } ) ; //Error Handling app . use ( function ( req , res ) { res . status ( 404 ) . json ( { error : 404 , message : "Not Found" } ) ; } ) ; app . use ( function ( req , res ) { res . status ( 500 ) . json ( { error : 500 , message : 'Internal Server Error' } ) ; } ) ; // Listening app . listen ( app . port , function ( ) { console . log ( 'League of Legends eSports API is listening on port ' + app . port ) ; } ) ; }
Main function of the API
Main function of the API