-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
62 lines (52 loc) · 1.79 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require("dotenv").config();
const dotenv = require("dotenv");
const session = require("express-session");
const MySQLStore = require("express-mysql-session")(session);
const express = require("express");
const app = express();
const mysql = require("mysql");
const shelfRouter = require("./router/myShelf/shelfRoute");
const searchBookRouter = require("./router/myShelf/searchBook");
const timerRouter = require("./router/myShelf/timerRoute");
const bookRegisterRouter = require("./router/myShelf/bookRegisterRouter");
const bookDeleteRouter = require("./router/myShelf/bookDeleteRouter");
const clubRouter = require('./router/club/clubRoute');
const postRouter = require('./router/club/postRoute');
const userRouter = require('./router/user/userRoute');
const bodyParser = require("body-parser");
const methodOverride = require("method-override");
//해당 미들웨어가 사이트로 들어오는 모두를 기억.
app.use(
session({
secret: "Hello!",
sotre: new MySQLStore({
host: `${process.env.DB_HOST}`,
port: 3307,
user: `${process.env.DB_USER}`,
password: `${process.env.DB_PASS}`,
database: `${process.env.DB_NAME}`,
}),
resave: false,
saveUninitialized: true,
})
);
app.listen(3000, () => {
console.log("Connected!!!");
});
app.use(express.urlencoded({ extended: true }));
app.use(methodOverride());
app.use(express.json());
app.use((err, req, res, next) => {
const { status } = err;
res.status(status).send("ERROR !! ");
});
app.use("/shelf", shelfRouter);
app.use("/search", searchBookRouter);
app.use("/timer", timerRouter);
app.use("/register", bookRegisterRouter);
app.use("/delete", bookDeleteRouter);
app.use("/club", clubRouter);
app.use("/club/post", postRouter);
app.use("/", userRouter);
app.use("/club", clubRouter);
module.exports = app;