-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (33 loc) · 1.17 KB
/
index.js
File metadata and controls
39 lines (33 loc) · 1.17 KB
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
import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import dotenv from "dotenv";
import path from 'path';
import { fileURLToPath } from "url";
// Routes
import AuthRoute from './Routes/AuthRoute.js'
import IncidentRoute from './Routes/IncidentfilterRoute.js';
const app = express();
// Middleware
app.use(bodyParser.json({ limit: "30mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
dotenv.config();
mongoose
.connect(process.env.MONGO_DB, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() =>
app.listen(process.env.PORT, () =>
console.log(`Listening at ${process.env.PORT}`)
)
)
.catch((error) => console.log(error));
app.use('/auth', AuthRoute)
app.use('/api', IncidentRoute);
app.get('/filter', (req, res) => {
const __filename = fileURLToPath(import.meta.url); // Get current file path
const __dirname = path.dirname(__filename); // Get the directory path of current file
const filePath = path.join(__dirname, 'view', 'incidentfiltering.html'); // Build absolute path to the file
res.sendFile(filePath); // Send the file to the client
});