Permalink
Browse files

Add server projects

  • Loading branch information...
mythz committed Nov 15, 2017
1 parent 83ebb93 commit 67a5553cbe35a9739c6c25fe9cbe7e50bf69271f
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack" Version="5.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyApp.ServiceModel\MyApp.ServiceModel.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ServiceStack;
using ServiceStack.Templates;
using ServiceStack.DataAnnotations;
using MyApp.ServiceModel;
namespace MyApp.ServiceInterface
{
[Exclude(Feature.Metadata)]
[FallbackRoute("/{PathInfo*}", Matches="AcceptsHtml")]
public class FallbackForClientRoutes
{
public string PathInfo { get; set; }
}
public class MyServices : Service
{
//Return index.html for unmatched requests so routing is handled on client
public object Any(FallbackForClientRoutes request) =>
new PageResult(Request.GetPage("/"));
public object Any(Hello request)
{
return new HelloResponse { Result = $"Hello, {request.Name}!" };
}
}
}
@@ -0,0 +1,16 @@
using ServiceStack;
namespace MyApp.ServiceModel
{
[Route("/hello")]
[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
}
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack.Interfaces" Version="5.*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Types\" />
</ItemGroup>
</Project>
@@ -0,0 +1,3 @@
# Keep Empty Directory
*
!.gitignore
@@ -0,0 +1,45 @@
using Funq;
using ServiceStack;
using NUnit.Framework;
using MyApp.ServiceInterface;
using MyApp.ServiceModel;
namespace MyApp.Tests
{
public class IntegrationTest
{
const string BaseUri = "http://localhost:2000/";
private readonly ServiceStackHost appHost;
class AppHost : AppSelfHostBase
{
public AppHost() : base(nameof(IntegrationTest), typeof(MyServices).Assembly) { }
public override void Configure(Container container)
{
}
}
public IntegrationTest()
{
appHost = new AppHost()
.Init()
.Start(BaseUri);
}
[OneTimeTearDown]
public void OneTimeTearDown() => appHost.Dispose();
public IServiceClient CreateClient() => new JsonServiceClient(BaseUri);
[Test]
public void Can_call_Hello_Service()
{
var client = CreateClient();
var response = client.Get(new Hello { Name = "World" });
Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}
}
}
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MyApp.ServiceInterface\MyApp.ServiceInterface.csproj" />
<ProjectReference Include="..\MyApp.ServiceModel\MyApp.ServiceModel.csproj" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171012-09" />
<PackageReference Include="ServiceStack" Version="5.*" />
<PackageReference Include="ServiceStack.Kestrel" Version="5.*" />
</ItemGroup>
</Project>
@@ -0,0 +1,32 @@
using NUnit.Framework;
using ServiceStack;
using ServiceStack.Testing;
using MyApp.ServiceInterface;
using MyApp.ServiceModel;
namespace MyApp.Tests
{
public class UnitTest
{
private readonly ServiceStackHost appHost;
public UnitTest()
{
appHost = new BasicAppHost().Init();
appHost.Container.AddTransient<MyServices>();
}
[OneTimeTearDown]
public void OneTimeTearDown() => appHost.Dispose();
[Test]
public void Can_call_MyServices()
{
var service = appHost.Container.Resolve<MyServices>();
var response = (HelloResponse)service.Any(new Hello { Name = "World" });
Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}
}
}
@@ -1,2 +1,32 @@
# angular-cli-spa
.NET Core 2.0 Angular 5 project created by https://cli.angular.io
.NET Core 2.0 Angular 5 project generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.0.
## Dev Workflow
Run `dotnet watch run` to start .NET Core 2.0 Server App and watch for changes and in a new terminal window run `npm run dev` to start a dev watch
aot build for compiling client assets.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `npm run build` to build the project. The build artifacts will be stored in the `wwwroot/` directory. Use `npm run build-prod` for a production build.
## Publish
Run `npm run publish` to generate a client and server production build the project. The build artifacts will be stored in the `bin/Release/netcoreapp2.0/publish/` directory.
## Running unit tests
Run `npm test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `npm run e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

0 comments on commit 67a5553

Please sign in to comment.