-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.ts
38 lines (30 loc) · 934 Bytes
/
admin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import express from "express"
import cors from "cors"
import { connection } from "./portfolio/db/portfoliodb"
import { AdminRouter } from "./portfolio/admin/routes"
import { PORTFOLIO_ADMIN_PORT } from "./portfolio/utils/constants"
//! Error in connection
connection.on("error", () => {
console.log("MongoDB connection error")
})
//? Connection established
connection.on("connected", function () {
console.log("MongoDB connected successfully")
})
//? Initialize Express app
const app = express()
// TODO: Set API port
const PORT = process.env.PORT || PORTFOLIO_ADMIN_PORT
//TODO: Configure CORS
app.use(cors())
//TODO: Configure body parser
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
//? Admin routes
app.use("/admin", AdminRouter)
//TODO: Listen from API Server port
app.listen(PORT, () => {
console.log(
`Portfolio-CMS: Admin-Server running successfully on http://localhost:${PORT}`
)
})