mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-04-25 09:10:38 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 810f9b353e | |||
| 7d2ee22c24 | |||
| e6f56938c1 | |||
| 1075225001 | |||
| 83c7fc1723 |
@@ -21,8 +21,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: 7.0.x
|
dotnet-version: 7.0.x
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore "api.yawaflua.ru.csproj"
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --no-restore
|
run: dotnet build --no-restore "api.yawaflua.ru.csproj"
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-build --verbosity normal
|
run: dotnet test --no-build --verbosity normal "api.yawaflua.ru.csproj"
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
@page
|
|
||||||
@model yaflay.ru.MyFeature.Pages.Page1Model
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width" />
|
|
||||||
<title>Page1</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace yaflay.ru.MyFeature.Pages
|
|
||||||
{
|
|
||||||
public class Page1Model : PageModel
|
|
||||||
{
|
|
||||||
public void OnGet()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,12 @@ using System.Text.Encodings.Web;
|
|||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using yaflay.ru.Database.Tables;
|
using yawaflua.ru.Database.Tables;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
using yaflay.ru.Models.Tables;
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
|
|
||||||
namespace yaflay.ru.Auth;
|
namespace yawaflua.ru.Auth;
|
||||||
|
|
||||||
public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOptions>
|
public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,9 @@ public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOp
|
|||||||
|
|
||||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
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.");
|
return AuthenticateResult.Fail("API Key was not provided.");
|
||||||
|
|
||||||
string? providedApiKey = apiKeyHeaderValues.FirstOrDefault()?.Replace("Bearer ", "");
|
string? providedApiKey = apiKeyHeaderValues.FirstOrDefault()?.Replace("Bearer ", "");
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace yaflay.ru.Auth
|
namespace yawaflua.ru.Auth
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum ApiKeyTypes
|
public enum ApiKeyTypes
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
||||||
using Microsoft.AspNetCore.RateLimiting;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using yaflay.ru.Models.Tables;
|
using yawaflua.ru.Models.Tables;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using yaflay.ru.Auth;
|
using yawaflua.ru.Auth;
|
||||||
using yaflay.ru.Database.Tables;
|
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("")]
|
[Route("api/")]
|
||||||
public class HomeController : Controller
|
public class ApiController : Controller
|
||||||
{
|
{
|
||||||
private IMemoryCache cache;
|
private IMemoryCache cache;
|
||||||
private AppDbContext ctx;
|
private AppDbContext ctx;
|
||||||
public HomeController(IMemoryCache cache, AppDbContext ctx)
|
public ApiController(IMemoryCache cache, AppDbContext ctx)
|
||||||
{
|
{
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
@@ -29,29 +29,16 @@ namespace yaflay.ru.Controllers
|
|||||||
public string watermelon { get; set; }
|
public string watermelon { get; set; }
|
||||||
public string discordId { get; set; }
|
public string discordId { get; set; }
|
||||||
public ApiKeyTypes type { get; set; }
|
public ApiKeyTypes type { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
public class commentBody
|
public class commentBody
|
||||||
{
|
{
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
public string sender { 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()
|
public async Task<IActionResult> getIndexPage()
|
||||||
{
|
{
|
||||||
string? indexPage = cache.Get<string>($"indexPage");
|
string? indexPage = cache.Get<string>($"indexPage");
|
||||||
@@ -65,11 +52,24 @@ namespace yaflay.ru.Controllers
|
|||||||
return Ok(indexPage);
|
return Ok(indexPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/redirects")]
|
[HttpGet("Projects")]
|
||||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
public async Task<IActionResult> getProjects()
|
||||||
public async Task<IActionResult> createRedirectUri([FromBody]redirectBody body)
|
{
|
||||||
|
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;
|
HttpResponseMessage message;
|
||||||
using (var requestMessage =
|
using (var requestMessage =
|
||||||
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||||
@@ -83,8 +83,8 @@ namespace yaflay.ru.Controllers
|
|||||||
{
|
{
|
||||||
Redirects redirects = new()
|
Redirects redirects = new()
|
||||||
{
|
{
|
||||||
redirectTo = body.url,
|
redirectTo = url,
|
||||||
uri = body.uri
|
uri = uri
|
||||||
};
|
};
|
||||||
await ctx.Redirects.AddAsync(redirects);
|
await ctx.Redirects.AddAsync(redirects);
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
@@ -95,9 +95,9 @@ namespace yaflay.ru.Controllers
|
|||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost("api/Blog")]
|
[HttpPost("Blog")]
|
||||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
[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;
|
HttpResponseMessage message;
|
||||||
@@ -109,36 +109,27 @@ namespace yaflay.ru.Controllers
|
|||||||
}
|
}
|
||||||
string responseBody = await message.Content.ReadAsStringAsync();
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
JsonNode response = JsonNode.Parse(responseBody);
|
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 = annotation,
|
||||||
{
|
authorId = response["user"]["id"].ToString(),
|
||||||
Annotation = body.annotation,
|
dateTime = DateTime.Now,
|
||||||
authorId = response["user"]["id"].ToString(),
|
ImageUrl = image,
|
||||||
dateTime = DateTime.Now,
|
Text = text,
|
||||||
ImageUrl = body.image,
|
Title = title,
|
||||||
Text = body.text,
|
authorNickname = response["user"]["global_name"].ToString()
|
||||||
Title = body.title,
|
};
|
||||||
authorNickname = response["user"]["global_name"].ToString()
|
await ctx.Blogs.AddAsync(article);
|
||||||
};
|
await ctx.SaveChangesAsync();
|
||||||
await ctx.Blogs.AddAsync(article);
|
return Ok();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Unauthorized(body);
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet("logout")]
|
[HttpGet("logout")]
|
||||||
@@ -150,7 +141,7 @@ namespace yaflay.ru.Controllers
|
|||||||
return Redirect("/");
|
return Redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/Blog/{blogId?}/comments")]
|
[HttpGet("Blog/{blogId?}/comments")]
|
||||||
public async Task<IActionResult> blogComments(int? blogId)
|
public async Task<IActionResult> blogComments(int? blogId)
|
||||||
{
|
{
|
||||||
Comments[]? comments = (Comments[]?)cache.Get($"commentsWithBlogId{blogId}");
|
Comments[]? comments = (Comments[]?)cache.Get($"commentsWithBlogId{blogId}");
|
||||||
@@ -163,16 +154,16 @@ namespace yaflay.ru.Controllers
|
|||||||
|
|
||||||
return Ok(comments);
|
return Ok(comments);
|
||||||
}
|
}
|
||||||
[HttpPost("api/Blog/{blogId}/comments")]
|
[HttpPost("Blog/{blogId}/comments")]
|
||||||
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PUBLIC")]
|
[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()
|
Comments comment = new()
|
||||||
{
|
{
|
||||||
creatorMail = body.sender,
|
creatorMail = sender,
|
||||||
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||||
Text = body.text,
|
Text = text,
|
||||||
postId = blogId
|
postId = blogId
|
||||||
};
|
};
|
||||||
await ctx.Comments.AddAsync(comment);
|
await ctx.Comments.AddAsync(comment);
|
||||||
@@ -180,23 +171,16 @@ namespace yaflay.ru.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/Blog/{blogId}")]
|
[HttpGet("Blog/{id}")]
|
||||||
public async Task<IActionResult> blog(int blogId)
|
public async Task<IActionResult> blog(int id)
|
||||||
{
|
{
|
||||||
Blogs? blog = cache.Get<Blogs>($"blogWithId{blogId}");
|
Blogs? blog;
|
||||||
if (blog == null)
|
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));
|
||||||
blog = ctx.Blogs.FirstOrDefault(k => k.Id == blogId);
|
|
||||||
if (blog != null)
|
|
||||||
cache.Set($"blogWithId{blogId}", (object)blog, DateTime.Now.AddMinutes(10));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return Ok(blog);
|
return Ok(blog);
|
||||||
}
|
}
|
||||||
[HttpGet("api/Blog")]
|
[HttpGet("Blog")]
|
||||||
public async Task<IActionResult> allBlogs()
|
public async Task<IActionResult> allBlogs()
|
||||||
{
|
{
|
||||||
Blogs[]? blogs = cache.Get<Blogs[]>($"allBlogs");
|
Blogs[]? blogs = cache.Get<Blogs[]>($"allBlogs");
|
||||||
@@ -210,19 +194,9 @@ namespace yaflay.ru.Controllers
|
|||||||
}
|
}
|
||||||
return Ok(blogs);
|
return Ok(blogs);
|
||||||
}
|
}
|
||||||
[HttpPost("api/authorize")]
|
[HttpPost("authorize")]
|
||||||
public async Task<IActionResult> authorizeUser([FromBody] authorizeBody body)
|
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(
|
await ctx.ApiKeys.AddAsync(
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
@@ -235,23 +209,7 @@ namespace yaflay.ru.Controllers
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return Ok(body.melon);
|
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");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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, [FromQuery(Name = "to")] string? to, [FromQuery(Name = "debug")] string debug = "false")
|
||||||
|
{
|
||||||
|
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(20));
|
||||||
|
|
||||||
|
return Redirect(redirects?.redirectTo + to?.Replace("%", "/") ?? "/404");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
-28
@@ -1,31 +1,33 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
# Èñïîëüçóåì îáðàç ASP.NET Core SDK äëÿ ñáîðêè ïðîåêòà
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
|
||||||
|
# Óñòàíîâêà ðàáî÷åé äèðåêòîðèè
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Êîïèðóåì ôàéëû ïðîåêòà è âîññòàíàâëèâàåì çàâèñèìîñòè
|
||||||
|
COPY . ./
|
||||||
|
RUN dotnet restore "api.yawaflua.ru.csproj"
|
||||||
|
|
||||||
|
# Ñîáèðàåì ïðîåêò
|
||||||
|
RUN dotnet publish -c Release -o /app/out "api.yawaflua.ru.csproj"
|
||||||
|
|
||||||
|
|
||||||
|
# Êîíå÷íûé îáðàç, èñïîëüçóþùèé ASP.NET Core runtime
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/out ./
|
||||||
|
# Îïðåäåëÿåì ïîðò, êîòîðûé ïðèëîæåíèå áóäåò ñëóøàòü
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
# Óñòàíîâêà ïåðåìåííûõ ñðåäû
|
||||||
|
ENV CLIENTID=123
|
||||||
|
ENV CLIENTSECRET=aAbB
|
||||||
|
ENV REDIRECTURL=http://example.org/
|
||||||
|
ENV PSQL_HOST=localhost
|
||||||
|
ENV PSQL_USER=root
|
||||||
|
ENV PSQL_PASSWORD=root
|
||||||
|
ENV PSQL_DATABASE=database
|
||||||
|
ENV OWNERID=1111111
|
||||||
|
ENV READMEFILE=https://raw.githubusercontent.com/yawaflua/yawaflua/main/README.md
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
# Çàïóñêàåì ASP.NET Core ïðèëîæåíèå
|
||||||
|
ENTRYPOINT ["dotnet", "api.yawaflua.ru.dll"]
|
||||||
|
|
||||||
WORKDIR /src
|
|
||||||
COPY ["yaflay.ru.csproj", "."]
|
|
||||||
RUN dotnet restore "./yaflay.ru.csproj"
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/."
|
|
||||||
RUN dotnet build "yaflay.ru.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
FROM build AS publish
|
|
||||||
ENV CLIENTID 123
|
|
||||||
ENV CLIENTSECRET aAbB
|
|
||||||
ENV REDIRECTURL http://example.org/
|
|
||||||
ENV PSQL_HOST localhost
|
|
||||||
ENV PSQL_USER root
|
|
||||||
ENV PSQL_PASSWORD root
|
|
||||||
ENV PSQL_DATABASE database
|
|
||||||
ENV OWNERID 1111111
|
|
||||||
ENV READMEFILE https://raw.githubusercontent.com/yawaflua/yawaflua/main/README.md
|
|
||||||
RUN dotnet publish "yaflay.ru.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
ENTRYPOINT ["dotnet", "yaflay.ru.dll"]
|
|
||||||
|
|||||||
+4
-4
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231127204250_Migrate271122342")]
|
[Migration("20231127204250_Migrate271122342")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate271122342 : Migration
|
public partial class Migrate271122342 : Migration
|
||||||
|
|||||||
+4
-4
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231204171742_Migrate04122016")]
|
[Migration("20231204171742_Migrate04122016")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate04122016 : Migration
|
public partial class Migrate04122016 : Migration
|
||||||
|
|||||||
+5
-5
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231204210831_Migrate0512")]
|
[Migration("20231204210831_Migrate0512")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -56,7 +56,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -83,7 +83,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate0512 : Migration
|
public partial class Migrate0512 : Migration
|
||||||
|
|||||||
+8
-8
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231218172614_Migrate18122023")]
|
[Migration("20231218172614_Migrate18122023")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Author");
|
b.ToTable("Author");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -129,9 +129,9 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Redirects");
|
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()
|
.WithMany()
|
||||||
.HasForeignKey("authorId")
|
.HasForeignKey("authorId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate18122023 : Migration
|
public partial class Migrate18122023 : Migration
|
||||||
|
|||||||
+8
-8
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231218173546_Migrate18122035")]
|
[Migration("20231218173546_Migrate18122035")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Author");
|
b.ToTable("Author");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -129,9 +129,9 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Redirects");
|
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()
|
.WithMany()
|
||||||
.HasForeignKey("authorId")
|
.HasForeignKey("authorId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate18122035 : Migration
|
public partial class Migrate18122035 : Migration
|
||||||
|
|||||||
+8
-8
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231219143602_Migrate191220231734")]
|
[Migration("20231219143602_Migrate191220231734")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Author");
|
b.ToTable("Author");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -81,7 +81,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -108,7 +108,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -127,9 +127,9 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Redirects");
|
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()
|
.WithMany()
|
||||||
.HasForeignKey("authorId")
|
.HasForeignKey("authorId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate191220231734 : Migration
|
public partial class Migrate191220231734 : Migration
|
||||||
|
|||||||
+5
-5
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231223164820_Migrate321220231944")]
|
[Migration("20231223164820_Migrate321220231944")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -64,7 +64,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -91,7 +91,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate321220231944 : Migration
|
public partial class Migrate321220231944 : Migration
|
||||||
|
|||||||
+6
-6
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20231225062718_Migrate25122023926")]
|
[Migration("20231225062718_Migrate25122023926")]
|
||||||
@@ -25,7 +25,7 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Database.Tables.ApiKey", b =>
|
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Key")
|
b.Property<string>("Key")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -45,7 +45,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("ApiKeys", "public");
|
b.ToTable("ApiKeys", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -84,7 +84,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -111,7 +111,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Migrate25122023926 : Migration
|
public partial class Migrate25122023926 : Migration
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace yaflay.ru.Migrations
|
namespace yawaflua.ru.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
partial class AppDbContextModelSnapshot : ModelSnapshot
|
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||||
@@ -22,7 +22,36 @@ namespace yaflay.ru.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
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")
|
b.Property<string>("Key")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -42,7 +71,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("ApiKeys", "public");
|
b.ToTable("ApiKeys", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -81,7 +110,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Blogs", "public");
|
b.ToTable("Blogs", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -108,7 +137,7 @@ namespace yaflay.ru.Migrations
|
|||||||
b.ToTable("Comments", "public");
|
b.ToTable("Comments", "public");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b =>
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using api.yawaflua.ru.Models.Tables;
|
||||||
using yaflay.ru.Database.Tables;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using yaflay.ru.Models.Tables;
|
using yawaflua.ru.Database.Tables;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
namespace yaflay.ru.Models
|
namespace yawaflua.ru.Models
|
||||||
{
|
{
|
||||||
public class AppDbContext : DbContext
|
public class AppDbContext : DbContext
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,7 @@ namespace yaflay.ru.Models
|
|||||||
public DbSet<Comments> Comments { get; set; }
|
public DbSet<Comments> Comments { get; set; }
|
||||||
public DbSet<Redirects> Redirects { get; set; }
|
public DbSet<Redirects> Redirects { get; set; }
|
||||||
public DbSet<ApiKey> ApiKeys { get; set; }
|
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||||
|
public DbSet<Projects> Projects { get; set; }
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
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")]
|
[Table("ApiKeys", Schema = "public")]
|
||||||
public class ApiKey
|
public class ApiKey
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace yaflay.ru.Models.Tables
|
namespace yawaflua.ru.Models.Tables
|
||||||
{
|
{
|
||||||
[Table("Blogs", Schema = "public")]
|
[Table("Blogs", Schema = "public")]
|
||||||
public class Blogs
|
public class Blogs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
|
|
||||||
namespace yaflay.ru.Models.Tables
|
namespace yawaflua.ru.Models.Tables
|
||||||
{
|
{
|
||||||
[Table("Comments", Schema = "public")]
|
[Table("Comments", Schema = "public")]
|
||||||
public class Comments
|
public class Comments
|
||||||
|
|||||||
@@ -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;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace yaflay.ru.Models.Tables
|
namespace yawaflua.ru.Models.Tables
|
||||||
{
|
{
|
||||||
public class Redirects
|
public class Redirects
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@page "{type?}"
|
@page "{type?}"
|
||||||
@model yaflay.ru.Pages.AdminPanelModel
|
@model yawaflua.ru.Pages.AdminPanelModel
|
||||||
@using System.Text.Json.Nodes
|
@using System.Text.Json.Nodes
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "AdminPanel";
|
ViewData["Title"] = "AdminPanel";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class AdminPanelModel : PageModel
|
public class AdminPanelModel : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@page "{code}"
|
@page "{code}"
|
||||||
@model yaflay.ru.Pages.AuthorizeModel
|
@model yawaflua.ru.Pages.AuthorizeModel
|
||||||
@using System.Text.Json.Nodes
|
@using System.Text.Json.Nodes
|
||||||
@using Newtonsoft.Json
|
@using Newtonsoft.Json
|
||||||
@{
|
@{
|
||||||
@@ -53,15 +53,15 @@
|
|||||||
message = await Startup.client.SendAsync(requestMessage);
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
}
|
}
|
||||||
string responseBody = await message.Content.ReadAsStringAsync();
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
JsonNode body = JsonNode.Parse(responseBody);
|
JsonNode? body = JsonNode.Parse(responseBody);
|
||||||
if (body["access_token"]?.ToString() == null)
|
if (body["access_token"]?.ToString() == null)
|
||||||
{
|
{
|
||||||
<h4>Ошибка! Попробуй авторизоваться заново</h4>
|
<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("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($"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("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 /\\");
|
Console.Error.WriteLine("debug: END /\\");
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpContent bodytoApi;
|
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(),
|
discordId = body["user"]["id"].ToString(),
|
||||||
melon = body["access_token"].ToString(),
|
melon = body["access_token"].ToString(),
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response.Redirect("/authorize");
|
Response.Redirect("/authorize", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class AuthorizeModel : PageModel
|
public class AuthorizeModel : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@page "{id?}"
|
@page "{id?}"
|
||||||
@model BlogModel
|
@model BlogModel
|
||||||
@using yaflay.ru.Models.Tables
|
@using yawaflua.ru.Models.Tables
|
||||||
@using Newtonsoft.Json
|
@using Newtonsoft.Json
|
||||||
@{
|
@{
|
||||||
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
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
|
public class BlogModel : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
@page "{uri?}"
|
@page
|
||||||
@model IndexModel
|
@model IndexModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "yawaflua";
|
ViewData["Title"] = "yawaflua";
|
||||||
|
|||||||
+6
-24
@@ -1,17 +1,16 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Models;
|
||||||
using yaflay.ru.Models.Tables;
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class IndexModel : PageModel
|
public class IndexModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ILogger<IndexModel> _logger;
|
||||||
public IMemoryCache cache;
|
public IMemoryCache cache;
|
||||||
public AppDbContext ctx;
|
public AppDbContext ctx;
|
||||||
public string? uri { get; set; } = null;
|
|
||||||
public IndexModel(ILogger<IndexModel> logger, IMemoryCache cache, AppDbContext ctx)
|
public IndexModel(ILogger<IndexModel> logger, IMemoryCache cache, AppDbContext ctx)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -19,28 +18,11 @@ namespace yaflay.ru.Pages
|
|||||||
this.ctx = ctx;
|
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;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class Index1Model : PageModel
|
public class Index1Model : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class PrivacyModel : PageModel
|
public class PrivacyModel : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
@using yaflay.ru
|
@using yawaflua.ru
|
||||||
@namespace yaflay.ru.Pages
|
@namespace yawaflua.ru.Pages
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|||||||
+4
-20
@@ -1,25 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using yaflay.ru;
|
using yawaflua.ru;
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main()
|
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()
|
CreateHostBuilder()
|
||||||
.Build()
|
.Build()
|
||||||
.Run();
|
.Run();
|
||||||
@@ -37,8 +22,7 @@ public class Program
|
|||||||
}
|
}
|
||||||
public static class StaticProgram
|
public static class StaticProgram
|
||||||
{
|
{
|
||||||
public static bool isNull(this object? value)
|
public static bool isNull(this object? value) =>
|
||||||
{
|
value == null;
|
||||||
return value == null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,56 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
"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
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:3236",
|
"applicationUrl": "http://localhost:16072",
|
||||||
"sslPort": 44373
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": ".",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
-40
@@ -5,12 +5,14 @@ using System.Reflection.Metadata.Ecma335;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using DotNetEd.CoreAdmin;
|
using DotNetEd.CoreAdmin;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using yaflay.ru.Auth;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using yaflay.ru.Models;
|
using yawaflua.ru.Auth;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace yaflay.ru
|
namespace yawaflua.ru
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@@ -28,40 +30,16 @@ namespace yaflay.ru
|
|||||||
public Startup()
|
public Startup()
|
||||||
{
|
{
|
||||||
configuration = new ConfigurationBuilder()
|
configuration = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables(prefix: "m.")
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: true)
|
.AddJsonFile("appsettings.json", optional: true)
|
||||||
.Build();
|
.Build();
|
||||||
if (clientId == null | clientSecret == null | redirectUrl == null)
|
|
||||||
{
|
clientId = configuration.GetValue<string>("clientId");
|
||||||
clientId = configuration.GetValue<string>("clientId");
|
clientSecret = configuration.GetValue<string>("clientSecret");
|
||||||
clientSecret = configuration.GetValue<string>("clientSecret");
|
redirectUrl = configuration.GetValue<string>("redirectUrl");
|
||||||
redirectUrl = configuration.GetValue<string>("redirectUrl");
|
connectionString = configuration.GetValue<string>("connectionString");
|
||||||
}
|
ownerId = configuration.GetValue<string[]>("ownerId");
|
||||||
if (connectionString == null)
|
readmeFile = configuration.GetValue<string>("readmeFile");
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
@@ -69,7 +47,7 @@ namespace yaflay.ru
|
|||||||
services.AddControllers()
|
services.AddControllers()
|
||||||
.AddRazorPagesOptions(options =>
|
.AddRazorPagesOptions(options =>
|
||||||
{
|
{
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt");
|
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
||||||
options.Conventions.AddPageRoute("/NotFound", "/404");
|
options.Conventions.AddPageRoute("/NotFound", "/404");
|
||||||
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
||||||
@@ -81,6 +59,8 @@ namespace yaflay.ru
|
|||||||
.AddTransient<ApiKeyAuthantication>()
|
.AddTransient<ApiKeyAuthantication>()
|
||||||
.AddSingleton(configuration)
|
.AddSingleton(configuration)
|
||||||
.AddDbContext<AppDbContext>(c => c.UseNpgsql(connectionString: connectionString))
|
.AddDbContext<AppDbContext>(c => c.UseNpgsql(connectionString: connectionString))
|
||||||
|
.AddSwaggerGen()
|
||||||
|
.AddSingleton(new MemoryCache(new MemoryCacheOptions()))
|
||||||
.AddAuthorization(k =>
|
.AddAuthorization(k =>
|
||||||
{
|
{
|
||||||
k.AddPolicy("DISCORD-OAUTH-PUBLIC", policyBuilder => {
|
k.AddPolicy("DISCORD-OAUTH-PUBLIC", policyBuilder => {
|
||||||
@@ -98,11 +78,11 @@ namespace yaflay.ru
|
|||||||
options.DefaultChallengeScheme = "Bearer";
|
options.DefaultChallengeScheme = "Bearer";
|
||||||
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PRIVATE", "DISCORD-OAUTH-PRIVATE");
|
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PRIVATE", "DISCORD-OAUTH-PRIVATE");
|
||||||
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PUBLIC", "DISCORD-OAUTH-PUBLIC");
|
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PUBLIC", "DISCORD-OAUTH-PUBLIC");
|
||||||
|
options.RequireAuthenticatedSignIn = false;
|
||||||
}).AddScheme<AuthenticationSchemeOptions, ApiKeyAuthantication>("Bearer", options => {});
|
}).AddScheme<AuthenticationSchemeOptions, ApiKeyAuthantication>("Bearer", options => {});
|
||||||
services.AddMvc()
|
services.AddMvc()
|
||||||
.AddRazorPagesOptions(options =>
|
.AddRazorPagesOptions(options =>
|
||||||
{
|
{
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt");
|
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
||||||
options.Conventions.AddPageRoute("/NotFound", "/404");
|
options.Conventions.AddPageRoute("/NotFound", "/404");
|
||||||
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
||||||
@@ -125,6 +105,7 @@ namespace yaflay.ru
|
|||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
|
app.UseSpa(x => x.UseProxyToSpaDevelopmentServer("http://localhost:8080"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@@ -132,17 +113,24 @@ namespace yaflay.ru
|
|||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
app.UseSwagger((options) =>
|
||||||
|
{
|
||||||
|
options.RouteTemplate = "swagger/v1/swagger.json";
|
||||||
|
});
|
||||||
|
app.UseSwaggerUI();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
app.UseCoreAdminCustomTitle("yawaflua");
|
app.UseCoreAdminCustomTitle("yawaflua");
|
||||||
app.UseCoreAdminCustomAuth((k) => Task.FromResult(true));
|
app.UseCoreAdminCustomAuth((k) => Task.FromResult(true));
|
||||||
app.UseCoreAdminCustomUrl("admin/coreadmin");
|
app.UseCoreAdminCustomUrl("admin/coreadmin");
|
||||||
#endif
|
#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 =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapDefaultControllerRoute();
|
endpoints.MapDefaultControllerRoute().AllowAnonymous();
|
||||||
|
endpoints.MapFallbackToFile("/index.html").AllowAnonymous();
|
||||||
|
endpoints.MapSwagger();
|
||||||
endpoints.MapRazorPages();
|
endpoints.MapRazorPages();
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers().AllowAnonymous();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,35 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<UserSecretsId>0c1057bc-b206-4a40-b003-9b6299aa9c64</UserSecretsId>
|
<UserSecretsId>0c1057bc-b206-4a40-b003-9b6299aa9c64</UserSecretsId>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<DockerfileContext>.</DockerfileContext>
|
<DockerfileContext>.</DockerfileContext>
|
||||||
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
|
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
|
||||||
|
<Authors>yawaflua</Authors>
|
||||||
|
<Company>yawaflua</Company>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
|
||||||
|
<Version>8.*-*</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.32" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.3" />
|
||||||
|
<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>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="7.0.4" />
|
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="7.0.4" />
|
||||||
<PackageReference Include="CoreAdmin" Version="2.7.1" />
|
<PackageReference Include="CoreAdmin" Version="2.7.1" />
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"defaultProvider": "cdnjs",
|
||||||
|
"libraries": []
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 647 KiB |
@@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.6.33723.286
|
VisualStudioVersion = 17.6.33723.286
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
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
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "frontend.yawaflua.ru", "..\frontend.yawaflua.ru\frontend.yawaflua.ru.esproj", "{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
Reference in New Issue
Block a user