<commit_before>/**
 * Module dependencies.
 */

var express = require('express')
    , routes = require('./routes/routes')
    , user = require('./routes')
    , http = require('http')
    , path = require('path')
    , fs = require('fs')
    , colors = require('colors');

var app = express();
/**
 * 防止进程挂掉
 */

process.on('uncaughtException', function(err) {
    console.log( " UNCAUGHT EXCEPTION " );
    console.log( "[Inside 'uncaughtException' event] " + err.stack || err.message );
});


var myErrorHandler=function( req, res, next){
    if(err)
    // note, using the typical middleware pattern, we'd call next() here, but
    // since this handler is a "provider", i.e. it terminates the request, we
    // do not.
    req.redirect("error.html")
    next();
};
app.configure(function () {
    app.set('port', process.env.PORT || 3000);

    app.set('views', __dirname + '/views');
    app.use(express.compress());
    app.set('view engine', 'html');
    app.use(express.favicon());
    app.use(express.logger('dev'));
     app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(express.cookieParser('reunion web'));
    app.use(express.cookieSession({cookie:{ path: '/', httpOnly: true, maxAge: null }}));
   /* app.use(express.session());*/
    app.use(app.router);
   /* app.use(myErrorHandler);*/
/*    app.use(function(err, req, res, next){
        if(err){
        console.error("SORRY!!!!!!");
        res.send(500, 'Something broke!');
            next();
        }

    });*/
    app.use(express.static(path.join(__dirname, 'public')));


    /*  app.use(express.static(path.join(__dirname, 'resources')));
     app.use(express.static(path.join(__dirname, 'views/partials')));*/
});
app.all('/api', function(req,res,next){

    var s =req.session["user"] ;
    if(s){
        next();
    }
    else{
        return res.redirect('login');

    }

});
/*app.configure('development', function () {
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});*/


routes(app);

http.createServer(app).listen(app.get('port'), function () {
    console.log("Express server listening on port " + app.get('port'));
});<commit_msg>auth api - by jarrick<commit_after>/**
 * Module dependencies.
 */

var express = require('express')
    , routes = require('./routes/routes')
    , user = require('./routes')
    , http = require('http')
    , path = require('path')
    , fs = require('fs')
    , colors = require('colors');

var app = express();
/**
 * 防止进程挂掉
 */

process.on('uncaughtException', function(err) {
    console.log( " UNCAUGHT EXCEPTION " );
    console.log( "[Inside 'uncaughtException' event] " + err.stack || err.message );
});


var myErrorHandler=function( req, res, next){
    if(err)
    // note, using the typical middleware pattern, we'd call next() here, but
    // since this handler is a "provider", i.e. it terminates the request, we
    // do not.
    req.redirect("error.html")
    next();
};
app.configure(function () {
    app.set('port', process.env.PORT || 3000);

    app.set('views', __dirname + '/views');

    app.set('view engine', 'html');
    app.use(express.compress());
    app.use(express.favicon());
    app.use(express.logger('dev'));
     app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(express.cookieParser('reunion web'));
    app.use(express.cookieSession({cookie:{ path: '/', httpOnly: true, maxAge: null }}));
   /* app.use(express.session());*/

    app.use(app.router);
   /* app.use(myErrorHandler);*/
/*    app.use(function(err, req, res, next){
        if(err){
        console.error("SORRY!!!!!!");
        res.send(500, 'Something broke!');
            next();
        }

    });*/
    app.use(express.static(path.join(__dirname, 'public')));


    /*  app.use(express.static(path.join(__dirname, 'resources')));
     app.use(express.static(path.join(__dirname, 'views/partials')));*/
});

/*app.configure('development', function () {
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});*/

app.all('/api/*', function(req,res,next){
    console.log("api")
    var s =req.session["user"] ;
    if(s){
        next();
    }
    else{
        return res.json(401,{error:"Unauthorized"});

    }

});
routes(app);

http.createServer(app).listen(app.get('port'), function () {
    console.log("Express server listening on port " + app.get('port'));
});
{'fraction_non_alphanumeric': 0.2047457627118644, 'fraction_numerical': 0.0038418079096045198, 'mean_word_length': 3.2476007677543186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1123413', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1428, 'n_words': 272}