switch to redis-url
This commit is contained in:
parent
89af70f042
commit
ef948ec46c
13
app.js
13
app.js
@ -1,7 +1,12 @@
|
|||||||
var express = require('express')
|
var express = require('express')
|
||||||
, app = express.createServer()
|
, app = express.createServer()
|
||||||
, nodemailer = require('nodemailer')
|
, nodemailer = require('nodemailer')
|
||||||
, redis = require('redis')
|
|
||||||
|
var redis;
|
||||||
|
if (process.env.NODE_ENV == 'production')
|
||||||
|
redis = require('redis-url').connect(process.env.REDISTOGO_URL);
|
||||||
|
else
|
||||||
|
redis = require('redis-url').connect();
|
||||||
|
|
||||||
// Express config
|
// Express config
|
||||||
app.set('views', __dirname + '/views');
|
app.set('views', __dirname + '/views');
|
||||||
@ -30,14 +35,12 @@ app.get('/', function(req, res) {
|
|||||||
app.post('/text', function(req, res) {
|
app.post('/text', function(req, res) {
|
||||||
var keystr = req.connection.remoteAddress + '_' + dateStr();
|
var keystr = req.connection.remoteAddress + '_' + dateStr();
|
||||||
|
|
||||||
var rclient = redis.createClient();
|
redis.incr(keystr, function(err, num) {
|
||||||
rclient.incr(keystr, function(err, num) {
|
|
||||||
rclient.quit();
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
res.send({success:false,msg:'Could not validate IP quota.'});
|
res.send({success:false,msg:'Could not validate IP quota.'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num < 51) {
|
if (num < 51) {
|
||||||
sendText(req.body.number, req.body.msg, function(err) {
|
sendText(req.body.number, req.body.msg, function(err) {
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"express": "2.5.2"
|
"express": "2.5.2"
|
||||||
, "jade": "0.14.2"
|
, "jade": "0.14.2"
|
||||||
, "nodemailer": "latest"
|
, "nodemailer": "latest"
|
||||||
, "redis": "latest"
|
, "redis-url": "latest"
|
||||||
}
|
}
|
||||||
, "devDependencies": {
|
, "devDependencies": {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user