-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (32 loc) · 1.04 KB
/
app.js
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
const express = require('express');
const app = express();
const cookieParser = require("cookie-parser");
const path = require("path");
const indexRouter = require("./routes/index")
const ownersRouter = require("./routes/ownersRouter")
const usersRouter = require("./routes/usersRouter")
const productsRouter = require("./routes/productsRouter")
const db = require("./config/mongoose-connection")
const expressSession = require("express-session")
const flash = require("connect-flash")
require("dotenv").config();
app.use(express.json());
app.use(express.urlencoded({ extended: true}));
app.use(cookieParser());
app.use(
expressSession({
resave:false,
saveUninitialized: false,
secret: process.env.JWT_KEY,
})
)
app.use(flash());
app.use(express.static(path.join(__dirname, "public")));
app.set("view engine", "ejs");
app.use("/",indexRouter);
app.use ("/owners", ownersRouter);
app.use ("/users", usersRouter);
app.use("/products", productsRouter);
app.listen(3000), () => {
console.log("server running port 3000")
};