Commit bfe15b20 authored by Цой Данил's avatar Цой Данил 💬

#1 added index.ts + checkhealth

parent eb4569a2
import express, { Router, Request, Response } from 'express'
export class HealthCheckController {
private router: Router
constructor() {
this.router = express.Router()
this.router.get('/', this.checkHealth)
}
public getRouter = (): Router => {
return this.router
}
private checkHealth = (req: Request, res: Response): void => {
res.send('Server is OK')
}
}
import express, { Express } from "express";
import dotenv from 'dotenv';
import cors from 'cors';
import { HealthCheckController } from "./controllers/healthCheck";
dotenv.config()
......@@ -12,4 +13,19 @@ class App {
this.app.use(express.static('public'))
this.app.use(cors())
}
}
\ No newline at end of file
public init = async(): Promise<void> => {
try{
this.app.use('/health-check', new HealthCheckController().getRouter())
this.app.listen(process.env.APP_PORT, () => {
console.log(`Server is running on port ${process.env.APP_PORT}`)
})
} catch(err: unknown){
console.log(err);
}
}
}
const app = new App();
app.init();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment