-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (21 loc) · 695 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (21 loc) · 695 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
const express = require("express");
const app = express();
const dotenv = require("dotenv");
const homeRoutes = require("./routes/home");
const connectDB = require('./config/database');
//Load .env file in config folder
dotenv.config({ path: "./config/config.env" }); // load config
connectDB();
//Static Folder
app.use(express.static("public"));
//Using EJS for views
app.set("view engine", "ejs");
//Body Parsing
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
//Setup Routes
app.use("/", homeRoutes);
//Server Running
app.listen(process.env.PORT, () => {
console.log(`Server is running on http://localhost:${process.env.PORT}/, you better catch it!`);
});