-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (38 loc) · 1.23 KB
/
Copy pathapp.js
File metadata and controls
52 lines (38 loc) · 1.23 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
40
41
42
43
44
45
46
47
48
49
50
51
52
// Packages and modules
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
const hbs = require("hbs");
// Routers
var indexRouter = require("./routes/index");
var dashboardRouter = require("./routes/dashboard");
var app = express();
// Define paths for Express
const publicPath = path.join(__dirname, "public");
const viewsPath = path.join(__dirname, "/templates/views");
const partialsPath = path.join(__dirname, "/templates/partials");
// Setup HBS and EJS engine and views locationscomm
app.set("view engine", "ejs");
app.set("views", viewsPath);
hbs.registerPartials(partialsPath);
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(publicPath));
// Ruta de index
app.use("/", indexRouter);
// Ruta de dashboard
app.use("/dashboard", dashboardRouter);
// app.post("/login",
// passport.authenticate("local", { failureRedirect: "/login" }),
// function (req, res) {
// res.redirect("/dashboard");
// });
app.get("*", (req, res) => {
res.render("not_found_404");
});
var port = (process.env.PORT || 8080);
app.listen(port);
module.exports = app;