-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5 [feat] DB연결시 관리자 유저가 없을경우 생성하도록 설정
- Loading branch information
Showing
1 changed file
with
13 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
const express = require('express'); | ||
const connectDB = require('./config/db'); | ||
const api = require('./api/routers/index'); | ||
const express = require("express"); | ||
const connectDB = require("./config/db"); | ||
const api = require("./api/routers/index"); | ||
const { createInitAdmin } = require("./api/controllers/userController"); | ||
|
||
const app = express(); | ||
|
||
app.use(express.json()); | ||
|
||
app.use('/api', api); | ||
app.use("/api", api); | ||
|
||
const { swaggerUi, specs } = require("./swagger/swagger") | ||
const { swaggerUi, specs } = require("./swagger/swagger"); | ||
|
||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)) | ||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)); | ||
|
||
connectDB().then(() => { | ||
connectDB() | ||
.then(async () => { | ||
await createInitAdmin(); | ||
const PORT = process.env.PORT || 3000; | ||
app.listen(PORT, () => console.log(`Server started on port ${PORT}`)); | ||
}).catch((err) => { | ||
}) | ||
.catch((err) => { | ||
console.error("Database connection failed", err); | ||
process.exit(1); | ||
}); | ||
}); |