-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (33 loc) · 875 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (33 loc) · 875 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
33
34
import express from "express";
import bodyParser from "body-parser";
import session from "express-session";
import dotenv from "dotenv";
import http from "http";
import routes from "./routes";
import path from "path";
import flash from "connect-flash";
dotenv.config();
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(flash());
app.use(
session({
secret: "2341",
key: "12",
resave: false,
saveUninitialized: false
})
);
app.use((req, res, next) => {
res.locals.flashes = req.flash();
next();
});
app.use(routes);
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");
app.use(express.static(path.join(__dirname, "public")));
const port = process.env.PORT || 3000;
http.createServer(app).listen(port, () => {
console.info(`Server running on port ${port}`);
});