This repository was archived by the owner on Jun 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
90 lines (73 loc) · 1.46 KB
/
server.js
File metadata and controls
90 lines (73 loc) · 1.46 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var Hapi = require('hapi'),
server = new Hapi.Server(),
glob = require('glob');
// Load configfile
var config = require('./config.js');
var mopidy = require('./modules/mopidyCom.js');
mopidy.init();
// Configure hapi server
server.connection({ port: config.main.port });
var socket;
server.register(require('hapio'), function(err) {
if (err) throw err;
socket = require('./modules/socketLogic.js');
socket.init(server.plugins.hapio.io);
});
// View engine
server.register(require('vision'), function (err) {
if (err) {
throw err;
}
server.views({
engines: {
jade: require('jade')
},
relativeTo: __dirname,
path: 'views',
context: {
website: 'Livid'
}
});
});
// Static files
server.register(require('inert'), function (err) {
if (err) {
throw err;
}
// Static files
server.route({
method: 'GET',
path: '/public/{param*}',
handler: {
directory: {
path: 'public'
}
}
});
});
/*
* Set routes
*/
// root
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply.view('index', {
title: 'Index'
})
}
});
// History page
server.route({
method: 'GET',
path: '/history',
handler: function (request, reply) {
reply.view('history', {
title: 'History'
})
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});