-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
17 lines (15 loc) · 701 Bytes
/
app.js
File metadata and controls
17 lines (15 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const express = require("express");
const app = express();
const path = require("path");
const { config } = require("dotenv");
const appRoutes = require("./routes/app-routes");
const errorHandlingMiddleware = require("./middleware/errorHandlingMiddleware");
config();
app.use(express.static(path.join(__dirname, "public"))); //? /user-files/<file-name>
app.use("/public", express.static(path.join(__dirname, "public"))); //? /public/user-files/<file-name>
app.use(appRoutes);
app.use(errorHandlingMiddleware);
app.listen(process.env.PORT, (err) => {
if (err) return console.log("Error occurred while starting the server.");
return console.log(`${process.env.PROJECT_NAME} server started.`);
});