-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
108 lines (84 loc) · 3.84 KB
/
Program.cs
File metadata and controls
108 lines (84 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System.Data;
using Microsoft.Data.Sqlite;
using RandomAPI.Repository;
using RandomAPI.Services.Webhooks;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IDbConnection>(sp =>
{
var conn = new SqliteConnection("Data Source=PersonalDev.db;Cache=Shared");
conn.Open();
return conn;
});
builder.Services.AddScoped<Func<IDbConnection>>(sp =>
() => sp.GetRequiredService<IDbConnection>());
#region Add Services
//webhook
builder.Services.AddScoped<IWebhookService, WebhookActionService>();
//time clock service
builder.Services.AddSingleton<IHoursService, TimeOutService>();
//db
builder.Services.AddScoped<IEventRepository, EventRepository>();
builder.Services.AddScoped<IWebhookRepository, WebhookRepository>();
#endregion
#region Initialization
//scanner for initializations
builder.Services.Scan(scan => scan
.FromAssemblyOf<IInitializer>()
.AddClasses(c => c.AssignableTo<IInitializer>())
.As<IInitializer>()
.WithScopedLifetime()
);
var app = builder.Build();
//the the end, init the dbs
using (var scope = app.Services.CreateScope())
{
IServiceProvider? serviceProvider = scope.ServiceProvider;
IEnumerable<IInitializer>? initializers = serviceProvider.GetServices<IInitializer>();
if (!initializers.Any())
{
Console.WriteLine("Warning: No services implementing IInitializer were found.");
}
IEnumerable<Task>? initializationTasks = initializers.Select(i => i.InitializeAsync());
await Task.WhenAll(initializationTasks);
}
#endregion
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
// TODO:
// - good logging service. rabapp has an event table, i bet i could do something worse
// date idea generator based on a list of ideas and an energy rating. should have a table of all ideas, endpoints to review what exists, and display the most recent selection from both parties
// idea - email checker that notifies me when a meeting time is moved or canceled for rabapp
//
// - AlertGatewayService
// API Endpoint Goal: POST / alert / ingest
// Brief Description(Project Scope): Centralized Notification Hub with Discord Integration.
// Receives generic webhooks (from Sentry, CI/CD, etc.), standardizes the payload, applies personalized filtering rules, and routes the cleaned alert to your Discord channel using a webhook.
// The service will format the alert into a visually appealing Discord Embed using a library like discord-webhook or requests.
// - HealthCheckAggregator
// API Endpoint Goal: GET / health / summary
// Brief Description(Project Scope): Unified System Status Dashboard.
// Periodically polls the health endpoints (/status or /health) of critical development services (Database, Backend API, CI/CD pipeline).
// Aggregates the results into a single, simplified GREEN/YELLOW/RED status JSON response for quick checking.
public class HealthCheckService { }
// - UniversalSnippetStore
// API Endpoint Goal: POST / snippet and GET /snippet/search
// Brief Description (Project Scope): Personal Developer Knowledge Base.
// A CRUD API to save and retrieve frequently forgotten code snippets, complex CLI commands, and database queries.
// Supports robust searching by language (python, sql) and customizable tags (regex, lambda, auth).
public class UniversalSnippetService { }
//list of strings as languages
//list of strings as tags
//snippet should probably the language(s), list of tags, the code snippet, and a description?