-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
523 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,63 @@ | ||
"use strict"; | ||
|
||
const app = require("../app"); | ||
const models = require('../src/models/index.js'); | ||
const models = require("../src/models/index.js"); | ||
const PORT = process.env.PORT || 3000; // 포트 | ||
const fs = require("fs"); | ||
const { imgsDir } = require("../src/config/staticDirLoc"); | ||
|
||
const { auto } = require("../src/config/sequelizeAuto") | ||
|
||
const oracledb = require("oracledb") | ||
const { auto } = require("../src/config/sequelizeAuto"); | ||
|
||
const oracledb = require("oracledb"); | ||
|
||
app.listen(PORT, async () => { | ||
if (process.env.NODE_ENV == 'development') { // 현재 개발 환경이라면 | ||
oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 | ||
} | ||
|
||
try { | ||
await models.sequelize.sync({force: false, alter: false}); | ||
} catch (err) { | ||
console.log('DB 연결 중 오류 발생: ', err); | ||
process.exit(); | ||
} | ||
|
||
// Find all users | ||
const users = await models.User.findAll(); | ||
console.log(users.every(user => user instanceof models.User)); // true | ||
console.log("All users:", JSON.stringify(users, null, 2)); | ||
console.log("All medicines:", JSON.stringify(await models.Medicine.findAll(), null, 2)); | ||
console.log("All likes:", JSON.stringify(await models.Like.findAll(), null, 2)); | ||
console.log("All comments:", JSON.stringify(await models.Comment.findAll(), null, 2)); | ||
console.log("All favorite medicines:", JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2)); | ||
|
||
// // model auto generation test | ||
// auto.run((err) => { | ||
// if (err) throw err; | ||
// console.log(auto.tables); // 생성된 모델 확인 | ||
// }); | ||
|
||
console.log(`Server running on port ${PORT}`); | ||
}); | ||
if (process.env.NODE_ENV == "development") { | ||
// 현재 개발 환경이라면 | ||
oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 | ||
} | ||
|
||
try { | ||
await models.sequelize.sync({ force: false, alter: false }); | ||
} catch (err) { | ||
console.log("DB 연결 중 오류 발생: ", err); | ||
process.exit(); | ||
} | ||
|
||
// Find all users | ||
const users = await models.User.findAll(); | ||
console.log(users.every((user) => user instanceof models.User)); // true | ||
console.log("All users:", JSON.stringify(users, null, 2)); | ||
console.log( | ||
"All medicines:", | ||
JSON.stringify(await models.Medicine.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All likes:", | ||
JSON.stringify(await models.Like.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All comments:", | ||
JSON.stringify(await models.Comment.findAll(), null, 2) | ||
); | ||
console.log( | ||
"All favorite medicines:", | ||
JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2) | ||
); | ||
|
||
// // model auto generation test | ||
// auto.run((err) => { | ||
// if (err) throw err; | ||
// console.log(auto.tables); // 생성된 모델 확인 | ||
// }); | ||
|
||
if (!fs.existsSync(imgsDir)) { // path doesn't exist | ||
try { | ||
fs.mkdirSync(imgsDir); // create directory | ||
console.log("Directory created successfully."); | ||
} catch (error) { | ||
console.error("Error creating directory:", error); | ||
} | ||
} | ||
|
||
console.log(`Server running on port ${PORT}`); | ||
}); |
Oops, something went wrong.