This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (44 loc) · 1.66 KB
/
index.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
'use strict';
var express = require('express');
var kraken = require('kraken-js');
var options;
var app;
/*
* Create and configure application. Also exports application instance for use by tests.
* See https://github.com/krakenjs/kraken-js#options for additional configuration options.
*/
options = {
onconfig: function(config, next) {
var twilio = require('./lib/twilio');
twilio.initialize(config.get('twilio:sid'), config.get('twilio:token'));
var mongoose = require('./lib/mongoose');
mongoose.initialize({url: config.get('mongoose:url')});
var FB = require('fbgraph');
FB.setAppSecret(config.get('facebook:secret'));
/*
* Add any additional config setup or overrides here. `config` is an initialized
* `confit` (https://github.com/krakenjs/confit/) configuration object.
*/
next(null, config);
}
};
app = module.exports = express();
app.use(kraken(options));
app.on('start', function() {
console.log('Application ready to serve requests.');
console.log('Environment: %s', app.kraken.get('env:env'));
});
app.on('middleware:after:session', function(eventargs) {
var FB_ID = app.kraken.get('facebook:id');
var FB_SECRET = app.kraken.get('facebook:secret');
var FB_URL_CALLBACK = app.kraken.get('facebook:url');
require('./lib/passport').initialize(FB_ID, FB_SECRET, FB_URL_CALLBACK, app);
});
app.on('middleware:after:static', function(eventargs) {
var serve = require('serve-static')(app.kraken.get('static:img'));
app.use('/img', serve);
serve = require('serve-static')(app.kraken.get('static:css'));
app.use('/css', serve);
serve = require('serve-static')(app.kraken.get('static:js'));
app.use('/js', serve);
});