-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (45 loc) · 1.44 KB
/
app.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
const express = require('express')
const app = express();
require('dotenv').config()
const Sentry = require('@sentry/node');
const Tracing = require("@sentry/tracing");
const Router = require('./routes/authroute')
const postRouter = require('./routes/postroute')
const mongooseConnection = require('./connection/mongodb');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
Sentry.init({
dsn:process.env.SENTRY_DSN,
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// enable Express.js middleware tracing
new Tracing.Integrations.Express({ app }),
],
tracesSampleRate: 1.0,
});
app.use(Sentry.Handlers.requestHandler());
// TracingHandler creates a trace for every incoming request
app.use(Sentry.Handlers.tracingHandler());
// All controllers should live here
app.get("/", function rootHandler(req, res) {
res.end("Hello world!");
});
app.use(Sentry.Handlers.errorHandler());
app.use(function onError(err, req, res, next) {
res.statusCode = 500;
res.end(res.sentry + "\n");
});
mongooseConnection()
app.get('/',(req,res)=>{
res.send(`Connected to server on Portno :${PORT}`)
})
app.use('/api',Router)
app.use('/api/post',postRouter)
const PORT = process.env.PORT || 8080
app.listen(PORT,(err,res)=>{
if(err) throw error;
console.log(`Connected to server on Portno :${PORT}`)
})