Remotely/Server/API/SavedScriptsController.cs
2024-10-21 11:53:41 -07:00

32 lines
761 B
C#

using Microsoft.AspNetCore.Mvc;
using Remotely.Server.Auth;
using Remotely.Server.Services;
using Remotely.Shared.Entities;
namespace Remotely.Server.API;
[Route("api/[controller]")]
[ApiController]
public class SavedScriptsController : ControllerBase
{
private readonly IDataService _dataService;
public SavedScriptsController(IDataService dataService)
{
_dataService = dataService;
}
[ServiceFilter(typeof(ExpiringTokenFilter))]
[HttpGet("{scriptId}")]
public async Task<ActionResult<SavedScript>> GetScript(Guid scriptId)
{
var result = await _dataService.GetSavedScript(scriptId);
if (!result.IsSuccess)
{
return NotFound();
}
return result.Value;
}
}