converts old style imports:
var express = require('express')
, redismodule = require('redis')
, _ = require('underscore')
to new style:
var express = require('express');
converts old style imports:
var express = require('express')
, redismodule = require('redis')
, _ = require('underscore')
to new style:
var express = require('express');
/* | |
an orm should only take care of mapping objects to a relational database. that's **all**. a lot of my problems with | |
sequelize come from the fact that i'm using sequelize to define my models. i would much prefer to use plain javascript | |
objects to define my models - not using sequelize.define or some other sort of "definer". ideally i could follow a more | |
classic object-oriented approach where my models could extend or implement an orm that takes care of relaying data back and | |
fourth between the database and client and nothing else. | |
*/ | |
var ORM = function() { | |
this._as = {}; |
module.exports = function() { | |
return function(req, res, next) { | |
if (!req.isAuthenticated()) { | |
return res.status(401).end(); | |
} | |
if (req.user.role !== 'admin') { | |
return res.redirect('/'); | |
} | |
return next(); | |
}; |
var util = require('util'); | |
var loggly = require('../services/loggly'); | |
function middleware() { | |
return function(err, req, res, next) { | |
if (!util.isError(err)) { | |
var error = new Error(); | |
if (typeof err === 'number') { | |
error.status = err; |
module.exports = function() { | |
return function(req, res, next) { | |
if (!req.user) return next(); | |
var sql = req.app.services.sql; | |
sql | |
.query('update users set last_active = $1 where id = $2;', [new Date(), req.user.id]) |
/** | |
* inlines all css | |
* @todo should replace sendgrid with smtp to make more reusable | |
*/ | |
var _ = require('underscore'); | |
var config = require('../config'); | |
var fs = require('fs'); | |
var jade = require('jade'); | |
var juice = require('juice'); |
/** | |
* validates and parses ids. optionally accepts multi-ids (comma separated integer ids) | |
*/ | |
var validator = require('validator'); | |
var parse = function(ids, multiple) { | |
if (!ids) { | |
return false; |
var convertDegToRad = require('./convert-deg-to-rad'); | |
module.exports = function(lat1, lon1, lat2, lon2) { | |
var R = 6371; // Radius of the earth in km | |
var dLat = convertDegToRad(lat2 - lat1); | |
var dLon = convertDegToRad(lon2 - lon1); | |
var a = | |
Math.sin(dLat / 2) * Math.sin(dLat / 2) + | |
Math.cos(convertDegToRad(lat1)) * Math.cos(convertDegToRad(lat2)) * | |
Math.sin(dLon / 2) * Math.sin(dLon / 2) |
module.exports = function(deg) { | |
return deg * (Math.PI / 180); | |
}; |