last ...
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
namespace xAiApi.Constants
|
||||||
|
{
|
||||||
|
public struct XAiApiConstants
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Database Descriptor ...
|
||||||
|
public const string XAiApiDbIdentifier = "xAiApiDb";
|
||||||
|
public const string XAiApiMigrationsAssemblyIdentifier = "xAiApi";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using xAiApi.Constants;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xDataService.Models;
|
||||||
|
|
||||||
|
namespace xAiApi.Database
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ai Api Database Descriptor ...
|
||||||
|
/// </summary>
|
||||||
|
public class XAiApiDatabaseDescriptor : XDatabaseDescriptor<XAiApiDbContext>, IXDatabaseDescriptor<XAiApiDbContext>
|
||||||
|
{
|
||||||
|
public XAiApiDatabaseDescriptor() : base(
|
||||||
|
name: XAiApiConstants.XAiApiDbIdentifier,
|
||||||
|
repositories: []
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OptionsBuilder = b => b.MigrationsAssembly(XAiApiConstants.XAiApiMigrationsAssemblyIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using xAiApi.Constants;
|
||||||
|
using xAiModels.Providers;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Db;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Providers;
|
||||||
|
using xStringService.Providers;
|
||||||
|
using xTagService.Providers;
|
||||||
|
|
||||||
|
namespace xAiApi.Database
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Db Context of AiApi ...
|
||||||
|
/// </summary>
|
||||||
|
public class XAiApiDbContext : XDbContext
|
||||||
|
{
|
||||||
|
//
|
||||||
|
#region DbSets ...
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Navigation Property Entities ...
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Constructor ...
|
||||||
|
public XAiApiDbContext(
|
||||||
|
DbContextOptions options,
|
||||||
|
XDataServiceConfiguration config,
|
||||||
|
XEntityRegisterarHandlerService dynamicEntityHandlers
|
||||||
|
) : base(
|
||||||
|
config: config,
|
||||||
|
options: options,
|
||||||
|
database: XAiApiConstants.XAiApiDbIdentifier,
|
||||||
|
dynamicEntityHandlers: dynamicEntityHandlers,
|
||||||
|
dynamicEntityRegisterarsNames: [
|
||||||
|
nameof(XTagEntityRegisterar),
|
||||||
|
nameof(XFileEntityRegisterar),
|
||||||
|
nameof(XStringEntityRegisterar),
|
||||||
|
nameof(XAiMessageEntityRegisterar),
|
||||||
|
nameof(XAiProjectEntityRegisterar),
|
||||||
|
nameof(XAiConversationEntityRegisterar),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Overrides ...
|
||||||
|
//
|
||||||
|
public override void OnXModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
//
|
||||||
|
public override void OnXConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{ }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
+247
-120
@@ -1,132 +1,259 @@
|
|||||||
using System.Reflection;
|
// using xHttpService.DI;
|
||||||
using IdentityModel.AspNetCore.OAuth2Introspection;
|
// using xAiApi.Database;
|
||||||
using xAiApi.Extensions;
|
// using xFileService.DI;
|
||||||
using xCommons.Configurations;
|
// using xDataService.DI;
|
||||||
using xCommons.Extensions;
|
// using xPushService.DI;
|
||||||
using xHttpService.DI;
|
// using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
// using System.Reflection;
|
||||||
using System.Text.Json;
|
// using xAiApi.Extensions;
|
||||||
using xIdentityService.DI;
|
// using xStringService.DI;
|
||||||
|
// using xStorageService.DI;
|
||||||
|
// using xCommons.Extensions;
|
||||||
|
// using xDataService.Models;
|
||||||
|
// using xIdentityService.DI;
|
||||||
|
// using xPushService.Helpers;
|
||||||
|
// using xCommons.Configurations;
|
||||||
|
// using System.Text.Json.Serialization;
|
||||||
|
// using IdentityModel.AspNetCore.OAuth2Introspection;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
namespace xAiApi
|
||||||
|
|
||||||
//
|
|
||||||
#region Register services ...
|
|
||||||
//
|
|
||||||
// Register Validation Provider and all XCommons Module Services ...
|
|
||||||
builder.Services.AddXCommons();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register App Configuration ...
|
|
||||||
builder.Services.AddXAppConfiguration(builder.Configuration);
|
|
||||||
var appConfiguration = builder.Services.GetRegisteredService<XAppConfiguration>();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register Allowed Origins ...
|
|
||||||
builder.Services.AddXCors(appConfiguration.AllowedOrigins);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register Swagger ...
|
|
||||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
||||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
|
||||||
builder.Services.AddXSwagger(builder.Configuration, xmlFilePath: xmlPath);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register HttpService ...
|
|
||||||
builder.Services.AddXHttpService(builder.Configuration);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add Api V1 Versioning ...
|
|
||||||
builder.Services.AddXApiV1Versioning();
|
|
||||||
|
|
||||||
//
|
|
||||||
// OAuthIntrospectin Http Client Handler ...
|
|
||||||
// this is for handling SSLErrors ...
|
|
||||||
builder.Services.AddHttpClient(OAuth2IntrospectionDefaults.BackChannelHttpClientName)
|
|
||||||
.ConfigurePrimaryHttpMessageHandler(() =>
|
|
||||||
{
|
|
||||||
return new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register Authorizations ...
|
|
||||||
builder.Services.AddXAuthorization();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Mapping Controllers ...
|
|
||||||
builder.Services.AddControllers()
|
|
||||||
.AddJsonOptions(x =>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Optional but recommended for .NET 8+:
|
|
||||||
// Allows reading properties case-insensitively (e.g., "myProp" matches "MyProp") ...
|
|
||||||
x.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
|
|
||||||
|
|
||||||
//
|
|
||||||
// This tells STJ to ignore circular references instead of throwing an exception ...
|
|
||||||
x.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Camel Case Naming Policy ...
|
|
||||||
x.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
|
||||||
});
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register XIdentity Service ...
|
|
||||||
builder.Services.AddXIdentityService(
|
|
||||||
configuration: builder.Configuration,
|
|
||||||
lifeTime: ServiceLifetime.Scoped
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
// Creating Application ...
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Using Middlewares ...
|
|
||||||
//
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
CreateHostBuilder(args).Build().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
|
{
|
||||||
|
webBuilder.UseStartup<Startup>();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Use Swagger Middleware ...
|
#region .net 10 Standard ...
|
||||||
app.UseXSwagger();
|
// //
|
||||||
|
// // Create Application Builder ...
|
||||||
|
// var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Force Https Redirection ...
|
// #region Register services ...
|
||||||
app.UseHttpsRedirection();
|
// //
|
||||||
|
// // Register Validation Provider and all XCommons Module Services ...
|
||||||
|
// builder.Services.AddXCommons();
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Using Cors ...
|
// // Register App Configuration ...
|
||||||
app.UseXCors();
|
// builder.Services.AddXAppConfiguration(builder.Configuration);
|
||||||
|
// var appConfiguration = builder.Services.GetRegisteredService<XAppConfiguration>();
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Using Routing ...
|
// // Register Allowed Origins ...
|
||||||
app.UseRouting();
|
// builder.Services.AddXCors(appConfiguration.AllowedOrigins);
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Use xIdentityService ...
|
// // Register Swagger ...
|
||||||
app.UseXIdentityService();
|
// var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
|
// var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
|
// builder.Services.AddXSwagger(builder.Configuration, xmlFilePath: xmlPath);
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Use Authorization ...
|
// // Register HttpService ...
|
||||||
app.UseAuthorization();
|
// builder.Services.AddXHttpService(builder.Configuration);
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Using Endpoints ...
|
// // Add Api V1 Versioning ...
|
||||||
app.UseEndpoints(endpoints =>
|
// builder.Services.AddXApiV1Versioning();
|
||||||
{
|
|
||||||
_ = endpoints.MapControllers();
|
|
||||||
});
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Runing Application ...
|
// // OAuthIntrospectin Http Client Handler ...
|
||||||
app.Run();
|
// // this is for handling SSLErrors ...
|
||||||
|
// builder.Services.AddHttpClient(OAuth2IntrospectionDefaults.BackChannelHttpClientName)
|
||||||
|
// .ConfigurePrimaryHttpMessageHandler(() =>
|
||||||
|
// {
|
||||||
|
// return new HttpClientHandler
|
||||||
|
// {
|
||||||
|
// ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Register Authorizations ...
|
||||||
|
// builder.Services.AddXAuthorization();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Mapping Controllers ...
|
||||||
|
// builder.Services.AddControllers()
|
||||||
|
// .AddJsonOptions(x =>
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Optional but recommended for .NET 8+:
|
||||||
|
// // Allows reading properties case-insensitively (e.g., "myProp" matches "MyProp") ...
|
||||||
|
// x.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // This tells STJ to ignore circular references instead of throwing an exception ...
|
||||||
|
// x.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Camel Case Naming Policy ...
|
||||||
|
// x.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// //
|
||||||
|
// var lifeTime = ServiceLifetime.Scoped;
|
||||||
|
// var repositoryType = xDataService.Constants.XRepositoryType.EF;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Register XIdentity Service ...
|
||||||
|
// builder.Services.AddXIdentityService(
|
||||||
|
// lifeTime: lifeTime,
|
||||||
|
// configuration: builder.Configuration
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Storage Service ...
|
||||||
|
// builder.Services.AddXStorageService(builder.Configuration);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Push Service ...
|
||||||
|
// builder.Services.AddXPushService(
|
||||||
|
// lifeTime: lifeTime,
|
||||||
|
// config: builder.Configuration
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Preparing DataBases ...
|
||||||
|
// var databases = new List<XDatabaseDescriptor>
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Introduce Ai Api Descriptor ...
|
||||||
|
// new XAiApiDatabaseDescriptor()
|
||||||
|
// };
|
||||||
|
// if (databases.HasChild())
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// databases
|
||||||
|
// .ToList()
|
||||||
|
// .ForEach(database =>
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Register DataBase ...
|
||||||
|
// builder.Services.AddXDatabase(
|
||||||
|
// lifeTime: lifeTime,
|
||||||
|
// descriptor: database,
|
||||||
|
// configuration: builder.Configuration
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Register String Service ...
|
||||||
|
// builder.Services.AddXStringService<XAiApiDbContext>(
|
||||||
|
// lifeTime: lifeTime,
|
||||||
|
// repositoryType: repositoryType
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Register File Service ...
|
||||||
|
// builder.Services.AddXFileService<XAiApiDbContext>(
|
||||||
|
// lifeTime: lifeTime,
|
||||||
|
// repositoryType: repositoryType
|
||||||
|
// );
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Creating Application ...
|
||||||
|
// var app = builder.Build();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// #region Using Middlewares ...
|
||||||
|
// //
|
||||||
|
// // Configure the HTTP request pipeline.
|
||||||
|
// var isDevelopmentEnvironment = false;
|
||||||
|
// if (app.Environment.IsDevelopment())
|
||||||
|
// {
|
||||||
|
// isDevelopmentEnvironment = true;
|
||||||
|
// app.UseDeveloperExceptionPage();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Use Swagger Middleware ...
|
||||||
|
// app.UseXSwagger();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Force Https Redirection ...
|
||||||
|
// app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using Cors ...
|
||||||
|
// app.UseXCors();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using Routing ...
|
||||||
|
// app.UseRouting();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Use xIdentityService ...
|
||||||
|
// app.UseXIdentityService();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Use Authorization ...
|
||||||
|
// app.UseAuthorization();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using Endpoints ...
|
||||||
|
// app.UseEndpoints(endpoints =>
|
||||||
|
// {
|
||||||
|
// _ = endpoints.MapControllers();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Use Storage Service ...
|
||||||
|
// app.UseXStorageService();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using DataBase ...
|
||||||
|
// if (databases.HasChild())
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// databases
|
||||||
|
// .ToList()
|
||||||
|
// .ForEach(database =>
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// app.UseXDatabase(
|
||||||
|
// descriptor: database,
|
||||||
|
// isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Use PushService ...
|
||||||
|
// var pushHelper = new XPushServiceHelper();
|
||||||
|
// app.UseXPushService(pushHelper);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using String Service ...
|
||||||
|
// app.UseXStringService(
|
||||||
|
// isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Using File Service ...
|
||||||
|
// app.UseXFileService(
|
||||||
|
// isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
// );
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Runing Application ...
|
||||||
|
// app.Run();
|
||||||
|
#endregion
|
||||||
+245
@@ -0,0 +1,245 @@
|
|||||||
|
using xTagService.DI;
|
||||||
|
using xHttpService.DI;
|
||||||
|
using xAiApi.Database;
|
||||||
|
using xFileService.DI;
|
||||||
|
using xDataService.DI;
|
||||||
|
using xPushService.DI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Reflection;
|
||||||
|
using xAiApi.Extensions;
|
||||||
|
using xStringService.DI;
|
||||||
|
using xStorageService.DI;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xDataService.Models;
|
||||||
|
using xIdentityService.DI;
|
||||||
|
using xPushService.Helpers;
|
||||||
|
using xCommons.Configurations;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
using IdentityModel.AspNetCore.OAuth2Introspection;
|
||||||
|
|
||||||
|
namespace xAiApi
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
private readonly List<XDatabaseDescriptor> databases;
|
||||||
|
private readonly XAiApiDatabaseDescriptor apiDatabaseDescriptor;
|
||||||
|
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Configuration = configuration;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create an Api Descriptor Class Instance ...
|
||||||
|
apiDatabaseDescriptor = new XAiApiDatabaseDescriptor();
|
||||||
|
databases = new List<XDatabaseDescriptor>
|
||||||
|
{
|
||||||
|
apiDatabaseDescriptor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Register Validation Provider and all XCommons Module Services ...
|
||||||
|
services.AddXCommons();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register App Configuration ...
|
||||||
|
services.AddXAppConfiguration(Configuration);
|
||||||
|
var appConfiguration = services.GetRegisteredService<XAppConfiguration>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Allowed Origins ...
|
||||||
|
services.AddXCors(appConfiguration.AllowedOrigins);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Swagger ...
|
||||||
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
|
services.AddXSwagger(Configuration, xmlFilePath: xmlPath);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register HttpService ...
|
||||||
|
services.AddXHttpService(Configuration);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add Api V1 Versioning ...
|
||||||
|
services.AddXApiV1Versioning();
|
||||||
|
|
||||||
|
//
|
||||||
|
// OAuthIntrospectin Http Client Handler ...
|
||||||
|
// this is for handling SSLErrors ...
|
||||||
|
services.AddHttpClient(OAuth2IntrospectionDefaults.BackChannelHttpClientName)
|
||||||
|
.ConfigurePrimaryHttpMessageHandler(() =>
|
||||||
|
{
|
||||||
|
return new HttpClientHandler
|
||||||
|
{
|
||||||
|
ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Authorizations ...
|
||||||
|
services.AddXAuthorization();
|
||||||
|
|
||||||
|
//
|
||||||
|
services.AddControllers()
|
||||||
|
.AddNewtonsoftJson(x =>
|
||||||
|
{
|
||||||
|
x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||||
|
x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
var lifeTime = ServiceLifetime.Scoped;
|
||||||
|
var repositoryType = xDataService.Constants.XRepositoryType.EF;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register XIdentity Service ...
|
||||||
|
services.AddXIdentityService(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
configuration: Configuration
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Storage Service ...
|
||||||
|
services.AddXStorageService(Configuration);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Push Service ...
|
||||||
|
services.AddXPushService(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
config: Configuration
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Preparing DataBases ...
|
||||||
|
if (databases.HasChild())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
databases
|
||||||
|
.ToList()
|
||||||
|
.ForEach(database =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Register DataBase ...
|
||||||
|
services.AddXDatabase(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
descriptor: database,
|
||||||
|
configuration: Configuration
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register String Service ...
|
||||||
|
services.AddXStringService<XAiApiDbContext>(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
repositoryType: repositoryType
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Tag Service ...
|
||||||
|
services.AddXTagService<XAiApiDbContext>(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
repositoryType: repositoryType
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register File Service ...
|
||||||
|
services.AddXFileService<XAiApiDbContext>(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
repositoryType: repositoryType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
var isDevelopmentEnvironment = false;
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
isDevelopmentEnvironment = true;
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Swagger Middleware ...
|
||||||
|
app.UseXSwagger();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Force Https Redirection ...
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using Cors ...
|
||||||
|
app.UseXCors();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using Routing ...
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use xIdentityService ...
|
||||||
|
app.UseXIdentityService();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Authorization ...
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
//
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Storage Service ...
|
||||||
|
app.UseXStorageService();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use PushService ...
|
||||||
|
var pushHelper = new XPushServiceHelper();
|
||||||
|
app.UseXPushService(pushHelper);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using DataBase ...
|
||||||
|
if (databases.HasChild())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
databases
|
||||||
|
.ToList()
|
||||||
|
.ForEach(database =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
app.UseXDatabase(
|
||||||
|
descriptor: database,
|
||||||
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using String Service ...
|
||||||
|
app.UseXStringService(
|
||||||
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using XTag Service ...
|
||||||
|
app.UseXTagService(
|
||||||
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using File Service ...
|
||||||
|
app.UseXFileService(
|
||||||
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-1
@@ -24,6 +24,30 @@
|
|||||||
"DisableSSLCheck": true,
|
"DisableSSLCheck": true,
|
||||||
"DefaultClientTimeout": -1
|
"DefaultClientTimeout": -1
|
||||||
},
|
},
|
||||||
|
"DataServiceConfiguration": {
|
||||||
|
"Databases": {
|
||||||
|
"xAiApiDb": {
|
||||||
|
"Provider": "SQLITE",
|
||||||
|
"ConnectionString": "Filename=./Db/XAiApi.db",
|
||||||
|
"SeedItems": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"EnableTracking": true,
|
||||||
|
"EnableSoftDelete": true,
|
||||||
|
"EnableDetailedErrors": false,
|
||||||
|
"SeedingMode": "AddIfNotExists",
|
||||||
|
"EnableSensitiveDataLogging": true,
|
||||||
|
"PagingConfiguration": {
|
||||||
|
"DefaultPageSize": 20,
|
||||||
|
"MaxAvailablePageSize": 400,
|
||||||
|
"MinAvailablePageSize": 5
|
||||||
|
},
|
||||||
|
"GraphQLBasePath": "/graphs"
|
||||||
|
},
|
||||||
|
"PushServiceConfiguration": {
|
||||||
|
"BaseRoute": "hubs",
|
||||||
|
"AddSupportMessageProtocol": true
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
@@ -31,4 +55,4 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
+23
-2
@@ -4,12 +4,13 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>13.0</LangVersion>
|
<LangVersion>12.0</LangVersion>
|
||||||
<Authors>Hadi Khazaee Asl</Authors>
|
<Authors>Hadi Khazaee Asl</Authors>
|
||||||
<Company>SaherElm IT Center</Company>
|
<Company>SaherElm IT Center</Company>
|
||||||
<PackageId>xSaherElm.xAiApi</PackageId>
|
<PackageId>xSaherElm.xAiApi</PackageId>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<!-- <TargetFramework>netcoreapp3.1</TargetFramework> -->
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
|
||||||
<Description>
|
<Description>
|
||||||
a WebAPI Project which contains all Business Logic of xSaherElm Project's AI.
|
a WebAPI Project which contains all Business Logic of xSaherElm Project's AI.
|
||||||
@@ -36,12 +37,19 @@
|
|||||||
<!-- Local Dependencies -->
|
<!-- Local Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../Modules/xCommons/xCommons.csproj" />
|
<ProjectReference Include="../Modules/xCommons/xCommons.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xAiModels/xAiModels.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xTagService/xTagService.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xDataService/xDataService.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xPushService/xPushService.csproj" />
|
||||||
<ProjectReference Include="../Modules/xHttpService/xHttpService.csproj" />
|
<ProjectReference Include="../Modules/xHttpService/xHttpService.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xFileService/xFileService.csproj" />
|
||||||
|
<ProjectReference Include="../Modules/xStorageService/xStorageService.csproj" />
|
||||||
<ProjectReference Include="../Modules/xIdentityHelper/xIdentityHelper.csproj" />
|
<ProjectReference Include="../Modules/xIdentityHelper/xIdentityHelper.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Dependencies -->
|
<!-- Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.11" />
|
||||||
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="5.0.0" />
|
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -52,4 +60,17 @@
|
|||||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Ef Core -->
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Create Required Folders -->
|
||||||
|
<Target Name="CreateRequiredFolder" AfterTargets="AfterPublish">
|
||||||
|
<MakeDir Directories="$(PublishDir)wwwroot" Condition="!Exists('$(PublishDir)wwwroot')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user