-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
36 lines (31 loc) · 927 Bytes
/
index.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
const express = require("express");
const path = require("path");
const morgan = require("morgan");
const nunjucks = require("nunjucks");
const { sequelize } = require("./models");
const app = express();
app.set("port", process.env.PORT || 3001);
app.set("view engine", "html");
nunjucks.configure("views", {
express: app,
watch: true,
});
sequelize
.sync({ force: false })
.then(() => {
console.log("데이터베이스 연결 성공");
})
.catch((err) => {
console.error(err);
});
app.use(morgan("dev"));
app.use(express.static(path.join(__dirname, "public")));
app.use(express.json());
app.use(express.urlencoded({ limit: "50mb", extended: false }));
//라우터
const imageRouter = require("./routes/Images");
app.use("/uploads", express.static("uploads"));
app.use("/api/image", imageRouter);
app.listen(app.get("port"), () => {
console.log(app.get("port"), "번 포트에서 대기 중");
});