lib/server.js
function handler(req, res) {

        var path = cog.getConfig('options.api_data');
        var urlRegex = cog.getConfig('options.api_url_regex');
        var url = req.url.replace(/^\//, '').replace(/\/$/, '');

        console.log(req.method + ' ' + req.url);

        // Find the JSON-data file and serve it, if URL points to the API.
        if (path && urlRegex && urlRegex.test(url)) {
            var file = path + '/' + url + '.json';
            if (grunt.file.exists(file)) {
                res.end(grunt.file.read(file));
                return;
            }
        }

        if (req.method == 'POST') {
            // TODO: This needs fixing, since it throws an error.
            res.end('{"message": "OK"}');
        }

    }
function handler(req, res) {

        var path = cog.getConfig('options.api_data');
        var urlRegex = cog.getConfig('options.api_url_regex');
        var url = req.url.replace(/^\//, '').replace(/\/$/, '');

        console.log(req.method + ' ' + req.url);

        // Find the JSON-data file and serve it, if URL points to the API.
        if (path && urlRegex && urlRegex.test(url)) {
            var file = path + '/' + url + '.json';
            if (grunt.file.exists(file)) {
                res.end(grunt.file.read(file));
                return;
            }
        }

        if (req.method == 'POST') {
            // TODO: This needs fixing, since it throws an error.
            res.end('{"message": "OK"}');
        }

    }
function handler ( req , res ) { var path = cog . getConfig ( 'options.api_data' ) ; var urlRegex = cog . getConfig ( 'options.api_url_regex' ) ; var url = req . url . replace ( / ^\/ / , '' ) . replace ( / \/$ / , '' ) ; console . log ( req . method + ' ' + req . url ) ; // Find the JSON-data file and serve it, if URL points to the API. if ( path && urlRegex && urlRegex . test ( url ) ) { var file = path + '/' + url + '.json' ; if ( grunt . file . exists ( file ) ) { res . end ( grunt . file . read ( file ) ) ; return ; } } if ( req . method == 'POST' ) { // TODO: This needs fixing, since it throws an error. res . end ( '{"message": "OK"}' ) ; } }
This is the development server used by CoG.
This is the development server used by CoG .