using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; using AyaNova.Util; using AyaNova.Biz; using AyaNova.Api.ControllerHelpers; using Microsoft.AspNetCore.Authorization; using System.Threading.Tasks; namespace AyaNova.Api.Controllers { /// /// Meta controller class /// [ApiVersion("8.0")] [Route("api/v{version:apiVersion}/")] [AllowAnonymous] [ApiController] public class ApiMetaController : ControllerBase { private readonly ApiServerState serverState; private readonly ILogger _log; /// /// /// /// /// public ApiMetaController(ILogger logger, ApiServerState apiServerState) { _log = logger; serverState = apiServerState; } /// /// AyaNova API documentation and manual /// /// [HttpGet] public async Task Index() { var errorBlock = string.Empty; if (serverState.IsSystemLocked) { errorBlock = $@"

SERVER ERROR

{serverState.Reason}

"; } var resp = $@" AyaNova server
{errorBlock}

{AyaNovaVersion.FullNameAndVersion}

AyaNova App

AyaNova manual

API explorer

Email AyaNova support

{await TranslationBiz.GetDefaultTranslationAsync("HelpLicense")}

{AyaNova.Core.License.LicenseInfo}

Schema version

{AySchema.currentSchema.ToString()}

Active techs

{await UserBiz.ActiveCountAsync()}

Server time

{DateUtil.ServerDateTimeString(System.DateTime.UtcNow)}
{TimeZoneInfo.Local.Id}

Server logs

{ServerBootConfig.AYANOVA_LOG_PATH}
"; return new ContentResult { ContentType = "text/html", StatusCode = 200, Content = resp }; } #region sigtest script /*

SIGTEST - 1

This is the signature header

Your browser does not support signing
The following browsers are supported:
IE 9.0 +, FIREFOX 3.0 +, SAFARI 3.0 +, CHROME 3.0 +, OPERA 10.0 +, IPAD 1.0 +, IPHONE 1.0 +, ANDROID 1.0 +

{SigScript()} private string SigScript(){ return @""; } */ #endregion /// /// Get API server info for general display /// /// API server info [HttpGet("ServerInfo")] public ActionResult ServerInfo() { return Ok(new { data = new { ServerVersion = AyaNovaVersion.FullNameAndVersion, DBSchemaVersion = AySchema.currentSchema, ServerLocalTime = DateUtil.ServerDateTimeString(System.DateTime.UtcNow), ServerTimeZone = TimeZoneInfo.Local.Id, License = AyaNova.Core.License.LicenseInfoAsJson } }); } #if (DEBUG) /// /// Get build mode of server, used for automated testing purposes /// /// "DEBUG" or "RELEASE" [HttpGet("BuildMode")] public ActionResult BuildMode() { return Ok(new { data = new { BuildMode = "DEBUG" } }); } #else /// /// Get build mode of server, used for automated testing purposes /// /// "DEBUG" or "RELEASE" [HttpGet("BuildMode")] public ActionResult BuildMode() { return Ok(new { data = new { BuildMode = "RELEASE" } }); } #endif } }