Ignore:
Timestamp:
09/15/26 21:15:53 (8 days ago)
Author:
Stefan-Saveski <stefansaveski19@…>
Branches:
master
Children:
a12988e, c42181c
Parents:
10009b9
Message:
  • ready for presentation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Program.cs

    r10009b9 rea40556  
    22using System.Text.Json.Serialization;
    33using iknow_api.Data;
     4using iknow_api.Models;
    45using iknow_api.Repositories;
    56using iknow_api.Services;
     
    5960builder.Services.AddOpenApi();
    6061
    61 // Register DbContext
     62// Register DbContext.
     63// The database lives behind the SSH tunnel: tunnel_scripta.cmd maps
     64// localhost:9999 to the faculty Postgres server. Start it before the API.
     65// The enum labels come from sql/ddl.sql, so each CLR enum is mapped onto its
     66// Postgres type by name; PgEnumLabels covers the members whose label is not
     67// simply the lowercased member name.
    6268builder.Services.AddDbContext<AppDbContext>(options =>
    63     options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
     69    options.UseNpgsql(
     70        builder.Configuration.GetConnectionString("DefaultConnection"),
     71        npgsql =>
     72        {
     73            npgsql.MapEnum<UserRole>("user_role", AppDbContext.ProjectSchema, PgEnumLabels.UserRole);
     74            npgsql.MapEnum<HighSchoolType>("hs_type", AppDbContext.ProjectSchema, PgEnumLabels.Lowercase);
     75            npgsql.MapEnum<Quota>("quota_type", AppDbContext.ProjectSchema, PgEnumLabels.Lowercase);
     76            npgsql.MapEnum<sType>("semester_type", AppDbContext.ProjectSchema, PgEnumLabels.Lowercase);
     77            npgsql.MapEnum<Grade>("grade_type", AppDbContext.ProjectSchema, PgEnumLabels.Grade);
     78        }));
    6479
    6580// Register your services
     
    7186builder.Services.AddScoped<IUserRepository, UserRepository>();
    7287builder.Services.AddScoped<IRefreshTokenRepository, RefreshTokenRepository>();
     88builder.Services.AddScoped<IProfRepository, ProfRepository>();
     89builder.Services.AddScoped<IProfService, ProfService>();
     90builder.Services.AddScoped<IEnrollmentService, EnrollmentService>();
     91builder.Services.AddScoped<IAdminService, AdminService>();
    7392builder.Services.AddAuthorization();
    7493var app = builder.Build();
Note: See TracChangeset for help on using the changeset viewer.