-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
35 lines (32 loc) · 975 Bytes
/
Program.cs
File metadata and controls
35 lines (32 loc) · 975 Bytes
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
using Photon.ImageDb.Jobs;
using Photon.ImageDb.Middleware;
using Quartz;
using Quartz.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
Directory.CreateDirectory("Images");
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<AuthenticationMiddleware>();
builder.Services.AddQuartz(q =>
{
var jobKey = new JobKey("DeleteImagesJob");
q.AddJob<DeleteImagesJob>(opts => opts.WithIdentity(jobKey));
q.AddTrigger(opts => opts
.ForJob(jobKey)
.WithIdentity("DeleteImagesJob-trigger")
.WithSimpleSchedule(x => x.WithIntervalInHours(4).RepeatForever()));
});
builder.Services.AddQuartzServer(options =>
{
options.WaitForJobsToComplete = true;
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseMiddleware<AuthenticationMiddleware>();
app.MapControllers();
app.Run();