Skip to content

Updates for 8.x #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.0",
"version": "0.30.6",
"commands": [
"dotnet-csharpier"
]
],
"rollForward": false
}
}
}
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,6 @@ Dockerfile

# .env file contains default environment variables for docker
.env
.git/
.git/
bin/
obj/
6 changes: 6 additions & 0 deletions Conduit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{E0DF0C
Directory.Build.props = Directory.Build.props
global.json = global.json
.editorconfig = .editorconfig
docker-compose.yml = docker-compose.yml
Dockerfile = Dockerfile
NuGet.config = NuGet.config
.github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml
.dockerignore = .dockerignore
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{79EC8D73-8DAD-430E-93CE-C1F29DBC33FA}"
Expand Down
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project>
<ItemGroup>
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="AutoMapper" Version="14.0.0" />
<PackageVersion Include="Bullseye" Version="5.0.0" />
<PackageVersion Include="Glob" Version="1.1.9" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.13" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.13" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.13" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.13" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="SimpleExec" Version="12.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7"/>
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
</ItemGroup>
</Project>
14 changes: 4 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["build/build.csproj", "build/"]
RUN dotnet restore "build/build.csproj"
COPY . .
WORKDIR "/src/build"
RUN dotnet build "build.csproj" -c Release -o /app/build
RUN dotnet run --project build/build.csproj -- publish

FROM build AS publish
RUN dotnet publish "build.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base

FROM base AS final
WORKDIR /app
EXPOSE 5000
COPY --link --from=build /src/publish .
EXPOSE 8080

ENTRYPOINT ["dotnet", "Conduit.dll"]
3 changes: 3 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ErrorActionPreference = "Stop";

dotnet run --project build/build.csproj -- $args
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

dotnet run --project Build/Build.csproj -- "$@"
2 changes: 1 addition & 1 deletion build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void RemoveDirectory(string d)
() =>
{
Run("dotnet", "tool restore");
Run("dotnet", "csharpier --check");
Run("dotnet", "csharpier . --check");
}
);

Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: '3'
services:
conduit:
build: .
environment:
- ASPNETCORE_Conduit_DatabaseProvider=${ASPNETCORE_Conduit_DatabaseProvider}
- ASPNETCORE_Conduit_ConnectionString=${ASPNETCORE_Conduit_ConnectionString}
ports:
- "5000:5000"
- "8080:8080"
2 changes: 1 addition & 1 deletion src/Conduit/Features/Articles/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CancellationToken cancellationToken
UpdatedAt = DateTime.UtcNow,
Description = message.Article.Description,
Title = message.Article.Title,
Slug = message.Article.Title.GenerateSlug()
Slug = message.Article.Title.GenerateSlug(),
};
await context.Articles.AddAsync(article, cancellationToken);

Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Articles/Edit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ IEnumerable<string> articleTagList
Article = article,
ArticleId = article.ArticleId,
Tag = new Tag { TagId = tag },
TagId = tag
TagId = tag,
};
articleTagsToCreate.Add(at);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Comments/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CancellationToken cancellationToken
Author = author,
Body = message.Model.Comment.Body ?? string.Empty,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow
UpdatedAt = DateTime.UtcNow,
};
await context.Comments.AddAsync(comment, cancellationToken);

Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Favorites/Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CancellationToken cancellationToken
Article = article,
ArticleId = article.ArticleId,
Person = person,
PersonId = person.PersonId
PersonId = person.PersonId,
};
await context.ArticleFavorites.AddAsync(favorite, cancellationToken);
await context.SaveChangesAsync(cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Followers/Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CancellationToken cancellationToken
Observer = observer,
ObserverId = observer.PersonId,
Target = target,
TargetId = target.PersonId
TargetId = target.PersonId,
};
await context.FollowedPeople.AddAsync(followedPeople, cancellationToken);
await context.SaveChangesAsync(cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Tags/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<TagsEnvelope> Handle(Query message, CancellationToken cancella
.ToListAsync(cancellationToken);
return new TagsEnvelope
{
Tags = tags?.Select(x => x.TagId ?? string.Empty).ToList() ?? new List<string>()
Tags = tags?.Select(x => x.TagId ?? string.Empty).ToList() ?? new List<string>(),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Features/Users/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ await context
message.User.Password ?? throw new InvalidOperationException(),
salt
),
Salt = salt
Salt = salt,
};

await context.Persons.AddAsync(person, cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion src/Conduit/Infrastructure/Security/JwtTokenGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public string CreateToken(string username)
JwtRegisteredClaimNames.Iat,
new DateTimeOffset(_jwtOptions.IssuedAt).ToUnixTimeSeconds().ToString(),
ClaimValueTypes.Integer64
)
),
};
var jwt = new JwtSecurityToken(
_jwtOptions.Issuer,
Expand Down
8 changes: 4 additions & 4 deletions src/Conduit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
Description = "Please insert JWT with Bearer into field",
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
BearerFormat = "JWT"
BearerFormat = "JWT",
}
);

Expand All @@ -72,11 +72,11 @@
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
Id = "Bearer",
},
},
Array.Empty<string>()
}
},
}
);
x.SwaggerDoc("v1", new OpenApiInfo { Title = "RealWorld API", Version = "v1" });
Expand Down
4 changes: 2 additions & 2 deletions src/Conduit/ServicesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void AddJwt(this IServiceCollection services)
// Validate the token expiry
ValidateLifetime = true,
// If you want to allow a certain amount of clock drift, set that here:
ClockSkew = TimeSpan.Zero
ClockSkew = TimeSpan.Zero,
};

services
Expand All @@ -94,7 +94,7 @@ public static void AddJwt(this IServiceCollection services)
}

return Task.CompletedTask;
}
},
};
});
}
Expand Down
Loading