-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
84 lines (64 loc) · 2.29 KB
/
app.js
File metadata and controls
84 lines (64 loc) · 2.29 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
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------- LOAD LIBRARIES -----------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Loading node modules
var http = require('https');
//var lookup = require('./example-usage/lookup');
// var conn = require('./database');
//var configuration = require('./config/configuration');
// application-wide utilities and assorted candies
//var utilities = require('./includes/utilities');
var redis = require("redis");
// Loading Hapi libraries
var Hapi = require('hapi');
/*
// exception handling
process.on('exit', function () {
console.log(process.env.NODE_ENV + 'About to exit.');
});
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err.message + '-' + err.stack);
});
*/
var http = new Hapi.Server('localhost', 8000);
// Start redis connection
// redisClient = redis.createClient('6379', '127.0.0.1');
// redisClient.select('10', function(err) { if(err) console.log(err); });
// Add the API routes and wait until onions are going pink.:P
http.route(
{
method: 'GET',
path: '/{path*}',
handler: {
directory: { path: './app', listing: false, index: true }
}
}
);
/*
http.addRoutes([
{
method: 'GET',
path: '/suggestion/key/{key}/value/{value}',
config: {
handler: lookup.getSuggestions,
cache: {
expiresIn: 2000000,
staleIn: 10000,
staleTimeout: 500,
mode: 'client+server'
}
}
},
{
method: 'POST',
path: '/suggestion/key/{key}/value/{value}',
config: {
handler: lookup.saveSuggestion
}
}
]);
*/
// Ignite the server
http.start(function () {
console.log('Server started at: ' + http.info.uri);
});