index.js 719 Bytes
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// server 진입점
import dotenv from "dotenv";
import app from "./app.js";
import appConfig from "./config/app.config.js";
import { sequelize, User } from "./models/index.js";

dotenv.config({
  path: `${
    process.env.NODE_ENV === "production" ? ".env" : ".env.development"
  }`,
});

sequelize
  .sync({ force: true })
  .then(async () => {
    console.log(" DB 연결 성공");
Kim, Chaerin's avatar
.    
Kim, Chaerin committed
17
    await User.create({
Kim, Chaerin's avatar
서버    
Kim, Chaerin committed
18
      id: 9999,
Kim, Chaerin's avatar
.    
Kim, Chaerin committed
19
20
21
22
23
      name: "admin",
      email: "admin",
      password: "admin!",
      gender: 0,
    });
Kim, Chaerin's avatar
Kim, Chaerin committed
24
25
26
27
28
29
30
31

    app.listen(appConfig.port, () => {
      console.log(`Server is running on port ${appConfig.port}`);
    });
  })
  .catch((err) => {
    console.log("연결 실패");
    console.log(err);
Kim, Chaerin's avatar
Kim, Chaerin committed
32
  });