-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
26 lines (20 loc) · 833 Bytes
/
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
require('dotenv').config();
const express = require('express'); //creating express application
const cors = require("cors");
const app = express();
const corsOptions = {
origin: "*"
};
const userRouter = require('./api/users/user.router'); //importing user.router //initializing express application
app.use(express.json()); //converting .JSON object into JS object
app.use(cors(corsOptions));
// app.get('/api', (req, res)=>{ //This callback method will take request and response object
// res.json({
// success:1,
// message: 'This os rest api working'
// });
// });
app.use('/api', userRouter); //if any request comes we pass it to the userRouter route
app.listen(process.env.APP_PORT, () => {
console.log('Server up and running on port: ', process.env.APP_PORT);
});