-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
75 lines (67 loc) · 2.22 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var application_root = __dirname;
var express = require('express');
var cons = require('consolidate');
var handlebars = require('handlebars');
var path = require('path');
var dropboxdb = require('dropboxdb');
// var TwilioClient = require('twilio').Client;
// var ACC_SID = 'AC38d0b53961a6faa172c8b300a9fb2e9e';
// var AUTH_TOKEN = 'c16bb6d833c7e6bedb74009d0eb02674';
var HOST = 'localhost';
var sys = require('sys');
// var client = new TwilioClient(ACC_SID, AUTH_TOKEN, HOST);
// var Twiml = require('twilio').Twiml;
// var phone = client.getPhoneNumber('+16096812980');
var app = express();
dropboxdb.connect({
key: 'an9xqcu05kyjbir',
secret: 'xgtmq9wcshbt7lh'
});
app.configure(function() {
app.use(express.bodyParser());
app.use(express.static(path.join(application_root, "public")));
app.engine('html', cons.handlebars);
app.set('views', path.join(application_root, "views"));
app.set('view engine', 'html');
app.set('application_root', application_root);
});
handlebars.loadPartial = function (name) {
var partial = handlebars.partials[name];
if (typeof partial === "string") {
partial = handlebars.compile(partial);
handlebars.partials[name] = partial;
}
return partial;
};
handlebars.registerHelper("block", function (name, options) {
/* Look for partial by name. */
var partial = handlebars.loadPartial(name) || options.fn;
return partial(this, { data : options.hash });
});
// phone.setup(function(){
// phone.on('incomingSms', function(reqParams, res) {
// console.log(reqParams);
// dropboxdb.find("phones",
// function(row) {
// return row.phone === reqParams.From;
// },
// function(rows) {
// rows.forEach(function(row) {
// dropboxdb.insert(
// "chatbox-" + row.chat,
// {author: row.name, msg: reqParams.Body},
// function(err, stat) {
// if(err) {
// console.log(err);
// }
// }
// );
// });
// });
// });
// });
require('./controllers/misc')(app);
require('./controllers/api')(app);
// require('./phone')(dropboxdb, phone);
app.listen(3000);
console.log("Listening on port 3000.");