source: Farmatiko/Startup.cs@ 0c48bbb

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

Add migration and DeletedOn property

  • Property mode set to 100644
File size: 2.7 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
32 services.AddEntityFrameworkNpgsql().AddDbContext<FarmatikoDataContext>(opt => {
33 opt.UseNpgsql(connectionString);
34 });
35
36 }
37
38 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
39 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
40 {
41 if (env.IsDevelopment())
42 {
43 app.UseDeveloperExceptionPage();
44 }
45 else
46 {
47 app.UseExceptionHandler("/Error");
48 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
49 app.UseHsts();
50 }
51
52 app.UseHttpsRedirection();
53 app.UseStaticFiles();
54 if (!env.IsDevelopment())
55 {
56 app.UseSpaStaticFiles();
57 }
58
59 app.UseRouting();
60
61 app.UseEndpoints(endpoints =>
62 {
63 endpoints.MapControllerRoute(
64 name: "default",
65 pattern: "{controller}/{action=Index}/{id?}");
66 });
67
68 app.UseSpa(spa =>
69 {
70 // To learn more about options for serving an Angular SPA from ASP.NET Core,
71 // see https://go.microsoft.com/fwlink/?linkid=864501
72
73 spa.Options.SourcePath = "ClientApp";
74
75 if (env.IsDevelopment())
76 {
77 spa.UseAngularCliServer(npmScript: "start");
78 }
79 });
80 }
81 }
82}
Note: See TracBrowser for help on using the repository browser.