package com.dowstats.controllers

import com.dowstats.data.entities.Mod
import com.dowstats.data.repositories.ModRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import jakarta.servlet.http.HttpServletRequest
import org.springframework.web.bind.annotation.PathVariable


@RestController
@RequestMapping("api/v1/mods")
@EnableWebSecurity
class ModVersionsController @Autowired constructor(
    val modRepository: ModRepository
) {

    @GetMapping
    fun getModVersions(): List<Mod> {
        return modRepository.findAll().toList()
    }

    @GetMapping("/{mod}")
    fun getModById(@PathVariable mod: Long): Mod {
        return modRepository.findById(mod).get()
    }
}
