Skip to content

Commit

Permalink
feat(support): connect db
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Apr 4, 2024
1 parent f10c096 commit 44c5e20
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "module-alias/register"

import express from "express"

import { infraService } from "@common/index"
import { infraService, sequelize } from "@common/index"
import { useSharedMiddleware } from "@common/middleware"
import { config } from "@root/config/config"
import logger from "@root/logger/logger"
Expand All @@ -18,11 +18,23 @@ infraService.pollMessages()

useSharedMiddleware(app)

// TODO: prefix under infra
// FormSG Backend handler routes
app.use("/", v2Router)
app.use("/v2/ping", (req, res) => res.status(200).send("Ok"))

app.listen(PORT, () => {
logger.info(`Infra container started on port ${PORT}`)
})
sequelize
.authenticate()
.then(() => {
logger.info(
"Connection to db has been established successfully on support service."
)
app.listen(PORT, () => {
logger.info(`Infra container started on port ${PORT}`)
})
})
.catch((err) => {
logger.error(`Unable to connect to the database: ${err}`)

// If we cannot connect to the db, report an error using status code
// And gracefully shut down the application since we can't serve client
process.exit(1)
})

0 comments on commit 44c5e20

Please sign in to comment.