-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (24 loc) · 892 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (24 loc) · 892 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
"use strict";
// Imported the necessary modules.
const Path = require("path");
const Express = require("express");
const BodyParser = require("body-parser");
const ErrorController = require("./controllers/error");
// Created an app.
const App = Express();
App.set("view engine", "ejs");
App.set("views", "views");
const AdminRoutes = require("./routes/admin");
const ShopRoute = require("./routes/shop");
// Used the "body-parser" module.
App.use(BodyParser.urlencoded({extended: false}));
App.use(Express.static(Path.join(__dirname, "public")));
// Used my created modules.
App.use("/admin", AdminRoutes.router); // Can determine what segment should the paths in the module be in.
App.use(ShopRoute);
// Added a 404 status page.
App.use(ErrorController.Get404);
// Initiated the server.
App.listen(3001, () => {
console.log("Server is running on URL http://localhost:3001");
});