-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.ts
42 lines (33 loc) · 1.01 KB
/
auth.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
39
40
41
42
import express from "express"
import cors from "cors"
import { connection } from "./portfolio/db/portfoliodb"
import { AuthRouter } from "./portfolio/auth/routes"
import { PORTFOLIO_AUTH_PORT } from "./portfolio/utils/constants"
import cookieParser from "cookie-parser"
//! 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_AUTH_PORT
//TODO: Configure CORS
app.use(cors())
//TODO: Configure body parser
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
//TODO: Configure cookie parser
app.use(cookieParser())
//? Auth routes
app.use("/auth", AuthRouter)
//TODO: Listen to Auth Server connections on PORT
app.listen(PORT, () => {
console.log(
`Portfolio-CMS: AUTH-Server running successfully on http://localhost:${PORT}`
)
})