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

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({
우지원's avatar
e    
우지원 committed
18
      id: "9999",
Kim, Chaerin's avatar
.    
Kim, Chaerin committed
19
20
21
22
      name: "admin",
      email: "admin",
      password: "admin!",
      gender: 0,
우지원's avatar
0728    
우지원 committed
23
      roomNumber : ["1234567abc","abc7654321"],
Kim, Chaerin's avatar
.    
Kim, Chaerin committed
24
    });
Kim, Chaerin's avatar
Kim, Chaerin committed
25

우지원's avatar
e    
우지원 committed
26
    await Room.create({
우지원's avatar
0728    
우지원 committed
27
      id: "1234567abc",
우지원's avatar
e    
우지원 committed
28
      name: "room",
우지원's avatar
우지원 committed
29
      owner: 8888,
우지원's avatar
   
우지원 committed
30
      member: [8888],
우지원's avatar
0802    
우지원 committed
31
      profileimg: "ef0930f6be18ce73380d952337a6de1f",
우지원's avatar
0728    
우지원 committed
32
33
34
35
36
37
38
    });

    await Room.create({
      id: "abc7654321",
      name: "room1",
      owner: 9999,
      member: [9999],
우지원's avatar
0802    
우지원 committed
39
      profileimg: "ef0930f6be18ce73380d952337a6de1f",
우지원's avatar
e    
우지원 committed
40
41
    });

Kim, Chaerin's avatar
Kim, Chaerin committed
42
43
44
45
46
47
48
    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
49
  });