<commit_before>var express = require('express')
var app = express()
var bodyParser = require('body-parser')
var session = require('express-session');
var KnexSessionStore = require('connect-session-knex')(session);
var db = require('./db');

const store = new KnexSessionStore({
    knex: db.knex,
    tablename: 'sessions' // optional. Defaults to 'sessions'
});

var urlencodedParser = bodyParser.urlencoded({ extended: false })

app.use(session({
    secret: process.env.COOKIE_SECRET,
    cookie: {
        maxAge: 10000000
    },
    store: store
}));

db.build().then(function() {
  app.post('/api/event', urlencodedParser, function (req, res) {
    if (!req.body) return res.sendStatus(400);
    var newevent = req.body;
    var eventlocation = newevent.EventLocation.split(',')
    newevent.location_latitude = eventlocation[0].trim();
    newevent.location_longitude = eventlocation[1].trim();
    newevent.hostid = req.session.userid;
    db.createEvent().then(function() {

    });
  })
  app.post('/api/:id/join', urlencodedParser, function (req, res) {
    if (!req.body) return res.sendStatus(400);
    db.joinEvent(req.params.id, req.session.userid).then(function() {
      
    });
  });
  
  app.post('/api/:id/comment', urlencodedParser, function (req, res) { postComment(req); });
  app.post('/api/:id/comment/:parent', urlencodedParser, function (req, res) { postComment(req); });
  
  postComment = function(req) {
    if (!req.body) return res.sendStatus(400);
    var newcomment = req.body;
    newcomment.userid = req.session.userid;
    db.postComment(newcomment).then(function() {
      
    });
  }
  app.use(function(req, res, next) {
    var idPromise;
    if(typeof req.session.userid == 'undefined') {
      idPromise = db.newUser().then(function(id) {
        return req.session.userid = id[0];
      })
    } else {
      idPromise = Promise.resolve(req.session.userid);
    }
      idPromise.then(function() {<commit_msg>im dumb<commit_after>var express = require('express')
var app = express()
var bodyParser = require('body-parser')
var session = require('express-session');
var KnexSessionStore = require('connect-session-knex')(session);
var db = require('./db');

const store = new KnexSessionStore({
    knex: db.knex,
    tablename: 'sessions' // optional. Defaults to 'sessions'
});

var urlencodedParser = bodyParser.urlencoded({ extended: false })

app.use(session({
    secret: process.env.COOKIE_SECRET,
    cookie: {
        maxAge: 10000000
    },
    store: store
}));

db.build().then(function() {
  app.post('/api/event', urlencodedParser, function (req, res) {
    if (!req.body) return res.sendStatus(400);
    var newevent = req.body;
    var eventlocation = newevent.EventLocation.split(',')
    newevent.location_latitude = eventlocation[0].trim();
    newevent.location_longitude = eventlocation[1].trim();
    newevent.hostid = req.session.userid;
    db.createEvent(newevent).then(function() {

    });
  })
  app.post('/api/:id/join', urlencodedParser, function (req, res) {
    if (!req.body) return res.sendStatus(400);
    db.joinEvent(req.params.id, req.session.userid).then(function() {
      
    });
  });
  
  app.post('/api/:id/comment', urlencodedParser, function (req, res) { postComment(req); });
  app.post('/api/:id/comment/:parent', urlencodedParser, function (req, res) { postComment(req); });
  
  postComment = function(req) {
    if (!req.body) return res.sendStatus(400);
    var newcomment = req.body;
    newcomment.userid = req.session.userid;
    db.postComment(newcomment).then(function() {
      
    });
  }
  app.use(function(req, res, next) {
    var idPromise;
    if(typeof req.session.userid == 'undefined') {
      idPromise = db.newUser().then(function(id) {
        return req.session.userid = id[0];
      })
    } else {
      idPromise = Promise.resolve(req.session.userid);
    }
      idPromise.then(function() {
{'fraction_non_alphanumeric': 0.16411042944785276, 'fraction_numerical': 0.010224948875255624, 'mean_word_length': 3.5606060606060606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1575098', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1287, 'n_words': 237}