-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
58 lines (37 loc) · 1.12 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const path = require('path');
const express = require('express');
const dotenv = require('dotenv');
const cors = require('cors');
const connectDB = require('./config/db');
// Adding DataDog Monitoring for Trial
var dd_options = {
'response_code' : true,
'tags' : ['app:my_app']
};
var connect_datadog = require('connect-datadog')(dd_options);
var StatsD = require('hot-shots');
var dogstatsd = new StatsD();
// Load environment variables
dotenv.config({
path: './config/config.env'
});
// Connect with Mongo database
connectDB();
// Create Express instance
const app = express();
// Middleware
// Body-Parser
app.use(express.json());
// Enable CORS
app.use(cors());
// data-dog middleware
app.use(connect_datadog);
// Routing
app.use('/api/v1/beaches', require('./routes/beaches'));
app.use('/api/v1/get-trips', require('./routes/get-trips'));
app.use('/api/v1/get-weather', require('./routes/get-weather'));
const PORT = process.env.PORT || 5005;
app.listen(PORT, () => {
console.log(`Beach-Me Server up and running in ${process.env.NODE_ENV}, on Port: ${PORT}`)
});
dogstatsd.increment('page.views');