-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (24 loc) · 874 Bytes
/
index.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
const express = require('express');
const userRoutes = require('./routes/userRoute');
const newsRoutes = require('./routes/newsRoute');
const priceRoutes = require('./routes/priceRoute');
const marketRoutes = require('./routes/marketRoute');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.use("/",userRoutes);
app.use("/articles",newsRoutes);
app.use("/price",priceRoutes);
app.use("/market",marketRoutes);
// Handling Errors
app.use((err, req, res, next) => {
// console.log(err);
err.statusCode = err.statusCode || 500;
err.message = err.message || "Internal server error";
res.status(err.statusCode).json({
message: err.message,
});
});
app.listen(PORT, () =>console.log(`Server running on port: http://localhost:${PORT}`));