mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-08 19:49:36 +02:00
make backend for my site
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@page
|
||||
@model yaflay.ru.MyFeature.Pages.Page1Model
|
||||
@model yawaflua.ru.MyFeature.Pages.Page1Model
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace yaflay.ru.MyFeature.Pages
|
||||
namespace yawaflua.ru.MyFeature.Pages
|
||||
{
|
||||
public class Page1Model : PageModel
|
||||
{
|
||||
|
||||
@@ -3,12 +3,12 @@ using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using yaflay.ru.Database.Tables;
|
||||
using yaflay.ru.Models;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using yawaflua.ru.Database.Tables;
|
||||
using yawaflua.ru.Models;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
|
||||
|
||||
namespace yaflay.ru.Auth;
|
||||
namespace yawaflua.ru.Auth;
|
||||
|
||||
public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
@@ -29,7 +29,9 @@ public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOp
|
||||
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var apiKeyHeaderValues))
|
||||
if (!Request.Host.Value.StartsWith("api"))
|
||||
return AuthenticateResult.NoResult();
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var apiKeyHeaderValues) && Request.Host.Value.StartsWith("api"))
|
||||
return AuthenticateResult.Fail("API Key was not provided.");
|
||||
|
||||
string? providedApiKey = apiKeyHeaderValues.FirstOrDefault()?.Replace("Bearer ", "");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace yaflay.ru.Auth
|
||||
namespace yawaflua.ru.Auth
|
||||
{
|
||||
|
||||
public enum ApiKeyTypes
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using yaflay.ru.Auth;
|
||||
using yaflay.ru.Database.Tables;
|
||||
using yawaflua.ru.Auth;
|
||||
using yawaflua.ru.Database.Tables;
|
||||
using yawaflua.ru.Utilities;
|
||||
using api.yawaflua.ru.Models.Tables;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace yaflay.ru.Controllers
|
||||
namespace yawaflua.ru.Controllers
|
||||
{
|
||||
[Route("")]
|
||||
public class HomeController : Controller
|
||||
[Route("api/")]
|
||||
public class ApiController : Controller
|
||||
{
|
||||
private IMemoryCache cache;
|
||||
private AppDbContext ctx;
|
||||
public HomeController(IMemoryCache cache, AppDbContext ctx)
|
||||
public ApiController(IMemoryCache cache, AppDbContext ctx)
|
||||
{
|
||||
this.cache = cache;
|
||||
this.ctx = ctx;
|
||||
@@ -29,29 +29,16 @@ namespace yaflay.ru.Controllers
|
||||
public string watermelon { get; set; }
|
||||
public string discordId { get; set; }
|
||||
public ApiKeyTypes type { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public class commentBody
|
||||
{
|
||||
public string text { get; set; }
|
||||
public string sender { get; set; }
|
||||
}
|
||||
public class articleBody
|
||||
{
|
||||
public string title { get; set; }
|
||||
public string annotation { get; set; }
|
||||
public string text { get; set; }
|
||||
public string image { get; set; }
|
||||
public string author { get; set; }
|
||||
}
|
||||
public class redirectBody
|
||||
{
|
||||
public string url { get; set; }
|
||||
public string uri { get; set; }
|
||||
public string author { get; set; }
|
||||
}
|
||||
|
||||
[HttpGet("api/Index")]
|
||||
|
||||
[HttpGet("Index")]
|
||||
public async Task<IActionResult> getIndexPage()
|
||||
{
|
||||
string? indexPage = cache.Get<string>($"indexPage");
|
||||
@@ -65,11 +52,24 @@ namespace yaflay.ru.Controllers
|
||||
return Ok(indexPage);
|
||||
}
|
||||
|
||||
[HttpPost("api/redirects")]
|
||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
||||
public async Task<IActionResult> createRedirectUri([FromBody]redirectBody body)
|
||||
[HttpGet("Projects")]
|
||||
public async Task<IActionResult> getProjects()
|
||||
{
|
||||
Console.WriteLine("Im here");
|
||||
Projects[] projects = Array.Empty<Projects>();
|
||||
if (cache.TryGetValue("projects", out projects) || ctx.Projects.Any())
|
||||
{
|
||||
projects ??= ctx.Projects.ToArray();
|
||||
cache.Set("projects", (object)projects);
|
||||
}
|
||||
Console.WriteLine(JsonConvert.SerializeObject(projects));
|
||||
return Ok(projects);
|
||||
}
|
||||
|
||||
[HttpPost("redirects")]
|
||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
||||
public async Task<IActionResult> createRedirectUri([FromQuery]string url, [FromQuery] string uri)
|
||||
{
|
||||
Console.WriteLine("url" + body.uri);
|
||||
HttpResponseMessage message;
|
||||
using (var requestMessage =
|
||||
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||
@@ -83,8 +83,8 @@ namespace yaflay.ru.Controllers
|
||||
{
|
||||
Redirects redirects = new()
|
||||
{
|
||||
redirectTo = body.url,
|
||||
uri = body.uri
|
||||
redirectTo = url,
|
||||
uri = uri
|
||||
};
|
||||
await ctx.Redirects.AddAsync(redirects);
|
||||
await ctx.SaveChangesAsync();
|
||||
@@ -95,9 +95,9 @@ namespace yaflay.ru.Controllers
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
[HttpPost("api/Blog")]
|
||||
[HttpPost("Blog")]
|
||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
||||
public async Task<IActionResult> createArticle([FromBody] articleBody body)
|
||||
public async Task<IActionResult> createArticle([FromQuery] string title, [FromQuery] string annotation, [FromQuery] string text, [FromQuery] string image, [FromQuery] string author)
|
||||
{
|
||||
|
||||
HttpResponseMessage message;
|
||||
@@ -109,36 +109,27 @@ namespace yaflay.ru.Controllers
|
||||
}
|
||||
string responseBody = await message.Content.ReadAsStringAsync();
|
||||
JsonNode response = JsonNode.Parse(responseBody);
|
||||
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null )
|
||||
if (response["user"] != null && Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) != null )
|
||||
{
|
||||
try
|
||||
|
||||
Blogs article = new()
|
||||
{
|
||||
Blogs article = new()
|
||||
{
|
||||
Annotation = body.annotation,
|
||||
authorId = response["user"]["id"].ToString(),
|
||||
dateTime = DateTime.Now,
|
||||
ImageUrl = body.image,
|
||||
Text = body.text,
|
||||
Title = body.title,
|
||||
authorNickname = response["user"]["global_name"].ToString()
|
||||
};
|
||||
await ctx.Blogs.AddAsync(article);
|
||||
await ctx.SaveChangesAsync();
|
||||
return Ok(body);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("error: HomeController error");
|
||||
Console.WriteLine("debug: lines: 80-96");
|
||||
Console.WriteLine($"debug: data from site: {body}");
|
||||
Console.WriteLine($"debug: exception: {ex.Message}");
|
||||
return StatusCode(500, body);
|
||||
}
|
||||
Annotation = annotation,
|
||||
authorId = response["user"]["id"].ToString(),
|
||||
dateTime = DateTime.Now,
|
||||
ImageUrl = image,
|
||||
Text = text,
|
||||
Title = title,
|
||||
authorNickname = response["user"]["global_name"].ToString()
|
||||
};
|
||||
await ctx.Blogs.AddAsync(article);
|
||||
await ctx.SaveChangesAsync();
|
||||
return Ok();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unauthorized(body);
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
[HttpGet("logout")]
|
||||
@@ -150,7 +141,7 @@ namespace yaflay.ru.Controllers
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
[HttpGet("api/Blog/{blogId?}/comments")]
|
||||
[HttpGet("Blog/{blogId?}/comments")]
|
||||
public async Task<IActionResult> blogComments(int? blogId)
|
||||
{
|
||||
Comments[]? comments = (Comments[]?)cache.Get($"commentsWithBlogId{blogId}");
|
||||
@@ -163,16 +154,16 @@ namespace yaflay.ru.Controllers
|
||||
|
||||
return Ok(comments);
|
||||
}
|
||||
[HttpPost("api/Blog/{blogId}/comments")]
|
||||
[HttpPost("Blog/{blogId}/comments")]
|
||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PUBLIC")]
|
||||
|
||||
public async Task<IActionResult> CreateBlogComments(int blogId, [FromBody]commentBody body)
|
||||
public async Task<IActionResult> CreateBlogComments(int blogId, [FromQuery] string text, [FromQuery] string sender)
|
||||
{
|
||||
Comments comment = new()
|
||||
{
|
||||
creatorMail = body.sender,
|
||||
creatorMail = sender,
|
||||
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
Text = body.text,
|
||||
Text = text,
|
||||
postId = blogId
|
||||
};
|
||||
await ctx.Comments.AddAsync(comment);
|
||||
@@ -180,23 +171,16 @@ namespace yaflay.ru.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet("api/Blog/{blogId}")]
|
||||
public async Task<IActionResult> blog(int blogId)
|
||||
[HttpGet("Blog/{id}")]
|
||||
public async Task<IActionResult> blog(int id)
|
||||
{
|
||||
Blogs? blog = cache.Get<Blogs>($"blogWithId{blogId}");
|
||||
if (blog == null)
|
||||
{
|
||||
blog = ctx.Blogs.FirstOrDefault(k => k.Id == blogId);
|
||||
if (blog != null)
|
||||
cache.Set($"blogWithId{blogId}", (object)blog, DateTime.Now.AddMinutes(10));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Blogs? blog;
|
||||
if (!cache.TryGetValue($"blogWithId{id}", out blog) && ctx.Blogs.TryGetValue(k => k.Id == id, out blog))
|
||||
cache.Set($"blogWithId{id}", blog, DateTime.Now.AddMinutes(30));
|
||||
|
||||
return Ok(blog);
|
||||
}
|
||||
[HttpGet("api/Blog")]
|
||||
[HttpGet("Blog")]
|
||||
public async Task<IActionResult> allBlogs()
|
||||
{
|
||||
Blogs[]? blogs = cache.Get<Blogs[]>($"allBlogs");
|
||||
@@ -210,19 +194,9 @@ namespace yaflay.ru.Controllers
|
||||
}
|
||||
return Ok(blogs);
|
||||
}
|
||||
[HttpPost("api/authorize")]
|
||||
[HttpPost("authorize")]
|
||||
public async Task<IActionResult> authorizeUser([FromBody] authorizeBody body)
|
||||
{
|
||||
var fromCache = cache.Get<ApiKey>($"apiKey-melon-{body.melon}");
|
||||
if (fromCache == null)
|
||||
{
|
||||
var melon = ctx.ApiKeys.FirstOrDefault(k => k.Melon == body.melon);
|
||||
if (melon != null)
|
||||
{
|
||||
cache.Set($"apiKey-melon-{body.melon}", (object)melon, DateTime.Now.AddMinutes(20));
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.ApiKeys.AddAsync(
|
||||
new()
|
||||
{
|
||||
@@ -235,23 +209,7 @@ namespace yaflay.ru.Controllers
|
||||
await ctx.SaveChangesAsync();
|
||||
return Ok(body.melon);
|
||||
}
|
||||
[HttpGet("r/{uri}")]
|
||||
public async Task<IActionResult> FromGitHub(string uri)
|
||||
{
|
||||
Console.WriteLine(uri);
|
||||
//if (uri == "404") { return Ok(); }
|
||||
Redirects? fromCache = cache.Get<Redirects>($"redirectsWithUrl-{uri}") ?? null;
|
||||
if (fromCache == null)
|
||||
{
|
||||
fromCache = ctx.Redirects.FirstOrDefault(k => k.uri == uri);
|
||||
Console.WriteLine("Im here!");
|
||||
if (fromCache != null)
|
||||
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
||||
}
|
||||
Console.WriteLine(fromCache?.ToString());
|
||||
return Redirect(fromCache?.redirectTo ?? "/404");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
34
Controllers/RedirectController.cs
Normal file
34
Controllers/RedirectController.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using yawaflua.ru.Models;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
using yawaflua.ru.Utilities;
|
||||
|
||||
namespace yawaflua.ru.Controllers
|
||||
{
|
||||
[Route("/r/")]
|
||||
[Authorize]
|
||||
public class RedirectController : ControllerBase
|
||||
{
|
||||
private AppDbContext ctx;
|
||||
private MemoryCache cache;
|
||||
public RedirectController(AppDbContext ctx, MemoryCache cache)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
this.cache = cache;
|
||||
}
|
||||
[HttpGet("{uri}")]
|
||||
public async Task<IActionResult> FromGitHub(string uri)
|
||||
{
|
||||
Console.WriteLine(uri);
|
||||
Redirects redirects;
|
||||
if (!cache.TryGetValue($"redirectsWithUrl-{uri}", out redirects) || ctx.Redirects.TryGetValue(k => k.uri == uri, out redirects))
|
||||
cache.Set($"redirectsWithUrl-{uri}", redirects, DateTime.Now.AddMinutes(10));
|
||||
|
||||
return Redirect(redirects?.redirectTo ?? "/404");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231127204250_Migrate271122342")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate271122342 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231204171742_Migrate04122016")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate04122016 : Migration
|
||||
|
||||
10
Migrations/20231204210831_Migrate0512.Designer.cs
generated
10
Migrations/20231204210831_Migrate0512.Designer.cs
generated
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231204210831_Migrate0512")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -83,7 +83,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -3,7 +3,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate0512 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231218172614_Migrate18122023")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Author");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -129,9 +129,9 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Redirects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.HasOne("yaflay.ru.Models.Tables.Author", "author")
|
||||
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||
.WithMany()
|
||||
.HasForeignKey("authorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
|
||||
@@ -3,7 +3,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate18122023 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231218173546_Migrate18122035")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Author");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -129,9 +129,9 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Redirects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.HasOne("yaflay.ru.Models.Tables.Author", "author")
|
||||
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||
.WithMany()
|
||||
.HasForeignKey("authorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate18122035 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231219143602_Migrate191220231734")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Author");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -127,9 +127,9 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Redirects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.HasOne("yaflay.ru.Models.Tables.Author", "author")
|
||||
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||
.WithMany()
|
||||
.HasForeignKey("authorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate191220231734 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231223164820_Migrate321220231944")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -64,7 +64,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -91,7 +91,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate321220231944 : Migration
|
||||
|
||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20231225062718_Migrate25122023926")]
|
||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Database.Tables.ApiKey", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("text");
|
||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("ApiKeys", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -84,7 +84,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -111,7 +111,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate25122023926 : Migration
|
||||
|
||||
164
Migrations/20240315193302_Migrate_22_32__15_03_2024.Designer.cs
generated
Normal file
164
Migrations/20240315193302_Migrate_22_32__15_03_2024.Designer.cs
generated
Normal file
@@ -0,0 +1,164 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20240315193302_Migrate_22_32__15_03_2024")]
|
||||
partial class Migrate_22_32__15_03_2024
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.12")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("api.yawaflua.ru.Models.Tables.Projects", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<string>("description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("image")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<decimal>("DiscordOwnerId")
|
||||
.HasColumnType("numeric(20,0)");
|
||||
|
||||
b.Property<string>("Melon")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Key");
|
||||
|
||||
b.ToTable("ApiKeys", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Annotation")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("authorId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("authorNickname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("dateTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("creatorMail")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("dateTime")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("postId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("redirectTo")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("uri")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Redirects");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Migrations/20240315193302_Migrate_22_32__15_03_2024.cs
Normal file
38
Migrations/20240315193302_Migrate_22_32__15_03_2024.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migrate_22_32__15_03_2024 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Projects",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
name = table.Column<string>(type: "text", nullable: false),
|
||||
description = table.Column<string>(type: "text", nullable: false),
|
||||
url = table.Column<string>(type: "text", nullable: false),
|
||||
image = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Projects", x => x.id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Projects");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using yaflay.ru.Models;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace yaflay.ru.Migrations
|
||||
namespace yawaflua.ru.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||
@@ -22,7 +22,36 @@ namespace yaflay.ru.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Database.Tables.ApiKey", b =>
|
||||
modelBuilder.Entity("api.yawaflua.ru.Models.Tables.Projects", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<string>("description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("image")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("text");
|
||||
@@ -42,7 +71,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("ApiKeys", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -81,7 +110,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Blogs", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -108,7 +137,7 @@ namespace yaflay.ru.Migrations
|
||||
b.ToTable("Comments", "public");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
||||
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using yaflay.ru.Database.Tables;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using api.yawaflua.ru.Models.Tables;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using yawaflua.ru.Database.Tables;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
|
||||
namespace yaflay.ru.Models
|
||||
namespace yawaflua.ru.Models
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
@@ -15,6 +16,7 @@ namespace yaflay.ru.Models
|
||||
public DbSet<Comments> Comments { get; set; }
|
||||
public DbSet<Redirects> Redirects { get; set; }
|
||||
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||
public DbSet<Projects> Projects { get; set; }
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using yaflay.ru.Auth;
|
||||
using yawaflua.ru.Auth;
|
||||
|
||||
namespace yaflay.ru.Database.Tables;
|
||||
namespace yawaflua.ru.Database.Tables;
|
||||
|
||||
[Table("ApiKeys", Schema = "public")]
|
||||
public class ApiKey
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace yaflay.ru.Models.Tables
|
||||
namespace yawaflua.ru.Models.Tables
|
||||
{
|
||||
[Table("Blogs", Schema = "public")]
|
||||
public class Blogs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace yaflay.ru.Models.Tables
|
||||
namespace yawaflua.ru.Models.Tables
|
||||
{
|
||||
[Table("Comments", Schema = "public")]
|
||||
public class Comments
|
||||
|
||||
16
Models/Tables/Projects.cs
Normal file
16
Models/Tables/Projects.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace api.yawaflua.ru.Models.Tables
|
||||
{
|
||||
[Table("Projects")]
|
||||
public class Projects
|
||||
{
|
||||
[Key]
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string description { get; set; }
|
||||
public string url { get; set; }
|
||||
public string image { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace yaflay.ru.Models.Tables
|
||||
namespace yawaflua.ru.Models.Tables
|
||||
{
|
||||
public class Redirects
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@page "{type?}"
|
||||
@model yaflay.ru.Pages.AdminPanelModel
|
||||
@model yawaflua.ru.Pages.AdminPanelModel
|
||||
@using System.Text.Json.Nodes
|
||||
@{
|
||||
ViewData["Title"] = "AdminPanel";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class AdminPanelModel : PageModel
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@page "{code}"
|
||||
@model yaflay.ru.Pages.AuthorizeModel
|
||||
@model yawaflua.ru.Pages.AuthorizeModel
|
||||
@using System.Text.Json.Nodes
|
||||
@using Newtonsoft.Json
|
||||
@{
|
||||
@@ -58,10 +58,10 @@
|
||||
{
|
||||
<h4>Ошибка! Попробуй авторизоваться заново</h4>
|
||||
|
||||
Console.Error.WriteLine("debug: START \\/ \nDon't worry, this message is not bad as you think");
|
||||
Console.Error.WriteLine("debug: START \\/ \ninfo: Don't worry, this message is not bad as you think");
|
||||
Console.Error.WriteLine("error: DiscordAuthorize is not worked");
|
||||
Console.Error.WriteLine($"debug: Body from discord: {body}\ndebug: Sended data to discord: {message.Content.ReadAsStringAsync().Result}");
|
||||
Console.Error.WriteLine($"info: Check environment data: \nClientId={Startup.clientId}\nClientSecret={Startup.clientSecret}\nRedirectUrl={Startup.redirectUrl}\nOwnerId={String.Join(",", Startup.ownerId)} ");
|
||||
Console.Error.WriteLine($"info: Check environment data: \n ClientId={Startup.clientId}\n ClientSecret={Startup.clientSecret}\n RedirectUrl={Startup.redirectUrl}\n OwnerId={String.Join(",", Startup.ownerId)} ");
|
||||
Console.Error.WriteLine("info: If any data is null and you set data in environment or appsettings.json, please create issue with this debug messages ");
|
||||
Console.Error.WriteLine("debug: END /\\");
|
||||
}
|
||||
@@ -72,7 +72,7 @@
|
||||
try
|
||||
{
|
||||
HttpContent bodytoApi;
|
||||
bodytoApi = new StringContent(JsonConvert.SerializeObject(new yaflay.ru.Controllers.HomeController.authorizeBody()
|
||||
bodytoApi = new StringContent(JsonConvert.SerializeObject(new yawaflua.ru.Controllers.ApiController.authorizeBody()
|
||||
{
|
||||
discordId = body["user"]["id"].ToString(),
|
||||
melon = body["access_token"].ToString(),
|
||||
@@ -87,7 +87,7 @@
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
Response.Redirect("/authorize");
|
||||
Response.Redirect("/authorize", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class AuthorizeModel : PageModel
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@page "{id?}"
|
||||
@model BlogModel
|
||||
@using yaflay.ru.Models.Tables
|
||||
@using yawaflua.ru.Models.Tables
|
||||
@using Newtonsoft.Json
|
||||
@{
|
||||
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class BlogModel : PageModel
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[IgnoreAntiforgeryToken]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "{uri?}"
|
||||
@page
|
||||
@model IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "yawaflua";
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using yaflay.ru.Models;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using yawaflua.ru.Models;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
public IMemoryCache cache;
|
||||
public AppDbContext ctx;
|
||||
public string? uri { get; set; } = null;
|
||||
public IndexModel(ILogger<IndexModel> logger, IMemoryCache cache, AppDbContext ctx)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -19,28 +18,11 @@ namespace yaflay.ru.Pages
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public void OnGet(string? uri)
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
Page();
|
||||
|
||||
this.uri = uri ?? null;
|
||||
Console.WriteLine(uri);
|
||||
if (this.uri != null)
|
||||
{
|
||||
Redirects? fromCache = cache.Get<Redirects>($"redirectsWithUrl-{uri}") ?? null;
|
||||
if (fromCache == null)
|
||||
{
|
||||
fromCache = ctx.Redirects.FirstOrDefault(k => k.uri == uri);
|
||||
Console.WriteLine("Im here!");
|
||||
if (fromCache != null)
|
||||
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
||||
}
|
||||
Console.WriteLine(fromCache?.ToString());
|
||||
Response.Redirect(fromCache?.redirectTo ?? "/404");
|
||||
}
|
||||
else
|
||||
{
|
||||
Page();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class Index1Model : PageModel
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace yaflay.ru.Pages
|
||||
namespace yawaflua.ru.Pages
|
||||
{
|
||||
public class PrivacyModel : PageModel
|
||||
{
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@using yaflay.ru
|
||||
@namespace yaflay.ru.Pages
|
||||
@using yawaflua.ru
|
||||
@namespace yawaflua.ru.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
||||
12
Pages/rrobotsTxt.cshtml
Normal file
12
Pages/rrobotsTxt.cshtml
Normal file
@@ -0,0 +1,12 @@
|
||||
@page
|
||||
@{
|
||||
Layout = null;
|
||||
this.Response.ContentType = "text/plain";
|
||||
}
|
||||
User-agent: *
|
||||
<environment include="Development,Staging">Disallow: /*</environment>
|
||||
<environment include="Production">Disallow: /* </environment>
|
||||
<environment include="Production">Allow: /Blog </environment>
|
||||
<environment include="Production">Allow: /Blog/* </environment>
|
||||
<environment include="Production">Allow: /Privacy </environment>
|
||||
<environment include="Production">Allow: / </environment>
|
||||
17
Program.cs
17
Program.cs
@@ -1,25 +1,10 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using yaflay.ru;
|
||||
using yawaflua.ru;
|
||||
public class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
Func<string, string?> parse = (string name) => Environment.GetEnvironmentVariable(name) ?? null;
|
||||
|
||||
Startup.clientId = parse("CLIENTID");
|
||||
Startup.clientSecret = parse("CLIENTSECRET");
|
||||
Startup.redirectUrl = parse("REDIRECTURL");
|
||||
if (!(parse("PSQL_HOST") == null | parse("PSQL_USER") == null | parse("PSQL_PASSWORD") == null | parse("PSQL_DATABASE") == null))
|
||||
{
|
||||
Startup.connectionString = $"Host={parse("PSQL_HOST")};Username={parse("PSQL_USER")};Password={parse("PSQL_PASSWORD")};Database={parse("PSQL_DATABASE")}";
|
||||
}
|
||||
if (parse("OWNERID") != null)
|
||||
{
|
||||
Startup.ownerId = new string?[] { parse("OWNERID") };
|
||||
}
|
||||
Startup.readmeFile = parse("READMEFILE");
|
||||
|
||||
CreateHostBuilder()
|
||||
.Build()
|
||||
.Run();
|
||||
|
||||
@@ -1,35 +1,45 @@
|
||||
{
|
||||
"profiles": {
|
||||
"yaflay.ru": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7269;http://localhost:5070"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:3236",
|
||||
"sslPort": 44373
|
||||
"applicationUrl": "http://localhost:16072",
|
||||
"sslPort": 44366
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5144",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7049;http://localhost:5144",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
66
Startup.cs
66
Startup.cs
@@ -5,12 +5,14 @@ using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.CompilerServices;
|
||||
using DotNetEd.CoreAdmin;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using yaflay.ru.Auth;
|
||||
using yaflay.ru.Models;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using yawaflua.ru.Auth;
|
||||
using yawaflua.ru.Models;
|
||||
|
||||
|
||||
namespace yaflay.ru
|
||||
namespace yawaflua.ru
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
@@ -28,40 +30,16 @@ namespace yaflay.ru
|
||||
public Startup()
|
||||
{
|
||||
configuration = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables(prefix: "m.")
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
.Build();
|
||||
if (clientId == null | clientSecret == null | redirectUrl == null)
|
||||
{
|
||||
clientId = configuration.GetValue<string>("clientId");
|
||||
clientSecret = configuration.GetValue<string>("clientSecret");
|
||||
redirectUrl = configuration.GetValue<string>("redirectUrl");
|
||||
}
|
||||
if (connectionString == null)
|
||||
{
|
||||
connectionString = configuration.GetValue<string>("connectionString");
|
||||
Console.WriteLine("Connectionstring" + connectionString);
|
||||
if (connectionString == null)
|
||||
{
|
||||
throw new ArgumentException("ConnectionString is null!");
|
||||
}
|
||||
}
|
||||
if (ownerId == null)
|
||||
{
|
||||
ownerId = new[] { configuration.GetValue<string>("ownerId") };
|
||||
if (ownerId?.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Owner id is null!");
|
||||
}
|
||||
}
|
||||
if (readmeFile == null)
|
||||
{
|
||||
readmeFile = configuration.GetValue<string>("readmeFile");
|
||||
if (readmeFile == null)
|
||||
{
|
||||
throw new ArgumentException("ReadmeFile link is null");
|
||||
}
|
||||
}
|
||||
|
||||
clientId = configuration.GetValue<string>("clientId");
|
||||
clientSecret = configuration.GetValue<string>("clientSecret");
|
||||
redirectUrl = configuration.GetValue<string>("redirectUrl");
|
||||
connectionString = configuration.GetValue<string>("connectionString");
|
||||
ownerId = configuration.GetValue<string[]>("ownerId");
|
||||
readmeFile = configuration.GetValue<string>("readmeFile");
|
||||
|
||||
}
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
@@ -81,6 +59,8 @@ namespace yaflay.ru
|
||||
.AddTransient<ApiKeyAuthantication>()
|
||||
.AddSingleton(configuration)
|
||||
.AddDbContext<AppDbContext>(c => c.UseNpgsql(connectionString: connectionString))
|
||||
.AddSwaggerGen()
|
||||
.AddSingleton(new MemoryCache(new MemoryCacheOptions()))
|
||||
.AddAuthorization(k =>
|
||||
{
|
||||
k.AddPolicy("DISCORD-OAUTH-PUBLIC", policyBuilder => {
|
||||
@@ -98,12 +78,13 @@ namespace yaflay.ru
|
||||
options.DefaultChallengeScheme = "Bearer";
|
||||
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PRIVATE", "DISCORD-OAUTH-PRIVATE");
|
||||
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PUBLIC", "DISCORD-OAUTH-PUBLIC");
|
||||
options.RequireAuthenticatedSignIn = false;
|
||||
}).AddScheme<AuthenticationSchemeOptions, ApiKeyAuthantication>("Bearer", options => {});
|
||||
services.AddMvc()
|
||||
.AddRazorPagesOptions(options =>
|
||||
{
|
||||
options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt");
|
||||
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
||||
options.Conventions.AddPageRoute("/rrobotsTxt", "/robots.txt");
|
||||
options.Conventions.AddPageRoute("/NotFound", "/404");
|
||||
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
||||
options.Conventions.AddPageRoute("/Authorize", "/authorize");
|
||||
@@ -132,17 +113,24 @@ namespace yaflay.ru
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseSwagger((options) =>
|
||||
{
|
||||
options.RouteTemplate = "swagger/v1/swagger.json";
|
||||
});
|
||||
app.UseSwaggerUI();
|
||||
#if DEBUG
|
||||
app.UseCoreAdminCustomTitle("yawaflua");
|
||||
app.UseCoreAdminCustomAuth((k) => Task.FromResult(true));
|
||||
app.UseCoreAdminCustomUrl("admin/coreadmin");
|
||||
#endif
|
||||
app.UseCors(k => { k.AllowAnyMethod(); k.AllowAnyOrigin(); k.AllowAnyHeader(); });
|
||||
app.UseCors(k => { k.WithMethods("POST", "GET", "PATCH", "PUT"); k.AllowAnyOrigin(); k.AllowAnyHeader(); });
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
endpoints.MapDefaultControllerRoute().AllowAnonymous();
|
||||
endpoints.MapFallbackToFile("/index.html").AllowAnonymous();
|
||||
endpoints.MapSwagger();
|
||||
endpoints.MapRazorPages();
|
||||
endpoints.MapControllers();
|
||||
endpoints.MapControllers().AllowAnonymous();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
13
Utilities/AppDbContextUtilities.cs
Normal file
13
Utilities/AppDbContextUtilities.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace yawaflua.ru.Utilities
|
||||
{
|
||||
public static class AppDbContextUtilities
|
||||
{
|
||||
public static bool TryGetValue<T>(this DbSet<T> set, Func<T, bool> predicate, out T? value) where T : class
|
||||
{
|
||||
value = set.FirstOrDefault(predicate);
|
||||
return value != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>0c1057bc-b206-4a40-b003-9b6299aa9c64</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
|
||||
<Authors>yawaflua</Authors>
|
||||
<Company>yawaflua</Company>
|
||||
<SpaProxyLaunchCommand>npm run serve -- --host 0.0.0.0 --port 8080</SpaProxyLaunchCommand>
|
||||
<SpaProxyServerUrl>http://localhost:8080</SpaProxyServerUrl>
|
||||
<SpaRoot>..\frontend.yawaflua.ru</SpaRoot>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
|
||||
<Version>8.*-*</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\frontend.yawaflua.ru\frontend.yawaflua.ru.esproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="7.0.4" />
|
||||
<PackageReference Include="CoreAdmin" Version="2.7.1" />
|
||||
@@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33723.286
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaflay.ru", "yaflay.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api.yawaflua.ru", "api.yawaflua.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "frontend.yawaflua.ru", "..\frontend.yawaflua.ru\frontend.yawaflua.ru.esproj", "{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -20,6 +22,12 @@ Global
|
||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
Reference in New Issue
Block a user