Skip to content
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
14 changes: 7 additions & 7 deletions Appy.GitDb.Core/Appy.GitDb.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<NoWarn>1591</NoWarn>
<PlatformTarget>AnyCpu</PlatformTarget>
<Version>0.14.0</Version>
<Version>0.14.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

</Project>
17 changes: 8 additions & 9 deletions Appy.GitDb.Local/Appy.GitDb.Local.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<NoWarn>1591</NoWarn>
<PlatformTarget>AnyCpu</PlatformTarget>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<Version>0.17.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.306" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="NLog" Version="4.4.9" />
<PackageReference Include="LibGit2Sharp" Version="0.31.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="6.1.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -24,8 +23,8 @@

<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>

</Project>
</Project>
2 changes: 1 addition & 1 deletion Appy.GitDb.Local/LocalGitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public LocalGitDb(string path, string remoteName = null, string remoteUrl = null
if (!string.IsNullOrEmpty(_remoteUrl))
{
_logger.Trace($"No repository exists on disk and there's a remote URL, cloning the repo from {_remoteUrl}");
Repository.Clone(_remoteUrl, path, new CloneOptions {IsBare = true, CredentialsProvider = credentials});
Repository.Clone(_remoteUrl, path, new CloneOptions { IsBare = true, FetchOptions = { CredentialsProvider = credentials } });
}
else
{
Expand Down
21 changes: 8 additions & 13 deletions Appy.GitDb.Remote/Appy.GitDb.Remote.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
<NoWarn>1591</NoWarn>
<PlatformTarget>AnyCpu</PlatformTarget>
<PlatformTarget>AnyCpu</PlatformTarget>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<Version>0.18.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System.Web" />
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Appy.GitDb.Core\Appy.GitDb.Core.csproj">
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
Expand All @@ -26,8 +21,8 @@

<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>

</Project>
</Project>
4 changes: 2 additions & 2 deletions Appy.GitDb.Remote/RemoteGitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Net;
using Appy.GitDb.Core.Interfaces;
using Appy.GitDb.Core.Model;
using Newtonsoft.Json;
Expand Down Expand Up @@ -34,7 +34,7 @@ public RemoteGitDb(string userName, string password, string url, int batchSize =


string urlEncode(string value) =>
HttpUtility.UrlEncode(value);
WebUtility.UrlEncode(value);

public Task<string> Get(string branch, string key) =>
_client.GetAsync<string>($"/{branch}/document/{urlEncode(key)}");
Expand Down
65 changes: 0 additions & 65 deletions Appy.GitDb.Server/App.config

This file was deleted.

95 changes: 40 additions & 55 deletions Appy.GitDb.Server/App.cs
Original file line number Diff line number Diff line change
@@ -1,76 +1,61 @@
using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.ExceptionHandling;
using Appy.GitDb.Core.Interfaces;
using Appy.GitDb.Server.Auth;
using Appy.GitDb.Server.Logging;
using Autofac;
using Autofac.Integration.WebApi;
using Microsoft.Owin.Extensions;
using Microsoft.Owin.Hosting;
using NLog;
using Owin;
using ExceptionLogger = Appy.GitDb.Server.Logging.ExceptionLogger;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using NLog.LayoutRenderers;
using AppyExceptionLayoutRenderer = Appy.GitDb.Server.Logging.ExceptionLayoutRenderer;

namespace Appy.GitDb.Server
{
public class App
{
App(){}
IContainer _container;
string _url;
IEnumerable<User> _users;
Logger _serverLog;
App() { }

public static App Create(string url, IGitDb repo, IEnumerable<User> users)
static App()
{
var builder = new ContainerBuilder();
builder.RegisterInstance(repo).As<IGitDb>().ExternallyOwned();
builder.RegisterApiControllers(typeof(App).Assembly);
LayoutRenderer.Register<AppyExceptionLayoutRenderer>("appy-exception");
LayoutRenderer.Register<CorrelationIdLayoutRenderer>("correlationid");
}

var app = new App
{
_container = builder.Build(),
_url = url,
_users = users,
_serverLog = LogManager.GetLogger("server-log")
};
LoggingMiddleware.Logger = LogManager.GetLogger("server-log");
public static WebApplication Create(string url, IGitDb repo, IEnumerable<User> users)
{
var builder = WebApplication.CreateBuilder();
builder.WebHost.UseUrls(url);
ConfigureServices(builder.Services, repo, users);
var app = builder.Build();
ConfigurePipeline(app);
return app;
}

public IDisposable Start()
public static IWebHostBuilder CreateTestBuilder(IGitDb repo, IEnumerable<User> users) =>
new WebHostBuilder()
.ConfigureServices(services => ConfigureServices(services, repo, users))
.Configure(ConfigurePipeline);

static void ConfigureServices(IServiceCollection services, IGitDb repo, IEnumerable<User> users)
{
try
{
_serverLog.Info("Starting up git server");
var result = WebApp.Start(new StartOptions(_url), Configuration);
_serverLog.Info($"Server started on {_url}");
return result;
}
catch (Exception ex)
{
_serverLog.Fatal(ex, string.Empty);
throw;
}
services.AddSingleton(repo);
services.AddSingleton(users);
services.AddTransient<LoggingMiddleware>();
services.AddAuthentication("Basic")
.AddScheme<BasicAuthOptions, BasicAuthHandler>("Basic", null);
services.AddAuthorization();
services.AddResponseCompression();
services.AddControllers()
.AddNewtonsoftJson();
}


public void Configuration(IAppBuilder app)
static void ConfigurePipeline(IApplicationBuilder app)
{
var config = new HttpConfiguration();
config.Services.Add(typeof(IExceptionLogger), new ExceptionLogger());
app.UseAutofacMiddleware(_container);
var auth = new Authentication(_users);
app.UseBasicAuthentication("appy.gitdb", auth.ValidateUsernameAndPassword);
config.MapHttpAttributeRoutes();
config.DependencyResolver = new AutofacWebApiDependencyResolver(_container);

app.Use<LoggingMiddleware>();
app.UseCompressionModule(OwinCompression.DefaultCompressionSettings);
app.UseStageMarker(PipelineStage.MapHandler);
app.UseWebApi(config);
app.UseMiddleware<LoggingMiddleware>();
app.UseResponseCompression();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}
}
Loading