Skip to content

Commit e8396e4

Browse files
authored
Merge pull request #110 from gothinkster/updates
Updates
2 parents 5f76a4c + 1b7f1d7 commit e8396e4

25 files changed

+139
-528
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"csharpier": {
6-
"version": "0.27.3",
6+
"version": "0.28.0",
77
"commands": [
88
"dotnet-csharpier"
99
]

.github/workflows/dotnetcore.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-dotnet@v4
1313
with:
14-
dotnet-version: 8.0.201
14+
dotnet-version: 8.0.204
1515
- run: dotnet run --project build/build.csproj

Directory.Packages.props

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<PackageVersion Include="AutoMapper" Version="13.0.1" />
44
<PackageVersion Include="Bullseye" Version="5.0.0" />
55
<PackageVersion Include="Glob" Version="1.1.9" />
6-
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" />
7-
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.2" />
8-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
9-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
6+
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
7+
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.4" />
8+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
9+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
1010
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1111
<PackageVersion Include="Serilog" Version="3.1.1" />
1212
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />

src/Conduit/Domain/Person.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Text.Json.Serialization;
43

src/Conduit/Features/Articles/Create.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ CancellationToken cancellationToken
6060
var t = await context.Tags.FindAsync(tag);
6161
if (t == null)
6262
{
63-
t = new Tag() { TagId = tag };
63+
t = new Tag { TagId = tag };
6464
await context.Tags.AddAsync(t, cancellationToken);
6565
//save immediately for reuse
6666
await context.SaveChangesAsync(cancellationToken);
6767
}
6868
tags.Add(t);
6969
}
7070

71-
var article = new Article()
71+
var article = new Article
7272
{
7373
Author = author,
7474
Body = message.Article.Body,
@@ -81,7 +81,7 @@ CancellationToken cancellationToken
8181
await context.Articles.AddAsync(article, cancellationToken);
8282

8383
await context.ArticleTags.AddRangeAsync(
84-
tags.Select(x => new ArticleTag() { Article = article, Tag = x }),
84+
tags.Select(x => new ArticleTag { Article = article, Tag = x }),
8585
cancellationToken
8686
);
8787

src/Conduit/Features/Articles/Edit.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ IEnumerable<string> articleTagList
109109
var at = article.ArticleTags?.FirstOrDefault(t => t.TagId == tag);
110110
if (at == null)
111111
{
112-
at = new ArticleTag()
112+
at = new ArticleTag
113113
{
114114
Article = article,
115115
ArticleId = article.ArticleId,
116-
Tag = new Tag() { TagId = tag },
116+
Tag = new Tag { TagId = tag },
117117
TagId = tag
118118
};
119119
articleTagsToCreate.Add(at);

src/Conduit/Features/Articles/List.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Net;
33
using System.Threading;
44
using System.Threading.Tasks;
5-
using Conduit.Domain;
65
using Conduit.Infrastructure;
76
using Conduit.Infrastructure.Errors;
87
using MediatR;
@@ -111,11 +110,7 @@ CancellationToken cancellationToken
111110
.AsNoTracking()
112111
.ToListAsync(cancellationToken);
113112

114-
return new ArticlesEnvelope()
115-
{
116-
Articles = articles,
117-
ArticlesCount = queryable.Count()
118-
};
113+
return new ArticlesEnvelope { Articles = articles, ArticlesCount = queryable.Count() };
119114
}
120115
}
121116
}

src/Conduit/Features/Comments/Create.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CancellationToken cancellationToken
4949
cancellationToken
5050
);
5151

