2021-04-02 17:28:07 +05:00
|
|
|
using AsbCloudInfrastructure;
|
2021-04-09 17:59:07 +05:00
|
|
|
using AsbCloudWebApi.SignalR;
|
2021-04-02 17:28:07 +05:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
services.AddControllers();
|
|
|
|
|
2021-05-20 11:17:55 +05:00
|
|
|
services.AddSwagger();
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
services.AddInfrastructure(Configuration);
|
|
|
|
|
2021-05-20 11:17:55 +05:00
|
|
|
services.AddJWTAuthentication();
|
2021-04-08 17:54:02 +05:00
|
|
|
|
|
|
|
services.AddSignalR();
|
|
|
|
|
|
|
|
services.AddCors(options =>
|
|
|
|
{
|
|
|
|
options.AddPolicy("ClientPermission", policy =>
|
|
|
|
{
|
|
|
|
policy.AllowAnyHeader()
|
|
|
|
.AllowAnyMethod()
|
2021-05-20 14:30:25 +05:00
|
|
|
.WithOrigins(
|
|
|
|
"http://0.0.0.0:3000",
|
2021-05-25 11:49:13 +05:00
|
|
|
"http://*:3000",
|
2021-05-20 14:30:25 +05:00
|
|
|
"http://localhost:3000",
|
|
|
|
"http://0.0.0.0:5000",
|
2021-05-25 11:49:13 +05:00
|
|
|
"http://*:5000",
|
2021-05-20 14:30:25 +05:00
|
|
|
"http://localhost:5000"
|
|
|
|
)
|
|
|
|
.AllowCredentials();
|
2021-04-08 17:54:02 +05:00
|
|
|
});
|
|
|
|
});
|
2021-04-02 17:28:07 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
{
|
2021-04-08 17:54:02 +05:00
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1");
|
2021-04-02 17:28:07 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
//app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
2021-04-08 17:54:02 +05:00
|
|
|
app.UseCors("ClientPermission");
|
2021-04-02 17:28:07 +05:00
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthentication();
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
2021-04-08 17:54:02 +05:00
|
|
|
endpoints.MapHub<TelemetryHub>("/hubs/telemetry");
|
2021-05-20 11:07:45 +05:00
|
|
|
endpoints.MapHub<ReportsHub>("/hubs/reports");
|
2021-04-02 17:28:07 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|