Skip to content

Commit

Permalink
#5 [feat] DB연결시 관리자 유저가 없을경우 생성하도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
OH-GITAEK committed May 27, 2024
1 parent bc56a9e commit 0046fa4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app.js
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);
});
});

0 comments on commit 0046fa4

Please sign in to comment.