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

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var mm = require('musicmetadata');
var Sequelize = require('sequelize');
var upload = require('jquery-file-upload-middleware');
var sass = require('node-sass');
var _ = require('lodash');

if (process.env.HEROKU_POSTGRESQL_GOLD_URL) {
  var match = process.env.HEROKU_POSTGRESQL_GOLD_URL.match(/postgres:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/)
  var sequelize = new Sequelize(match[5], match[1], match[2], {
    dialect: 'postgres',
    protocol: 'postgres',
    port: match[4],
    host: match[3],
    logging: true
  });
} else {
  sequelize = new Sequelize('test', 'root', 'pass');
}

var Track = sequelize.define('Track', {
  file: { type: Sequelize.STRING, unique: true },
  name: { type: Sequelize.STRING },
  time: { type: Sequelize.INTEGER },
  artist: { type: Sequelize.STRING },
  album: { type: Sequelize.STRING },
  genre: { type: Sequelize.STRING }
});

sequelize
  .sync()
  .complete(function(err) {
    if (err) {
      console.log('✗ Error occurred while creating the table:', err)
    } else {
      console.log('✓ Sequelize Sync Complete')
    }
  });

upload.configure({
  uploadDir: __dirname + '/public/uploads',
  uploadUrl: '/uploads'
});

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use('/upload', upload.fileHandler());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(sass.middleware({ src: path.join(__dirname, 'public') }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.errorHandler());
app.use(function(req, res, next){
  if (req.path.indexOf('uploads') !== -1) {
    // 404 on /uploads/filename
    var track404 = req.path.split('/').slice(-1)[0];
    Track.find({ where: { file: track404 } })
      .success(function (track) {
        if (track) {
          track.destroy()
            .success(function() {
              console.log('deleted - ', track404);
              return res.send( { message: 'Track no longer exists' });
            });<commit_msg>Disabled sass middleware temporarily<commit_after>
/**
 * Module dependencies.
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var mm = require('musicmetadata');
var Sequelize = require('sequelize');
var upload = require('jquery-file-upload-middleware');
var sass = require('node-sass');
var _ = require('lodash');

if (process.env.HEROKU_POSTGRESQL_GOLD_URL) {
  var match = process.env.HEROKU_POSTGRESQL_GOLD_URL.match(/postgres:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/)
  var sequelize = new Sequelize(match[5], match[1], match[2], {
    dialect: 'postgres',
    protocol: 'postgres',
    port: match[4],
    host: match[3],
    logging: true
  });
} else {
  sequelize = new Sequelize('test', 'root', 'pass');
}

var Track = sequelize.define('Track', {
  file: { type: Sequelize.STRING, unique: true },
  name: { type: Sequelize.STRING },
  time: { type: Sequelize.INTEGER },
  artist: { type: Sequelize.STRING },
  album: { type: Sequelize.STRING },
  genre: { type: Sequelize.STRING }
});

sequelize
  .sync()
  .complete(function(err) {
    if (err) {
      console.log('✗ Error occurred while creating the table:', err)
    } else {
      console.log('✓ Sequelize Sync Complete')
    }
  });

upload.configure({
  uploadDir: __dirname + '/public/uploads',
  uploadUrl: '/uploads'
});

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use('/upload', upload.fileHandler());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
//app.use(sass.middleware({ src: path.join(__dirname, 'public') }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.errorHandler());
app.use(function(req, res, next){
  if (req.path.indexOf('uploads') !== -1) {
    // 404 on /uploads/filename
    var track404 = req.path.split('/').slice(-1)[0];
    Track.find({ where: { file: track404 } })
      .success(function (track) {
        if (track) {
          track.destroy()
            .success(function() {
              console.log('deleted - ', track404);
              return res.send( { message: 'Track no longer exists' });
            });
{'fraction_non_alphanumeric': 0.2026266416510319, 'fraction_numerical': 0.010006253908692933, 'mean_word_length': 3.8076152304609217, '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': '6279021', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1610, 'n_words': 335}