Skip to content

Commit

Permalink
Rework project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
a.civier committed May 16, 2024
1 parent f237799 commit e79058c
Show file tree
Hide file tree
Showing 98 changed files with 177 additions and 97 deletions.
13 changes: 11 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.env*
wwwroot/
.env
.git
*.md
.mono/
.devcontainer/
.vscode/
node_modules/
obj/
bin/
Dockerfile
docker-compose.yml
3 changes: 3 additions & 0 deletions service/.editorconfig → .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dotnet_diagnostic.SA1633.severity = silent
# SA1600: Elements should be documented
dotnet_diagnostic.SA1600.severity = silent

# SA0001: XML comment analysis
dotnet_diagnostic.SA0001.severity = none

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = warning

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: dotnet restore

- name: Restore tool dependencies
working-directory: ./service/DNE.Todo.API
working-directory: ./src/Api
run: dotnet tool restore

- name: Test
Expand All @@ -58,7 +58,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: openapi.json
path: ./service/DNE.Todo.API/bin/Release/net8.0/openapi.json
path: ./src/Api/bin/Release/net8.0/openapi.json

- name: Upload .NET artifacts
uses: actions/upload-artifact@v3
Expand Down
9 changes: 5 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@
"vite",
],
"type": "node",
"cwd": "${workspaceFolder}/client",
"cwd": "${workspaceFolder}/src/Client",
"preLaunchTask": "generateClientApi",
"serverReadyAction": {
"action": "debugWithChrome",
"webRoot": "${workspaceFolder}/src/Client",
"pattern": "Local:.*http://localhost:([0-9]+)/",
"uriFormat": "http://localhost:%s"
}
},
{
"name": "Todo Service Launch",
"name": "Todo Api Launch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/service/DNE.Todo.API/bin/Debug/net8.0/DNE.Todo.API.dll",
"program": "${workspaceFolder}/src/Api/bin/Debug/net8.0/DNE.Todo.Api.dll",
"args": [],
"cwd": "${workspaceFolder}/service/DNE.Todo.API",
"cwd": "${workspaceFolder}/src/Api",
"stopAtEntry": false,
// "serverReadyAction": {
// "action": "openExternally",
Expand Down
15 changes: 6 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
"tasks": [
{
"label": "generateClientApi",
"command": "npm run",
"type": "process",
"args": [
"api:generate:dev"
],
"script": "api:generate:dev",
"type": "npm",
"options": {
"cwd": "${workspaceFolder}/client",
"cwd": "${workspaceFolder}/src/Client",
}
},
{
Expand All @@ -18,7 +15,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/service/DNE.Todo.API/DNE.Todo.API.csproj",
"${workspaceFolder}/src/Api/Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -30,7 +27,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/service/DNE.Todo.API/DNE.Todo.API.csproj",
"${workspaceFolder}/src/Api/Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -43,7 +40,7 @@
"args": [
"watch",
"run",
"${workspaceFolder}/service/DNE.Todo.API/DNE.Todo.API.csproj",
"${workspaceFolder}/src/Api/Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Don't Nod</Company>
<Product />
</PropertyGroup>
</Project>
49 changes: 49 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- For more info on central package management go to
https://devblogs.microsoft.com/nuget/introducing-central-package-management/ -->
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Ardalis.GuardClauses" Version="4.5.0" />
<PackageVersion Include="Azure.Identity" Version="1.11.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />

<PackageVersion Include="DotSwashbuckle.AspNetCore" Version="3.0.8" />
<PackageVersion Include="DotSwashbuckle.AspNetCore.Annotations" Version="3.0.8" />

<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />

<PackageVersion Include="MediatR" Version="12.2.0" />

<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3"
NoWarn="NU1605" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.3"
NoWarn="NU1605" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.15.2" />
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="2.15.2" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />

<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables"
Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore"
Version="8.0.4" />

<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />

<PackageVersion Include="moq" Version="4.20.70" />
<PackageVersion Include="xunit" Version="2.5.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />

<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
</ItemGroup>
</Project>
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ FROM build-base as build-base-with-dependencies
WORKDIR /workspace

# Copy source
COPY client/ client/
COPY service/ service/
COPY WebAppStarter.sln README.md ./

# Install Client Dependencies
RUN cd client && npm ci
COPY ./ ./

# Install Dot net Dependencies
RUN dotnet restore
RUN cd service/DNE.Todo.API && dotnet tool restore
RUN cd src/Api && dotnet tool restore

RUN dotnet tool install --global dotnet-ef

Expand Down Expand Up @@ -74,7 +69,7 @@ WORKDIR /app
COPY --from=prod-build /workspace/out .

EXPOSE 8080
ENTRYPOINT ["dotnet", "DNE.Todo.API.dll"]
ENTRYPOINT ["dotnet", "DNE.Todo.Api.dll"]

## ---------------------------------------------------------------------------------- ##
## -------------------------------- development build ------------------------------- ##
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ This starter kit is a boilerplate based on the https://github.com/Azure-Samples/
# Setup the starter

## Setup the Client
For details on setting up and running the client, see the [Client documentation](/client/README.md)
For details on setting up and running the client, see the [Client documentation](/src/Client/README.md)

## Setup the Service
For details on setting up and running the service, see the [Service documentation](/service/DNE.Todo.API/README.md)
## Setup the API
For details on setting up and running the service, see the [Service documentation](/src/Api/README.md)

# Docker
Create a `.env` file at the root of the project and populate it with the following values to configure your environment:
Expand Down
31 changes: 22 additions & 9 deletions WebAppStarter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "service", "service", "{D34D9A25-2206-4972-BC45-EC8363A695C0}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D34D9A25-2206-4972-BC45-EC8363A695C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DNE.Todo.API", "service\DNE.Todo.API\DNE.Todo.API.csproj", "{24717492-0735-485A-A0A9-DF837633E3DD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "src\Api\Api.csproj", "{24717492-0735-485A-A0A9-DF837633E3DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DNE.Todo.Test", "service\DNE.Todo.Test\DNE.Todo.Test.csproj", "{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB}"
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "Client", "src\Client\client.esproj", "{0261127C-E97A-4350-AFFD-FBFF75F12AD3}"
EndProject
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "client", "client\client.esproj", "{0261127C-E97A-4350-AFFD-FBFF75F12AD3}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solutions Items", "Solutions Items", "{272BAA60-C02E-4786-B5DE-7622C493F27D}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
README.md = README.md
global.json = global.json
.gitignore = .gitignore
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{41D3ECC0-AB64-4994-8B5E-73A7876C4F5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.UnitTests", "tests\Api.UnitTests\Api.UnitTests.csproj", "{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,23 +33,24 @@ Global
{24717492-0735-485A-A0A9-DF837633E3DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24717492-0735-485A-A0A9-DF837633E3DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24717492-0735-485A-A0A9-DF837633E3DD}.Release|Any CPU.Build.0 = Release|Any CPU
{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB}.Release|Any CPU.Build.0 = Release|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Release|Any CPU.Build.0 = Release|Any CPU
{0261127C-E97A-4350-AFFD-FBFF75F12AD3}.Release|Any CPU.Deploy.0 = Release|Any CPU
{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{24717492-0735-485A-A0A9-DF837633E3DD} = {D34D9A25-2206-4972-BC45-EC8363A695C0}
{8A92DCE0-94D5-494E-BCCE-AD2599ECAFBB} = {D34D9A25-2206-4972-BC45-EC8363A695C0}
{0261127C-E97A-4350-AFFD-FBFF75F12AD3} = {D34D9A25-2206-4972-BC45-EC8363A695C0}
{31BDF5B0-70C7-4802-B0C8-63A88C0DFD67} = {41D3ECC0-AB64-4994-8B5E-73A7876C4F5F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A727A511-A414-4DD0-A3C6-3DCCCBB5C3FB}
Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"sdk": {
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
29 changes: 0 additions & 29 deletions service/DNE.Todo.Test/DNE.Todo.Test.csproj

This file was deleted.

File renamed without changes.
File renamed without changes.
39 changes: 18 additions & 21 deletions service/DNE.Todo.API/DNE.Todo.API.csproj → src/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dne-todo-api-2f979706-5df6-465d-af50-c3917e0e8925</UserSecretsId>

<Company>Don't Nod</Company>
<Product />
<RootNamespace>DNE.Todo.Api</RootNamespace>
<AssemblyName>DNE.Todo.Api</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.3" NoWarn="NU1605" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Identity.Web" Version="2.15.2" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="2.15.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PackageReference Include="Microsoft.Identity.Web" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="DotSwashbuckle.AspNetCore" Version="3.0.8" />
<PackageReference Include="DotSwashbuckle.AspNetCore.Annotations" Version="3.0.8" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="DotSwashbuckle.AspNetCore" />
<PackageReference Include="DotSwashbuckle.AspNetCore.Annotations" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
</ItemGroup>

<Target Name="OpenAPI" AfterTargets="Build">
Expand All @@ -39,12 +36,12 @@
</Target>

<Target Name="Generate Client type definition" AfterTargets="Build" Condition="$(Configuration)=='Release'">
<Exec Command="npm ci" Condition="'$(RestorePackagesWithLockFile)' != 'true'" WorkingDirectory="$(MSBuildProjectDirectory)/../../client" />
<Exec Command="npm run api:generate $(TargetDir)/openapi.json" Condition="'$(RestorePackagesWithLockFile)' != 'true'" WorkingDirectory="$(MSBuildProjectDirectory)/../../client" />
<Exec Command="npm ci" Condition="'$(RestorePackagesWithLockFile)' != 'true'" WorkingDirectory="$(MSBuildProjectDirectory)/../Client" />
<Exec Command="npm run api:generate $(TargetDir)/openapi.json" Condition="'$(RestorePackagesWithLockFile)' != 'true'" WorkingDirectory="$(MSBuildProjectDirectory)/../Client" />
</Target>

<ItemGroup>
<ProjectReference Include="..\..\client\client.esproj">
<ProjectReference Include="..\Client\client.esproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public ReadTodoPermissionFilter(IConfiguration configuration, IOptions<ClaimSett
}
}

public class ReadTodoPermissionAttribute : TypeFilterAttribute<ReadTodoPermissionFilter> { }
public class ReadTodoPermissionAttribute : TypeFilterAttribute<ReadTodoPermissionFilter>
{
}

#pragma warning restore SA1649 // File name should match first type name
#pragma warning restore SA1402 // File may only contain a single type
Loading

0 comments on commit e79058c

Please sign in to comment.