-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (42 loc) · 1.52 KB
/
Program.cs
File metadata and controls
53 lines (42 loc) · 1.52 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
using FastEndpoints;
using FastEndpoints.Swagger;
using Microsoft.AspNetCore.Builder;
using UniversityEnrollmentSystem.Application.Interfaces;
using UniversityEnrollmentSystem.Application.Services;
using UniversityEnrollmentSystem.Domain.Interfaces;
using UniversityEnrollmentSystem.Infrastructure.Repositories;
var builder = WebApplication.CreateBuilder(args);
// Add FastEndpoints
builder.Services.AddFastEndpoints();
// Add Swagger
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Add Authorization services
builder.Services.AddAuthorization();
// Register Services
builder.Services.AddScoped<IStudentService, StudentService>();
builder.Services.AddScoped<IClassService, ClassService>();
builder.Services.AddScoped<IEnrollmentService, EnrollmentService>();
builder.Services.AddScoped<IMarkService, MarkService>();
// Register Repositories
builder.Services.AddSingleton<IStudentRepository, StudentRepository>();
builder.Services.AddSingleton<IClassRepository, ClassRepository>();
builder.Services.AddSingleton<IEnrollmentRepository, EnrollmentRepository>();
builder.Services.AddSingleton<IMarkRepository, MarkRepository>();
var app = builder.Build();
// Configure middleware pipeline
if (app.Environment.IsDevelopment())
{
app.UseDefaultExceptionHandler();
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
// Use FastEndpoints
app.UseFastEndpoints(c =>
{
c.Endpoints.RoutePrefix = "api";
c.Serializer.Options.PropertyNamingPolicy = null;
});
app.Run();