source: Farmatiko/Startup.cs@ 171f106

Last change on this file since 171f106 was 171f106, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Add BaseEntity class and it's inheritance

  • Property mode set to 100644
File size: 2.6 KB
Line 
1using Microsoft.AspNetCore.Builder;
2using Microsoft.AspNetCore.Hosting;
3using Microsoft.AspNetCore.SpaServices.AngularCli;
4using Microsoft.Extensions.Configuration;
5using Microsoft.Extensions.DependencyInjection;
6using Microsoft.Extensions.Hosting;
7using FarmatikoData;
8using Microsoft.EntityFrameworkCore;
9
10namespace Farmatiko
11{
12 public class Startup
13 {
14 public Startup(IConfiguration configuration)
15 {
16 Configuration = configuration;
17 }
18
19 public IConfiguration Configuration { get; }
20
21 // This method gets called by the runtime. Use this method to add services to the container.
22 public void ConfigureServices(IServiceCollection services)
23 {
24 services.AddControllersWithViews();
25 // In production, the Angular files will be served from this directory
26 services.AddSpaStaticFiles(configuration =>
27 {
28 configuration.RootPath = "ClientApp/dist";
29 });
30 var connectionString = Configuration.GetSection("ConnectionStrings").GetValue<string>("FarmatikoConnection");
31 services.AddEntityFrameworkNpgsql().AddDbContext<FarmatikoDataContext>(opt => opt.UseNpgsql(connectionString));
32
33 }
34
35 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
36 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
37 {
38 if (env.IsDevelopment())
39 {
40 app.UseDeveloperExceptionPage();
41 }
42 else
43 {
44 app.UseExceptionHandler("/Error");
45 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
46 app.UseHsts();
47 }
48
49 app.UseHttpsRedirection();
50 app.UseStaticFiles();
51 if (!env.IsDevelopment())
52 {
53 app.UseSpaStaticFiles();
54 }
55
56 app.UseRouting();
57
58 app.UseEndpoints(endpoints =>
59 {
60 endpoints.MapControllerRoute(
61 name: "default",
62 pattern: "{controller}/{action=Index}/{id?}");
63 });
64
65 app.UseSpa(spa =>
66 {
67 // To learn more about options for serving an Angular SPA from ASP.NET Core,
68 // see https://go.microsoft.com/fwlink/?linkid=864501
69
70 spa.Options.SourcePath = "ClientApp";
71
72 if (env.IsDevelopment())
73 {
74 spa.UseAngularCliServer(npmScript: "start");
75 }
76 });
77 }
78 }
79}
Note: See TracBrowser for help on using the repository browser.