-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver-routes.js
More file actions
77 lines (61 loc) · 1.64 KB
/
Copy pathserver-routes.js
File metadata and controls
77 lines (61 loc) · 1.64 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
var Hapi = require("hapi");
var mongodb =require ('mongodb')
var dbRunners = "mongodb://maryams:mary1900@linus.mongohq.com:10085/dbRunners"
var mongoClient= mongodb.MongoClient;
var server = Hapi.createServer('0.0.0.0', 8080);
server.views({
engines: {
jade: require("jade")
},
path: "./views"
});
/*var myData;
mongoClient.connect(dbRunners, function(err, db) {
if (err) console.log(err);
var collection = db.collection('articles');
collection.find().sort({ "id": -1}).toArray(function (err, docs) {
myData = docs
})});*/
server.route({
method: 'GET',
path: '/Jade',
config: {
handler: function (request, reply) {
reply.view('view-home');
}}
});
/*
server.route({
method: 'GET',
path: '/articles/new',
config: {
handler: function (request, reply) {
reply('new entry here');
},
}
});
server.route({
method: 'GET',
path: '/articles/{id}',
config: {
handler: function (request, reply) {
reply('You asked for the page ' + request.params.id);
},
validate: {
params: {
id: Joi.string().required()
}
}
}
})
server.route({
method: 'GET',
path: '/articles/{id}/edit',
config: {
handler: function (request, reply) {
reply('You want to edit ' + request.params.id +', ja? ');
},
}
});
*/
server.start();