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

export class CiRestApi {

  static start(platformConfig: PlatformConfig) {
    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(platformConfig.ciInternalServerPort, () => {
      logInfo({ message: `[ContainerManagerServer] API is live on port ${platformConfig.ciInternalServerPort}`})
    })
  }

}
