James Tombleson
521940ca4f
* exposing connectionStrings to controllers * First controller added to start testing * corrected param to be page not age * new model to map connection strings to for the controllers * HelloWorldJob uses options now to make hangfire happy * improved the html reader to find some rss feeds and start to extract the body of the content * moved html parser to its own namespace and make a sub client to process theh header * helpful vsc changes * updated rss watcher to include the sourceId so it can be added to the db call * updated tests to reflect changes * updated gitignore to avoid trash and moved over my makefile * More routes and added serilog * adding more database calls for the controllers * Updated interfaces for the tables * Added Serilog to jobs * removed default files * Added more routes and added DTO * Added DTO objects and SourceType Consts for easy usage * updated discord model name to follow the pattern * updated formatting * new dto objects and Subscriptions repo interface * added subscription db and api calls * focusing on the twitter tags as most sites focus on them * updated test to pull a html based feed
75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using Hangfire;
|
|
using Hangfire.MemoryStorage;
|
|
using Serilog;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
using Newsbot.Collector.Domain.Models;
|
|
using Newsbot.Collector.Domain.Consts;
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.WriteTo.Console()
|
|
.CreateLogger();
|
|
|
|
Log.Information("Starting up");
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Define Logger
|
|
builder.Host.UseSerilog(); // <-- Add this line
|
|
|
|
// Build the conifg
|
|
var config = GetConfiguration();
|
|
builder.Configuration.AddConfiguration(config);
|
|
|
|
// Configure Hangfire
|
|
builder.Services.AddHangfire(f => f.UseMemoryStorage());
|
|
builder.Services.AddHangfireServer();
|
|
GlobalConfiguration.Configuration.UseSerilogLogProvider();
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
builder.Services.Configure<ConnectionStrings>(config.GetSection("ConnectionStrings"));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseHangfireDashboard();
|
|
SetupRecurringJobs(config, Log.Logger);
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|
|
|
|
|
|
static IConfiguration GetConfiguration()
|
|
{
|
|
return new ConfigurationBuilder()
|
|
.AddJsonFile("appsettings.json", true)
|
|
.AddEnvironmentVariables()
|
|
.Build();
|
|
}
|
|
|
|
static void SetupRecurringJobs(IConfiguration configuration, Serilog.ILogger logger)
|
|
{
|
|
RecurringJob.AddOrUpdate<HelloWorldJob>("Example", x => x.InitAndExecute(new HelloWorldJobOptions
|
|
{
|
|
Message = "Hello from the background!"
|
|
}), "0/1 * * * *");
|
|
RecurringJob.AddOrUpdate<RssWatcherJob>("RSS", x => x.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionString = configuration.GetSection(ConfigConnectionStringConst.Database).Value ?? ""
|
|
}), "15 0-23 * * *");
|
|
}
|