52-
var comment = new Comment()
52+
var comment = new Comment
5353
{
5454
Author = author,
5555
Body = message.Model.Comment.Body ?? string.Empty,

src/Conduit/Features/Favorites/Add.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CancellationToken cancellationToken
6161

6262
if (favorite == null)
6363
{
64-
favorite = new ArticleFavorite()
64+
favorite = new ArticleFavorite
6565
{
6666
Article = article,
6767
ArticleId = article.ArticleId,

src/Conduit/Features/Followers/Add.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CancellationToken cancellationToken
6464

6565
if (followedPeople == null)
6666
{
67-
followedPeople = new FollowedPeople()
67+
followedPeople = new FollowedPeople
6868
{
6969
Observer = observer,
7070
ObserverId = observer.PersonId,

src/Conduit/Features/Tags/List.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async Task<TagsEnvelope> Handle(Query message, CancellationToken cancella
2020
.Tags.OrderBy(x => x.TagId)
2121
.AsNoTracking()
2222
.ToListAsync(cancellationToken);
23-
return new TagsEnvelope()
23+
return new TagsEnvelope
2424
{
2525
Tags = tags?.Select(x => x.TagId ?? string.Empty).ToList() ?? new List<string>()
2626
};

src/Conduit/Infrastructure/Security/JwtIssuerOptions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Threading.Tasks;
32
using Microsoft.IdentityModel.Tokens;
43

54
namespace Conduit.Infrastructure.Security;

src/Conduit/Program.cs

+5-35
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Reflection;
43
using Conduit;
5-
using Conduit.Features.Profiles;
64
using Conduit.Infrastructure;
75
using Conduit.Infrastructure.Errors;
8-
using Conduit.Infrastructure.Security;
9-
using FluentValidation;
10-
using FluentValidation.AspNetCore;
11-
using MediatR;
126
using Microsoft.AspNetCore.Builder;
13-
using Microsoft.AspNetCore.Http;
147
using Microsoft.EntityFrameworkCore;
15-
using Microsoft.Extensions.Configuration;
168
using Microsoft.Extensions.DependencyInjection;
179
using Microsoft.Extensions.Logging;
1810
using Microsoft.OpenApi.Models;
@@ -25,15 +17,6 @@
2517

2618
var builder = WebApplication.CreateBuilder(args);
2719

28-
builder.Services.AddMediatR(cfg =>
29-
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly())
30-
);
31-
builder.Services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationPipelineBehavior<,>));
32-
builder.Services.AddScoped(
33-
typeof(IPipelineBehavior<,>),
34-
typeof(DBContextTransactionPipelineBehavior<,>)
35-
);
36-
3720
// take the connection string from the environment variable or use hard-coded database name
3821
var connectionString = defaultDatabaseConnectionSrting;
3922

@@ -81,7 +64,7 @@
8164
x.SupportNonNullableReferenceTypes();
8265

8366
x.AddSecurityRequirement(
84-
new OpenApiSecurityRequirement()
67+
new OpenApiSecurityRequirement
8568
{
8669
{
8770
new OpenApiSecurityScheme
@@ -98,11 +81,8 @@
9881
);
9982
x.SwaggerDoc("v1", new OpenApiInfo { Title = "RealWorld API", Version = "v1" });
10083
x.CustomSchemaIds(y => y.FullName);
101-
x.DocInclusionPredicate((version, apiDescription) => true);
102-
x.TagActionsBy(y => new List<string>()
103-
{
104-
y.GroupName ?? throw new InvalidOperationException()
105-
});
84+
x.DocInclusionPredicate((_, _) => true);
85+
x.TagActionsBy(y => new List<string> { y.GroupName ?? throw new InvalidOperationException() });
10686
x.CustomSchemaIds(s => s.FullName?.Replace("+", "."));
10787
});
10888

@@ -123,17 +103,7 @@
123103
.WhenWritingNull
124104
);
125105

126-
builder.Services.AddFluentValidationAutoValidation();
127-
builder.Services.AddFluentValidationClientsideAdapters();
128-
builder.Services.AddValidatorsFromAssemblyContaining<Startup>();
129-
130-
builder.Services.AddAutoMapper(typeof(Program));
131-
132-
builder.Services.AddScoped<IPasswordHasher, PasswordHasher>();
133-
builder.Services.AddScoped<IJwtTokenGenerator, JwtTokenGenerator>();
134-
builder.Services.AddScoped<ICurrentUserAccessor, CurrentUserAccessor>();
135-
builder.Services.AddScoped<IProfileReader, ProfileReader>();
136-
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
106+
builder.Services.AddConduit();
137107

138108
builder.Services.AddJwt();
139109

@@ -143,7 +113,7 @@
143113

144114
app.UseMiddleware<ErrorHandlingMiddleware>();
145115

146-
app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
116+
app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
147117

148118
app.UseAuthentication();
149119
app.UseMvc();

src/Conduit/Resources/Infrastructure.Errors.ErrorHandlingMiddleware.Designer.cs

-72
This file was deleted.

0 commit comments

Comments
 (0)