Resharper cleanup and fixes and remove useless asp overhead
This commit is contained in:
parent
e0d6a97dca
commit
acb2b25e09
44 changed files with 54 additions and 81 deletions
|
@ -6,11 +6,11 @@ using Microsoft.AspNetCore.Mvc;
|
|||
namespace Geekbot.net.WebApi.Controllers.Commands
|
||||
{
|
||||
[EnableCors("AllowSpecificOrigin")]
|
||||
public class HelpController : Controller
|
||||
public class CommandController : Controller
|
||||
{
|
||||
private readonly CommandService _commands;
|
||||
|
||||
public HelpController(CommandService commands)
|
||||
public CommandController(CommandService commands)
|
||||
{
|
||||
_commands = commands;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace Geekbot.net.WebApi.Controllers.Commands
|
|||
let cmdParamsObj = cmd.Parameters.Select(cmdParam => new CommandParamDto
|
||||
{
|
||||
Summary = cmdParam.Summary,
|
||||
Default = cmdParam.DefaultValue?.ToString() ?? null,
|
||||
Default = cmdParam.DefaultValue?.ToString(),
|
||||
Type = cmdParam.Type?.ToString()
|
||||
})
|
||||
.ToList()
|
||||
|
@ -31,7 +31,7 @@ namespace Geekbot.net.WebApi.Controllers.Commands
|
|||
{
|
||||
Name = cmd.Name,
|
||||
Summary = cmd.Summary,
|
||||
IsAdminCommand = (param.Contains("admin")),
|
||||
IsAdminCommand = param.Contains("admin") || param.Contains("owner"),
|
||||
Aliases = cmd.Aliases.ToArray(),
|
||||
Params = cmdParamsObj
|
||||
}).ToList();
|
|
@ -1,4 +1,5 @@
|
|||
using Geekbot.net.Lib;
|
||||
using System.Globalization;
|
||||
using Geekbot.net.Lib;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
@ -13,7 +14,7 @@ namespace Geekbot.net.WebApi.Controllers.Status
|
|||
var responseBody = new ApiStatusDto
|
||||
{
|
||||
GeekbotVersion = Constants.BotVersion(),
|
||||
ApiVersion = Constants.ApiVersion.ToString(),
|
||||
ApiVersion = Constants.ApiVersion.ToString(CultureInfo.InvariantCulture),
|
||||
Status = "Online"
|
||||
};
|
||||
return Ok(responseBody);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Concurrent;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ namespace Geekbot.net.WebApi.Logging
|
|||
case LogLevel.Critical:
|
||||
_geekbotLogger.Error(LogSource.Api, $"{eventId.Id} - {_categoryName} - {state}", exception);
|
||||
break;
|
||||
case LogLevel.None:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(logLevel));
|
||||
}
|
||||
|
@ -67,6 +69,9 @@ namespace Geekbot.net.WebApi.Logging
|
|||
return NLog.LogLevel.Error;
|
||||
case LogLevel.Critical:
|
||||
return NLog.LogLevel.Fatal;
|
||||
case LogLevel.None:
|
||||
return NLog.LogLevel.Off;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(level));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Database;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using Geekbot.net.WebApi.Logging;
|
||||
|
@ -13,9 +13,10 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
namespace Geekbot.net.WebApi
|
||||
{
|
||||
public class WebApiStartup
|
||||
public static class WebApiStartup
|
||||
{
|
||||
public static void StartWebApi(IGeekbotLogger logger, RunParameters runParameters, CommandService commandService)
|
||||
public static void StartWebApi(IGeekbotLogger logger, RunParameters runParameters, CommandService commandService,
|
||||
DatabaseContext databaseContext)
|
||||
{
|
||||
WebHost.CreateDefaultBuilder()
|
||||
.UseKestrel(options =>
|
||||
|
@ -26,6 +27,7 @@ namespace Geekbot.net.WebApi
|
|||
{
|
||||
services.AddMvc();
|
||||
services.AddSingleton<CommandService>(commandService);
|
||||
services.AddSingleton<DatabaseContext>(databaseContext);
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowSpecificOrigin",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue