Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Configure host properties #43

Closed
github-actions bot opened this issue May 14, 2023 · 1 comment
Closed

Configure host properties #43

github-actions bot opened this issue May 14, 2023 · 1 comment
Assignees
Labels
backend Back end related todo This has to be worked on

Comments

@github-actions
Copy link

https://api.github.com/dariomrk/EduLink/blob/a78df3fef8acf5d91187e648af211afc32665ad2/backend/Api/Program.cs#L26

    {
        public static void Main(string[] args)
        {
            WebApplication
                .CreateBuilder(args)
                .ConfigureHost()
                .RegisterApplicationServices()
                .Build()
                .ConfigureMiddleware()
                .Run();
        }
    }

    public static class HostInitializer
    {
        public static WebApplicationBuilder ConfigureHost(this WebApplicationBuilder builder)
        {
            var host = builder.Host;
            // TODO: Configure host properties

            return builder;
        }
    }

    public static class ServiceInitializer
    {
        public static WebApplicationBuilder RegisterApplicationServices(this WebApplicationBuilder builder)
        {
            var services = builder.Services;
            // TODO: Configure services

            #region Controller registration
            services.AddControllers()
                .AddJsonOptions(options =>
                {
                    // endpoints recieve and send enum string representations
                    options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                });
            #endregion

            #region Service registration
            // services go here
            #endregion

            #region Repository registration
            // repositories go here
            #endregion

            var connectionString = ConfigurationHelper
                .GetConfiguration()
                .GetConnectionString("Database");

            services.AddDbContext<EduLinkDbContext>(options =>
                options.UseNpgsql(connectionString, options =>
                    options.UseNetTopologySuite()));

            services.AddEndpointsApiExplorer();
            services.AddSwaggerGen();

            return builder;
        }
    }

    public static class MiddlewareInitializer
    {
        public static WebApplication ConfigureMiddleware(this WebApplication app)
        {
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
@github-actions github-actions bot added the todo This has to be worked on label May 14, 2023
@dariomrk dariomrk self-assigned this May 14, 2023
@dariomrk dariomrk added the backend Back end related label May 14, 2023
@github-actions
Copy link
Author

Closed in 177876b

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend Back end related todo This has to be worked on
Projects
None yet
Development

No branches or pull requests

1 participant