express-nodejs-app/src/app.ts
Sambo Chea 03458fe00c
Some checks failed
continuous-integration/drone/push Build is failing
Add express server from module and updated the server and config
2021-09-16 18:14:49 +07:00

29 lines
686 B
TypeScript

// app config
import "./dotenv"
import { createServer } from "http"
import { SERVER_PORT } from "./app.config"
import { info } from "@cubetiq/ts-common/dist/log"
import application from "./server"
// get current host id
const hostId = `${require("os").hostname()}#${process.pid}`
const startedAt = new Date()
const app = application.instance
const httpServer = createServer(app)
info(
`Application server running on: ${hostId} at port: ${SERVER_PORT} and started at: ${startedAt}`
)
httpServer.listen(SERVER_PORT)
app.get("/info", (req, res) => {
res.type("json")
res.send({
startedAt,
message: `Instance id: ${hostId}`,
status: "OK",
})
})