-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (39 loc) · 1003 Bytes
/
Copy pathindex.js
File metadata and controls
43 lines (39 loc) · 1003 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
31
32
33
34
35
36
37
38
39
40
41
42
43
const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');
const uh = require('./userhandle');
const th = require('./todohandle');
const cookieParser = require('cookie-parser');
const port = process.env.PORT || 4000;
const app = express();
require('dotenv').config({ path: `${__dirname}/.env` });
app.use('/todos', express.static(__dirname + '/public'));
mongoose
.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
})
.then(() => {
console.log('Connected');
})
.catch((err) => {
console.log(err);
});
app.use(
cors({
origin: ['http://localhost:5500', 'https://rafsanamin.epizy.com'],
credentials: true,
})
);
app.set('trust proxy', 1);
app.use(cookieParser());
app.use(express.json());
app.use('/auth', uh);
app.use('/todo', th);
app.get('/', (req, res) => {
res.send(`Hi`);
});
app.listen(port, () => {
console.log(`App listening at ${port}`);
});