-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (39 loc) · 901 Bytes
/
Copy pathindex.js
File metadata and controls
45 lines (39 loc) · 901 Bytes
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
import restify from 'restify';
import mongoose from 'mongoose';
/**
* Create server
* @type {*|Server}
*/
const server = restify.createServer({
name: 'nodejs-mongoose-geospatial',
ignoreTrailingSlash: true
});
/**
* Configure restify plugin
*/
server.use(restify.plugins.bodyParser());
server.use(restify.plugins.queryParser());
server.use(restify.plugins.acceptParser(server.acceptable));
require('dotenv').config({
path: './.env'
});
/**
* Attempt to onnect to DB
* @type {MongooseThenable}
*/
mongoose.connect(process.env.DB_HOST).then(() => {
console.log("Database connection established successfully!");
}, (err) => {
throw err;
});
/**
* Register routers
*/
const router = require("./app/Http/Routes/index");
router.applyRoutes(server);
/**
* Starting server
*/
server.listen(3000, () => {
console.log('%s listening at %s', server.name, server.url);
});