import express from 'express'
import { DeploymentPlatform } from 'types'
import { logInfo } from './log'

export class CiRestApi {

  static start(deploymentPlatform: DeploymentPlatform) {
    const server = express()

    server.use(express.json())

    server.get('/', (req, res) => {
      res.redirect('/status')
    })

    server.get('/status', (req, res) => {
      res.send('Server is live')
    })

    server.listen(deploymentPlatform.ciInternalServerPort, () => {
      logInfo({ message: `[ContainerManagerServer] API is live on port ${deploymentPlatform.ciInternalServerPort}`})
    })
  }

}
