-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (26 loc) · 872 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
29
30
31
32
33
34
35
36
37
38
39
40
const connectToMongoose = require('./db')
var cors = require('cors')
connectToMongoose();
const dotenv = require("dotenv");
dotenv.config();
const express = require('express')
const app = express()
const port = process.env.PORT || 5000;
const path = require('path');
app.use(cors())
app.use(express.json())
// agr request body ko use krna h toh ya json me kam krna ho toh
//Availabe rotues
app.use('/api/auth', require('./routes/auth'));
app.use('/api/note', require('./routes/note'));
if (process.env.NODE_ENV == "production") {
app.use(express.static(path.join("./inotebook/build")));
// app.get("*", function (_, res) {
// res.sendFile(
// path.resolve(__dirname, 'inotebook', 'build', 'index.html'),
// )
// })
}
app.listen(port, () => {
console.log(`Example app listening on port http://localhost:${port}`)
})