-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (32 loc) · 943 Bytes
/
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
var Koa = require('koa');
var serve = require('koa-static');
var connections = require('./config/connections');
var url = connections.hostname + ':' + connections.port;
/**
* Connection to database
*/
var mongoose = require('mongoose');
var dbConnection = mongoose.connect('mongodb://hackfestarun:[email protected]:21016/hackfestarun',
function (err) {
if (err) {
console.log('Connection Error,err');
}
else {
console.log('Connection Successful');
}
});
var app = Koa();
app.use(serve(__dirname + '/public'));
/**
* Routings
*/
var routing = require('./routes/routes');
app.use(routing.routes());
app.use(routing.allowedMethods());
var entry = require('./model/entrySchema');
/**
* Starts the server and push users to the public page.
*/
app.listen(connections.port);
console.log('Serving on ' + url + ' in ' + connections.env);
module.exports = app;