-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
52 lines (41 loc) · 1.36 KB
/
server.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
var Hapi = require('hapi'),
fs = require('fs'),
Path = require('path'),
Good = require('good'),
Bell = require('bell'),
AuthCookie = require('hapi-auth-cookie'),
server = new Hapi.Server({debug: {request: ['error']}});
server.connection({ port: process.env.PORT });
// serves up views (html template pages)
server.views({
engines: {
html: require('handlebars')
},
path: Path.join(__dirname, 'views')
});
var googleAuthOptions = {
provider: 'google',
password: process.env.ENC_PW, //Password used for encryption
clientId: process.env.CLIENTID,//'YourAppId',
clientSecret: process.env.CLIENTSECRET,//'YourAppSecret',
isSecure: false //means authentication can occur over http
};
var sessionAuthOptions = {
cookie: 'darkCookie',
password: process.env.ENC_PW,
isSecure: false
};
//register plugins with server
server.register([Bell, AuthCookie], function (err) {
if (err) {
throw err; // something bad happened loading the plugin
}
server.auth.strategy('google', 'bell', googleAuthOptions);
server.auth.strategy('session', 'cookie', sessionAuthOptions);
server.auth.default('session'); //if no auth is specified it defaults to checking the session cookie
server.route(require('./js/routes'));
server.start(function () {
console.log('Server running at: ' + server.info.uri);
});
});
module.exports = server;