From da4da5fcf1e98b947863ad9db040ef1b145f4e55 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 1 Apr 2015 00:19:52 +0200 Subject: [PATCH] add a simple nancy web app which queries the endpionts --- src/OnePeek.WebConsole/HomeModule.cs | 36 +++++ .../OnePeek.WebConsole.csproj | 123 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 35 +++++ src/OnePeek.WebConsole/Web.config | 29 +++++ src/OnePeek.WebConsole/packages.config | 5 + src/OnePeek.sln | 6 + 6 files changed, 234 insertions(+) create mode 100644 src/OnePeek.WebConsole/HomeModule.cs create mode 100644 src/OnePeek.WebConsole/OnePeek.WebConsole.csproj create mode 100644 src/OnePeek.WebConsole/Properties/AssemblyInfo.cs create mode 100644 src/OnePeek.WebConsole/Web.config create mode 100644 src/OnePeek.WebConsole/packages.config diff --git a/src/OnePeek.WebConsole/HomeModule.cs b/src/OnePeek.WebConsole/HomeModule.cs new file mode 100644 index 0000000..8bf8c19 --- /dev/null +++ b/src/OnePeek.WebConsole/HomeModule.cs @@ -0,0 +1,36 @@ +using Nancy; +using OnePeek.Entities; +using System.IO; + +namespace OnePeek.WebConsole +{ + public class HomeModule : NancyModule + { + public HomeModule() + { + var ratingEndpoint = new Api.AppRatingEndpoint(); + var metaEndpoint = new Api.AppMetadataEndpoint(); + + + Get["/meta/{id?2532ff45-aa3f-4aba-a266-ed7ec71d47bd}", true] = async (ctx, token) => + { + AppMetadata meta = await metaEndpoint.GetMetadata(ctx.id, StoreType.WindowsPhone8, StoreCultureType.EN_US); + return Response.AsJson(meta); + }; + + + Get["/reviews/{id?2532ff45-aa3f-4aba-a266-ed7ec71d47bd}", true] = async (ctx, token) => + { + AppReviews reviews = await ratingEndpoint.GetReviews(ctx.id, StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest); + return Response.AsJson(reviews); + }; + + + Get["/image/{id?4274cebb-01c7-4788-97f7-635322fa4877}", true] = async (ctx, token) => + { + Stream imageStream = await metaEndpoint.GetImageAsStream(ctx.id, StoreImageType.None); + return Response.FromStream(imageStream, "image/jpeg"); + }; + } + } +} \ No newline at end of file diff --git a/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj b/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj new file mode 100644 index 0000000..fc52384 --- /dev/null +++ b/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj @@ -0,0 +1,123 @@ + + + + + Debug + AnyCPU + + + 2.0 + {BB514985-A085-4C87-9D0A-734A86AA6D17} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + OnePeek.WebConsole + OnePeek.WebConsole + v4.5.1 + false + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + ..\packages\Nancy.1.1\lib\net40\Nancy.dll + + + ..\packages\Nancy.Hosting.Aspnet.1.1\lib\net40\Nancy.Hosting.Aspnet.dll + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + + + + + {843aac40-1d0f-49d1-a6e1-cf6b7a5db7eb} + OnePeek.Api + + + {d45d6378-3ed0-4445-94fe-21f62c1df4e6} + OnePeek.Entities + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 17691 + / + http://localhost:1999 + False + False + + + False + + + + + + \ No newline at end of file diff --git a/src/OnePeek.WebConsole/Properties/AssemblyInfo.cs b/src/OnePeek.WebConsole/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bf944d4 --- /dev/null +++ b/src/OnePeek.WebConsole/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OnePeek.WebConsole")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OnePeek.WebConsole")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bb514985-a085-4c87-9d0a-734a86aa6d17")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/OnePeek.WebConsole/Web.config b/src/OnePeek.WebConsole/Web.config new file mode 100644 index 0000000..75483b0 --- /dev/null +++ b/src/OnePeek.WebConsole/Web.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/OnePeek.WebConsole/packages.config b/src/OnePeek.WebConsole/packages.config new file mode 100644 index 0000000..f357dce --- /dev/null +++ b/src/OnePeek.WebConsole/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/OnePeek.sln b/src/OnePeek.sln index 40b85f1..7674e42 100644 --- a/src/OnePeek.sln +++ b/src/OnePeek.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnePeek.Entities", "OnePeek EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnePeek.Console", "OnePeek.Console\OnePeek.Console.csproj", "{A68611D8-A796-4A7A-A69D-D61B929CF8D8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnePeek.WebConsole", "OnePeek.WebConsole\OnePeek.WebConsole.csproj", "{BB514985-A085-4C87-9D0A-734A86AA6D17}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {A68611D8-A796-4A7A-A69D-D61B929CF8D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {A68611D8-A796-4A7A-A69D-D61B929CF8D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {A68611D8-A796-4A7A-A69D-D61B929CF8D8}.Release|Any CPU.Build.0 = Release|Any CPU + {BB514985-A085-4C87-9D0A-734A86AA6D17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB514985-A085-4C87-9D0A-734A86AA6D17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB514985-A085-4C87-9D0A-734A86AA6D17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB514985-A085-4C87-9D0A-734A86AA6D17}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE