-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (23 loc) · 732 Bytes
/
app.js
File metadata and controls
30 lines (23 loc) · 732 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
require("dotenv").config({ path: "./.env" });
const express = require(`express`);
const app = express();
require("./models/dbconfig").dbconnection();
const usersRouter = require(`./routes/userRoute`);
// logger for a route hit information in the backend
const logger = require(`morgan`);
app.use(logger('tiny'));
// body parsers
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// make base uri of api
app.use(`/`, usersRouter);
// unknown routes
app.all("*", function(req, res, next) {
res.status(404).json({
success: false,
message: `${req.url} Not found `
});
})
app.listen(process.env.PORT, () => {
console.log(`server started running on port ${process.env.PORT}`);
})