Compare commits
2 commits
3cad9b1d13
...
5073eb60f3
Author | SHA1 | Date | |
---|---|---|---|
5073eb60f3 | |||
608e9a7f9e |
19 changed files with 68 additions and 54 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "myhm-commission",
|
||||
"name": "Looking Glass",
|
||||
"dockerComposeFile": "../docker-compose.dev.yml",
|
||||
"service": "myhm-commission-dev",
|
||||
"service": "looking-glass-dev",
|
||||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
|
@ -23,7 +23,8 @@
|
|||
"redhat.vscode-xml",
|
||||
"aaron-bond.better-comments",
|
||||
"donjayamanne.githistory",
|
||||
"eamodio.gitlens"
|
||||
"eamodio.gitlens",
|
||||
"ms-azuretools.vscode-docker"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -5,10 +5,10 @@
|
|||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C#: myhm-commission",
|
||||
"name": "C#: Looking Glass",
|
||||
"type": "dotnet",
|
||||
"request": "launch",
|
||||
"projectPath": "${workspaceFolder}/myhm-commission.csproj"
|
||||
"projectPath": "${workspaceFolder}/LookingGlass.csproj"
|
||||
}
|
||||
|
||||
]
|
||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"dotnet.defaultSolution": "myhm-commission.sln",
|
||||
"dotnet.defaultSolution": "LookingGlass.sln",
|
||||
"editor.formatOnSave": true,
|
||||
"[csharp]": {
|
||||
"editor.defaultFormatter": "csharpier.csharpier-vscode",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Contributing to $WIP
|
||||
# Contributing to Looking Glass
|
||||
|
||||
Thanks for taking the time to contribute to $WIP! Please read through this document to ensure that your contribution is in compliance with our guidelines. We are excited to have you contribute to our project!
|
||||
Thanks for taking the time to contribute to Looking Glass! Please read through this document to ensure that your contribution is in compliance with our guidelines. We are excited to have you contribute to our project!
|
||||
|
||||
## Conventional Commits
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace Myhm.Data
|
||||
namespace LookingGlass.Data
|
||||
{
|
||||
public class MyhmConfiguration
|
||||
public class ApplicationSettings
|
||||
{
|
||||
public required string AuthToken { get; init; }
|
||||
public required string DatabaseConnectionString { get; init; }
|
|
@ -1,12 +1,13 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using static EnumStringValues.EnumExtensions;
|
||||
|
||||
namespace Myhm.Data
|
||||
namespace LookingGlass.Data
|
||||
{
|
||||
public class MyhmContext(DbContextOptions<MyhmContext> options) : DbContext(options)
|
||||
public class ApplicationContext(DbContextOptions<ApplicationContext> options)
|
||||
: DbContext(options)
|
||||
{
|
||||
public DbSet<Moderation> Moderation { get; set; } = default!;
|
||||
public DbSet<Token> Token { get; set; } = default!;
|
||||
public DbSet<User> User { get; set; } = default!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using EnumStringValues;
|
||||
|
||||
namespace Myhm.Data;
|
||||
namespace LookingGlass.Data;
|
||||
|
||||
public class Moderation
|
||||
{
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
namespace Myhm.Data;
|
||||
|
||||
public class Token
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string String { get; set; } = default!;
|
||||
public int DiscordUserId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
22
Data/User.cs
Normal file
22
Data/User.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
namespace LookingGlass.Data;
|
||||
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Token { get; set; } = default!;
|
||||
public int DiscordUserId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public bool WriteAccess { get; set; } = false;
|
||||
public bool Disabled { get; set; } = false;
|
||||
|
||||
public static User FromToken(string token, ApplicationContext context)
|
||||
{
|
||||
User user =
|
||||
context.User.First(u => u.Token == token) ?? throw new Exception("User not found");
|
||||
if (user.Disabled)
|
||||
{
|
||||
throw new Exception("User not found");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
10
Dockerfile
10
Dockerfile
|
@ -7,17 +7,17 @@ EXPOSE 8081
|
|||
FROM mcr.microsoft.com/dotnet/sdk:9.0@sha256:84fd557bebc64015e731aca1085b92c7619e49bdbe247e57392a43d92276f617 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["myhm-commission.csproj", "./"]
|
||||
RUN dotnet restore "myhm-commission.csproj"
|
||||
COPY ["LookingGlass.csproj", "./"]
|
||||
RUN dotnet restore "LookingGlass.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/"
|
||||
RUN dotnet build "myhm-commission.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
RUN dotnet build "LookingGlass.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "myhm-commission.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
RUN dotnet publish "LookingGlass.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "myhm-commission.dll"]
|
||||
ENTRYPOINT ["dotnet", "LookingGlass.dll"]
|
||||
|
|
|
@ -209,7 +209,7 @@ If you develop a new program, and you want it to be of the greatest possible use
|
|||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
myhm-commission
|
||||
looking-glass
|
||||
Copyright (C) 2025 MYHM
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
@ -222,7 +222,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
myhm-commission Copyright (C) 2025 MYHM
|
||||
looking-glass Copyright (C) 2025 MYHM
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Myhm</RootNamespace>
|
||||
<RootNamespace>LookingGlass</RootNamespace>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "myhm-commission", "myhm-commission.csproj", "{D39B0551-B762-4BD9-81DC-FF49FB7F8439}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LookingGlass", "LookingGlass.csproj", "{D39B0551-B762-4BD9-81DC-FF49FB7F8439}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
14
Program.cs
14
Program.cs
|
@ -1,14 +1,14 @@
|
|||
using System.Reflection;
|
||||
using LookingGlass.Data;
|
||||
using LookingGlass.Util.SwaggerTheme;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Myhm.Data;
|
||||
using Myhm.Util.SwaggerTheme;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var config = builder.Configuration.GetSection("Configuration").Get<MyhmConfiguration>();
|
||||
builder.Services.Configure<MyhmConfiguration>(builder.Configuration.GetSection("Configuration"));
|
||||
var config = builder.Configuration.GetSection("Configuration").Get<ApplicationSettings>();
|
||||
builder.Services.Configure<ApplicationSettings>(builder.Configuration.GetSection("Configuration"));
|
||||
|
||||
if ((config?.AuthToken?.Length ?? 0) < 64 && !builder.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -17,8 +17,8 @@ if ((config?.AuthToken?.Length ?? 0) < 64 && !builder.Environment.IsDevelopment(
|
|||
);
|
||||
}
|
||||
|
||||
builder.Services.AddDbContextFactory<MyhmContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("MyhmContext"))
|
||||
builder.Services.AddDbContextFactory<ApplicationContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("ApplicationContext"))
|
||||
);
|
||||
|
||||
if (config?.UseSentry == true)
|
||||
|
@ -34,7 +34,7 @@ builder.Services.AddSwaggerGen(opts =>
|
|||
"v1",
|
||||
new OpenApiInfo
|
||||
{
|
||||
Title = "Myhm API",
|
||||
Title = "Looking Glass API",
|
||||
Version = "v1",
|
||||
Description = "",
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
# myhm-commission
|
||||
# looking-glass
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Myhm.Util;
|
||||
namespace LookingGlass.Util;
|
||||
|
||||
public class RandomStringGenerator
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using AspNetCore.Swagger.Themes;
|
||||
|
||||
namespace Myhm.Util.SwaggerTheme;
|
||||
namespace LookingGlass.Util.SwaggerTheme;
|
||||
|
||||
public class CustomStyle : ModernStyle
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
services:
|
||||
myhm-commission-dev:
|
||||
container_name: myhm-commission-dev
|
||||
looking-glass-dev:
|
||||
container_name: looking-glass-dev
|
||||
image: mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm@sha256:f84f5dc61134aacd099c03f58663994da48047a6f43b9d5ba446a5b5ad2074aa
|
||||
environment:
|
||||
CONFIGURATION__AUTHTOKEN: "hi"
|
||||
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://myhm-commission:myhm-commission@postgres:5432/myhm-commission"
|
||||
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://looking-glass:looking-glass@postgres:5432/looking-glass"
|
||||
ASPNETCORE_URLS: "http://0.0.0.0:8000"
|
||||
LOGGING__LOGLEVEL_DEFAULT: "Trace"
|
||||
CONFIGURATION__USESENTRY: false
|
||||
|
@ -15,7 +15,7 @@ services:
|
|||
command: sleep infinity
|
||||
|
||||
database:
|
||||
container_name: myhm-commission-db
|
||||
container_name: looking-glass-db
|
||||
extends:
|
||||
service: database
|
||||
file: ./docker-compose.yml
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
services:
|
||||
myhm-commission:
|
||||
image: www.coastalcommits.com/cswimr/myhm-commission:latest
|
||||
looking-glass:
|
||||
image: www.coastalcommits.com/cswimr/lookingglass:latest
|
||||
ports:
|
||||
- 8000:8000
|
||||
environment:
|
||||
|
@ -20,7 +20,7 @@ services:
|
|||
|
||||
# The only current valid value is `PostgresSQL`. This is used to determine which database type to use.
|
||||
CONFIGURATION__DATABASETYPE: "PostgresSQL"
|
||||
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://myhm-commission:myhm-commission@postgres:5432/myhm-commission"
|
||||
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://LookingGlass:LookingGlass@postgres:5432/LookingGlass"
|
||||
|
||||
# Determines the log level for the application's default logger.
|
||||
# Valid values are `Trace`, `Debug`, `Information`, `Warning`, `Error`, and `Critical`.
|
||||
|
@ -41,13 +41,13 @@ services:
|
|||
CONFIGURATION__USESWAGGER: true
|
||||
|
||||
database:
|
||||
container_name: myhm-commission-db
|
||||
container_name: looking-glass-db
|
||||
image: postgres:17.2@sha256:87ec5e0a167dc7d4831729f9e1d2ee7b8597dcc49ccd9e43cc5f89e808d2adae
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: myhm-commission
|
||||
POSTGRES_PASSWORD: myhm-commission
|
||||
POSTGRES_DB: myhm-commission
|
||||
POSTGRES_USER: LookingGlass
|
||||
POSTGRES_PASSWORD: LookingGlass
|
||||
POSTGRES_DB: LookingGlass
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue