Code Monkey home page Code Monkey logo

cortside.aspnetcore's Introduction

Cortside.AspNetCore

Cortside.AspNetCore

// warm all the serivces up, can chain these together if needed
services.AddStartupTask<WarmupServicesStartupTask>();
// setup and register boostrapper and it's installers
services.AddBootStrapper<DefaultApplicationBootStrapper>(Configuration, o => {
    o.AddInstaller(new IdentityServerInstaller());
    o.AddInstaller(new NewtonsoftInstaller());
    o.AddInstaller(new SubjectPrincipalInstaller());
    o.AddInstaller(new SwaggerInstaller());
    o.AddInstaller(new ModelMapperInstaller());
});
// add response compression using gzip and brotli compression
services.AddDefaultResponseCompression(CompressionLevel.Optimal);

Cortside.AspNetCore.ApplicationInsights

var instrumentationKey = Configuration["ApplicationInsights:InstrumentationKey"];
var serviceName = Configuration["Service:Name"];

// add application insights telemetry
services.AddApplicationInsights(serviceName, instrumentationKey);

Cortside.AspNetCore.Common

This contains model classes that are common, i.e:

  • PageResult/PagedList - model thow has information about a total resultset as well as the items for a single page of results
  • ListResult - model that has results wrapped in common shape, matching PagedResult

Cortside.AspNetCore.AccessControl

// Add the access control using IdentityServer and PolicyServer
services.AddAccessControl(Configuration);

This is the expected shape of settings in appsettings.json:

    "IdentityServer": {
        "Authority": "http://localhost:5001",
        "ApiName": "shoppingcart-api",
        "ApiSecret": "apiresource-secret",
        "RequireHttpsMetadata": false,
        "CacheDuration": "00:10:00",
        "CacheEnabled": true,
        "Authentication": {
            "GrantType": "client_credentials",
            "Scope": "catalog-api",
            "ClientId": "shoppingcart-service",
            "ClientSecret": "secret",
            "SlidingExpiration": 30
        }
    },
    "PolicyServer": {
        "CacheDuration": "0.00:05:00",
        "BasePolicy": "ShoppingCart",
        "PolicyServerUrl": "http://localhost:5001",
        "BasePolicyPrefix": "ShoppingCart"
    },

Cortside.AspNetCore.Swagger

// Add swagger with versioning and OpenID Connect configuration using Newtonsoft
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var versions = new List<OpenApiInfo> {
    new OpenApiInfo {
        Version = "v1",
        Title = "Acme.ShoppingCart API",
        Description = "Acme.ShoppingCart API",
    },
    new OpenApiInfo {
        Version = "v2",
        Title = "Acme.ShoppingCart API",
        Description = "Acme.ShoppingCart API",
    }
};
services.AddSwagger(Configuration, xmlFile, versions);
app.UseSwagger("Acme.ShoppingCart Api", provider);

Note: you may need to add the provider to the Configuration method like this:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)

Also make sure that routes include the replacement token for the version number, like this:

[Route("api/v{version:apiVersion}/customers")]

Cortside.AspNetCore.Auditable

Contains base class AuditableEntity for domain entities as well as Subject domain entity needed by it.

// add SubjectPrincipal for auditing
services.AddSubjectPrincipal();
// intentionally set after UseAuthentication
app.UseMiddleware<SubjectMiddleware>();

Cortside.AspNetCore.EntityFramework

Contains the following:

  • AuditableDatabaseContext
  • UnitOfWorkContext
  • IUnitOfWork
  • QueryableExtensions for getting paged results

cortside.aspnetcore's People

Contributors

cycl157 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.