feat: initial commit

This commit is contained in:
2025-11-24 14:00:13 -05:00
commit 050f0bc935
24 changed files with 1512 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
using Microsoft.EntityFrameworkCore;
using SharpbinV3.Data.Entities;
namespace SharpbinV3.Data
{
public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<User> Users => Set<User>();
public DbSet<Paste> Pastes => Set<Paste>();
}
}
+31
View File
@@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace SharpbinV3.Data.Entities
{
[Index(nameof(PID), IsUnique = true)]
[Index(nameof(UUID), IsUnique = true)]
[Index(nameof(ID), IsUnique = true)]
[Index(nameof(AuthorUUID))]
[Index(nameof(ExpiresAt))]
[Index(nameof(Views))]
[Index(nameof(Visiblity))]
public sealed class Paste
{
[Key]
public int PID { get; set; }
public required string UUID { get; set; } // uuid v7 includes timestamp, this counts as created at
public required string ID { get; set; }
public string? Title { get; set; }
public required string AuthorUUID { get; set; } // uuid of the user who created the paste, or "ANON" for anonymous pastes
public User? User { get; set; }
public required string FilePath { get; set; }
public long? EditedAt { get; set; }
public int Size { get; set; } // stored size (may be compressed)
public int TrueSize { get; set; } // uncompressed size
public int Views { get; set; }
public string? Syntax { get; set; }
public int Visiblity { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private
public long ExpiresAt { get; set; } // timestamp of when the paste expires, or 0 for never
}
}
+23
View File
@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
using System.ComponentModel.DataAnnotations;
namespace SharpbinV3.Data.Entities
{
[Index(nameof(UID), IsUnique = true)]
[Index(nameof(UUID), IsUnique = true)]
public sealed class User
{
[Key]
public int UID { get; set; }
public required Guid UUID { get; set; } = Guid.CreateVersion7(); // uuid v7 includes timestamp
public required string Username { get; set; }
public required string PasswordHash { get; set; }
public string? Email { get; set; }
public string? DisplayName { get; set; }
public long? LastLogin { get; set; }
public int Type { get; set; } = 0; // 0 = regular user, 1 = moderator, 255 = admin
public int Visiblity { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private
public List<Paste> Pastes { get; set; } = [];
}
}