2fb86a435e
ASP.NET Core 10 Razor Pages + PostgreSQL/EF Core. RTL Persian, Jalali dates, self-hosted Vazirmatn, teal/coral brand. Features: - Shift listings: browse/filter (city, district, role, type, pay), weekly Jalali calendar, detail + interest handoff, near-me distance sort - Hiring (استخدام) listings with employment type + salary range - Pattern-engine recommendations + anonymous interest tracking (visitor cookie) - Heuristic Persian listing-parser + admin queue (raw channel post → shift/job) - Phone-OTP cookie auth + visitor-history linking + profile Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System.Text.Encodings.Web;
|
|
using System.Text.Unicode;
|
|
using JobsMedical.Web.Data;
|
|
using JobsMedical.Web.Services;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorPages();
|
|
|
|
// Interest tracking + recommendation engine.
|
|
builder.Services.AddHttpContextAccessor();
|
|
builder.Services.AddMemoryCache();
|
|
builder.Services.AddScoped<VisitorContext>();
|
|
builder.Services.AddScoped<InterestService>();
|
|
builder.Services.AddScoped<RecommendationService>();
|
|
builder.Services.AddScoped<OtpService>();
|
|
// Listing parser: heuristic now; swap for an LLM-backed IListingParser later.
|
|
builder.Services.AddSingleton<IListingParser, HeuristicListingParser>();
|
|
|
|
// Phone-OTP cookie auth.
|
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
|
.AddCookie(o =>
|
|
{
|
|
o.LoginPath = "/Account/Login";
|
|
o.AccessDeniedPath = "/Account/Login";
|
|
o.ExpireTimeSpan = TimeSpan.FromDays(30);
|
|
o.SlidingExpiration = true;
|
|
});
|
|
|
|
// Emit Persian/Arabic characters directly in HTML instead of \u-style entities.
|
|
builder.Services.AddSingleton(HtmlEncoder.Create(
|
|
UnicodeRanges.BasicLatin, UnicodeRanges.Arabic, UnicodeRanges.ArabicSupplement,
|
|
UnicodeRanges.ArabicExtendedA, UnicodeRanges.GeneralPunctuation));
|
|
|
|
builder.Services.AddDbContext<AppDbContext>(opt =>
|
|
opt.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Apply migrations + seed on startup (fine for MVP single-instance deploy).
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
|
db.Database.Migrate();
|
|
await SeedData.EnsureSeededAsync(db);
|
|
}
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseRouting();
|
|
|
|
// Assign every visitor a stable cookie id so we can track interest from the first visit.
|
|
app.UseMiddleware<VisitorCookieMiddleware>();
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapStaticAssets();
|
|
app.MapRazorPages()
|
|
.WithStaticAssets();
|
|
|
|
app.Run();
|