From de991b98586492d0ab7afb7c45fdae1c7b4f4782 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Mon, 2 Nov 2015 13:35:14 -0800 Subject: [PATCH] Switch to using DI to acquire Node instances. Bump versions to alpha2. --- .../AngularPrerenderTagHelper.cs | 8 ++-- .../project.json | 4 +- .../ReactRenderer.cs | 5 +-- .../project.json | 4 +- .../Configuration.cs | 24 ++++++++++++ .../{HttpNodeHost.cs => HttpNodeInstance.cs} | 6 +-- ...st.cs => InputOutputStreamNodeInstance.cs} | 6 +-- .../HostingModels/NodeHost.cs | 10 ----- ...eRunner.cs => OutOfProcessNodeInstance.cs} | 28 ++++++++++---- .../INodeInstance.cs | 10 +++++ Microsoft.AspNet.NodeServices/NodeInstance.cs | 38 ------------------- .../EmbeddedResourceReader.cs | 0 .../{ => Util}/StringAsTempFile.cs | 0 Microsoft.AspNet.NodeServices/project.json | 5 ++- samples/angular/MusicStore/Startup.cs | 14 ++----- samples/angular/MusicStore/project.json | 2 +- .../Controllers/HomeController.cs | 2 +- .../Controllers/ScriptController.cs | 8 +++- samples/misc/ES2015Transpilation/Startup.cs | 4 ++ samples/misc/ES2015Transpilation/project.json | 2 +- .../ReactGrid/Controllers/HomeController.cs | 9 ++++- samples/react/ReactGrid/Startup.cs | 4 ++ samples/react/ReactGrid/project.json | 2 +- 23 files changed, 103 insertions(+), 92 deletions(-) create mode 100644 Microsoft.AspNet.NodeServices/Configuration.cs rename Microsoft.AspNet.NodeServices/HostingModels/{HttpNodeHost.cs => HttpNodeInstance.cs} (89%) rename Microsoft.AspNet.NodeServices/HostingModels/{InputOutputStreamNodeHost.cs => InputOutputStreamNodeInstance.cs} (93%) delete mode 100644 Microsoft.AspNet.NodeServices/HostingModels/NodeHost.cs rename Microsoft.AspNet.NodeServices/HostingModels/{OutOfProcessNodeRunner.cs => OutOfProcessNodeInstance.cs} (85%) create mode 100644 Microsoft.AspNet.NodeServices/INodeInstance.cs delete mode 100644 Microsoft.AspNet.NodeServices/NodeInstance.cs rename Microsoft.AspNet.NodeServices/{HostingModels => Util}/EmbeddedResourceReader.cs (100%) rename Microsoft.AspNet.NodeServices/{ => Util}/StringAsTempFile.cs (100%) diff --git a/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs b/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs index 9a5292b..31e4602 100644 --- a/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs +++ b/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs @@ -20,8 +20,6 @@ namespace Microsoft.AspNet.NodeServices.Angular const string PrerenderModuleAttributeName = "aspnet-ng2-prerender-module"; const string PrerenderExportAttributeName = "aspnet-ng2-prerender-export"; - private static NodeInstance nodeInstance = new NodeInstance(); - [HtmlAttributeName(PrerenderModuleAttributeName)] public string ModuleName { get; set; } @@ -29,15 +27,17 @@ namespace Microsoft.AspNet.NodeServices.Angular public string ExportName { get; set; } private IHttpContextAccessor contextAccessor; + private INodeServices nodeServices; - public AngularRunAtServerTagHelper(IHttpContextAccessor contextAccessor) + public AngularRunAtServerTagHelper(INodeServices nodeServices, IHttpContextAccessor contextAccessor) { this.contextAccessor = contextAccessor; + this.nodeServices = nodeServices; } public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - var result = await nodeInstance.InvokeExport(nodeScript.FileName, "renderComponent", new { + var result = await this.nodeServices.InvokeExport(nodeScript.FileName, "renderComponent", new { componentModule = this.ModuleName, componentExport = this.ExportName, tagName = output.TagName, diff --git a/Microsoft.AspNet.NodeServices.Angular/project.json b/Microsoft.AspNet.NodeServices.Angular/project.json index 133451b..fec49f8 100644 --- a/Microsoft.AspNet.NodeServices.Angular/project.json +++ b/Microsoft.AspNet.NodeServices.Angular/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha1", + "version": "1.0.0-alpha2", "description": "Microsoft.AspNet.NodeServices.Angular Class Library", "authors": [ "Microsoft" @@ -25,7 +25,7 @@ } }, "dependencies": { - "Microsoft.AspNet.NodeServices": "1.0.0-alpha1", + "Microsoft.AspNet.NodeServices": "1.0.0-alpha2", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8" }, "resource": [ diff --git a/Microsoft.AspNet.NodeServices.React/ReactRenderer.cs b/Microsoft.AspNet.NodeServices.React/ReactRenderer.cs index 653e52a..4094a2a 100644 --- a/Microsoft.AspNet.NodeServices.React/ReactRenderer.cs +++ b/Microsoft.AspNet.NodeServices.React/ReactRenderer.cs @@ -5,7 +5,6 @@ namespace Microsoft.AspNet.NodeServices.React public static class ReactRenderer { private static StringAsTempFile nodeScript; - private static NodeInstance nodeInstance = new NodeInstance(); static ReactRenderer() { // Consider populating this lazily @@ -13,8 +12,8 @@ namespace Microsoft.AspNet.NodeServices.React nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit } - public static async Task RenderToString(string moduleName, string exportName, string baseUrl) { - return await nodeInstance.InvokeExport(nodeScript.FileName, "renderToString", new { + public static async Task RenderToString(INodeServices nodeServices, string moduleName, string exportName, string baseUrl) { + return await nodeServices.InvokeExport(nodeScript.FileName, "renderToString", new { moduleName, exportName, baseUrl diff --git a/Microsoft.AspNet.NodeServices.React/project.json b/Microsoft.AspNet.NodeServices.React/project.json index 3500b73..a099840 100644 --- a/Microsoft.AspNet.NodeServices.React/project.json +++ b/Microsoft.AspNet.NodeServices.React/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha1", + "version": "1.0.0-alpha2", "description": "Microsoft.AspNet.NodeServices.React Class Library", "authors": [ "Microsoft" @@ -25,7 +25,7 @@ } }, "dependencies": { - "Microsoft.AspNet.NodeServices": "1.0.0-alpha1" + "Microsoft.AspNet.NodeServices": "1.0.0-alpha2" }, "resource": [ "Content/**/*" diff --git a/Microsoft.AspNet.NodeServices/Configuration.cs b/Microsoft.AspNet.NodeServices/Configuration.cs new file mode 100644 index 0000000..c0c336e --- /dev/null +++ b/Microsoft.AspNet.NodeServices/Configuration.cs @@ -0,0 +1,24 @@ +using Microsoft.Framework.DependencyInjection; + +namespace Microsoft.AspNet.NodeServices { + public static class Configuration { + public static void AddNodeServices(this IServiceCollection serviceCollection, NodeHostingModel hostingModel = NodeHostingModel.Http) { + serviceCollection.AddSingleton(typeof(INodeServices), (serviceProvider) => { + return CreateNodeServices(hostingModel); + }); + } + + private static INodeServices CreateNodeServices(NodeHostingModel hostingModel) + { + switch (hostingModel) + { + case NodeHostingModel.Http: + return new HttpNodeInstance(); + case NodeHostingModel.InputOutputStream: + return new InputOutputStreamNodeInstance(); + default: + throw new System.ArgumentException("Unknown hosting model: " + hostingModel.ToString()); + } + } + } +} diff --git a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeHost.cs b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs similarity index 89% rename from Microsoft.AspNet.NodeServices/HostingModels/HttpNodeHost.cs rename to Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs index 14dd3ef..915f92a 100644 --- a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeHost.cs +++ b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; namespace Microsoft.AspNet.NodeServices { - internal class HttpNodeHost : OutOfProcessNodeRunner { + internal class HttpNodeInstance : OutOfProcessNodeInstance { private readonly static Regex PortMessageRegex = new Regex(@"^\[Microsoft.AspNet.NodeServices.HttpNodeHost:Listening on port (\d+)\]$"); private readonly static JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings { @@ -15,8 +15,8 @@ namespace Microsoft.AspNet.NodeServices { private int _portNumber; - public HttpNodeHost(int port = 0) - : base(EmbeddedResourceReader.Read(typeof(HttpNodeHost), "/Content/Node/entrypoint-http.js"), port.ToString()) + public HttpNodeInstance(int port = 0) + : base(EmbeddedResourceReader.Read(typeof(HttpNodeInstance), "/Content/Node/entrypoint-http.js"), port.ToString()) { } diff --git a/Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeHost.cs b/Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeInstance.cs similarity index 93% rename from Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeHost.cs rename to Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeInstance.cs index f8a7ca7..0f79935 100644 --- a/Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeHost.cs +++ b/Microsoft.AspNet.NodeServices/HostingModels/InputOutputStreamNodeInstance.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.NodeServices { // Instead of directly using stdin/stdout, we could use either regular sockets (TCP) or use named pipes // on Windows and domain sockets on Linux / OS X, but either way would need a system for framing the // requests, associating them with responses, and scheduling use of the comms channel. - internal class InputOutputStreamNodeHost : OutOfProcessNodeRunner + internal class InputOutputStreamNodeInstance : OutOfProcessNodeInstance { private SemaphoreSlim _invocationSemaphore = new SemaphoreSlim(1); private TaskCompletionSource _currentInvocationResult; @@ -24,8 +24,8 @@ namespace Microsoft.AspNet.NodeServices { ContractResolver = new CamelCasePropertyNamesContractResolver() }; - public InputOutputStreamNodeHost() - : base(EmbeddedResourceReader.Read(typeof(InputOutputStreamNodeHost), "/Content/Node/entrypoint-stream.js")) + public InputOutputStreamNodeInstance() + : base(EmbeddedResourceReader.Read(typeof(InputOutputStreamNodeInstance), "/Content/Node/entrypoint-stream.js")) { } diff --git a/Microsoft.AspNet.NodeServices/HostingModels/NodeHost.cs b/Microsoft.AspNet.NodeServices/HostingModels/NodeHost.cs deleted file mode 100644 index a66f978..0000000 --- a/Microsoft.AspNet.NodeServices/HostingModels/NodeHost.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Threading.Tasks; - -namespace Microsoft.AspNet.NodeServices { - public abstract class NodeHost : System.IDisposable - { - public abstract Task Invoke(NodeInvocationInfo invocationInfo); - - public abstract void Dispose(); - } -} diff --git a/Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeRunner.cs b/Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeInstance.cs similarity index 85% rename from Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeRunner.cs rename to Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeInstance.cs index fb3d06f..5fa5e53 100644 --- a/Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeRunner.cs +++ b/Microsoft.AspNet.NodeServices/HostingModels/OutOfProcessNodeInstance.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.NodeServices { * Class responsible for launching the Node child process, determining when it is ready to accept invocations, * and finally killing it when the parent process exits. Also it restarts the child process if it dies. */ - internal abstract class OutOfProcessNodeRunner : NodeHost { + public abstract class OutOfProcessNodeInstance : INodeServices { private object _childProcessLauncherLock; private bool disposed; private StringAsTempFile _entryPointScript; @@ -18,19 +18,33 @@ namespace Microsoft.AspNet.NodeServices { protected Process NodeProcess { get { - // This is only exposed to support the UnreliableStreamNodeHost, which is just to verify that + // This is only exposed to support the unreliable OutOfProcessNodeRunner, which is just to verify that // other hosting/transport mechanisms are possible. This shouldn't really be exposed. return this._nodeProcess; } } - public OutOfProcessNodeRunner(string entryPointScript, string commandLineArguments = null) + public OutOfProcessNodeInstance(string entryPointScript, string commandLineArguments = null) { this._childProcessLauncherLock = new object(); this._entryPointScript = new StringAsTempFile(entryPointScript); this._commandLineArguments = commandLineArguments ?? string.Empty; } + public abstract Task Invoke(NodeInvocationInfo invocationInfo); + + public Task Invoke(string moduleName, params object[] args) { + return this.InvokeExport(moduleName, null, args); + } + + public async Task InvokeExport(string moduleName, string exportedFunctionName, params object[] args) { + return await this.Invoke(new NodeInvocationInfo { + ModuleName = moduleName, + ExportedFunctionName = exportedFunctionName, + Args = args + }); + } + protected async Task EnsureReady() { lock (this._childProcessLauncherLock) { if (this._nodeProcess == null || this._nodeProcess.HasExited) { @@ -104,8 +118,8 @@ namespace Microsoft.AspNet.NodeServices { protected virtual void OnErrorDataReceived(string errorData) { Console.WriteLine("[Node] " + errorData); } - - public override void Dispose() + + public void Dispose() { Dispose(true); GC.SuppressFinalize(this); @@ -125,8 +139,8 @@ namespace Microsoft.AspNet.NodeServices { disposed = true; } } - - ~OutOfProcessNodeRunner() { + + ~OutOfProcessNodeInstance() { Dispose (false); } } diff --git a/Microsoft.AspNet.NodeServices/INodeInstance.cs b/Microsoft.AspNet.NodeServices/INodeInstance.cs new file mode 100644 index 0000000..9118688 --- /dev/null +++ b/Microsoft.AspNet.NodeServices/INodeInstance.cs @@ -0,0 +1,10 @@ +using System; +using System.Threading.Tasks; + +namespace Microsoft.AspNet.NodeServices { + public interface INodeServices : IDisposable { + Task Invoke(string moduleName, params object[] args); + + Task InvokeExport(string moduleName, string exportedFunctionName, params object[] args); + } +} diff --git a/Microsoft.AspNet.NodeServices/NodeInstance.cs b/Microsoft.AspNet.NodeServices/NodeInstance.cs deleted file mode 100644 index 7768f18..0000000 --- a/Microsoft.AspNet.NodeServices/NodeInstance.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.NodeServices { - public class NodeInstance : IDisposable { - private readonly NodeHost _nodeHost; - - public NodeInstance(NodeHostingModel hostingModel = NodeHostingModel.Http) { - switch (hostingModel) { - case NodeHostingModel.Http: - this._nodeHost = new HttpNodeHost(); - break; - case NodeHostingModel.InputOutputStream: - this._nodeHost = new InputOutputStreamNodeHost(); - break; - default: - throw new ArgumentException("Unknown hosting model: " + hostingModel.ToString()); - } - } - - public Task Invoke(string moduleName, params object[] args) { - return this.InvokeExport(moduleName, null, args); - } - - public async Task InvokeExport(string moduleName, string exportedFunctionName, params object[] args) { - return await this._nodeHost.Invoke(new NodeInvocationInfo { - ModuleName = moduleName, - ExportedFunctionName = exportedFunctionName, - Args = args - }); - } - - public void Dispose() - { - this._nodeHost.Dispose(); - } - } -} diff --git a/Microsoft.AspNet.NodeServices/HostingModels/EmbeddedResourceReader.cs b/Microsoft.AspNet.NodeServices/Util/EmbeddedResourceReader.cs similarity index 100% rename from Microsoft.AspNet.NodeServices/HostingModels/EmbeddedResourceReader.cs rename to Microsoft.AspNet.NodeServices/Util/EmbeddedResourceReader.cs diff --git a/Microsoft.AspNet.NodeServices/StringAsTempFile.cs b/Microsoft.AspNet.NodeServices/Util/StringAsTempFile.cs similarity index 100% rename from Microsoft.AspNet.NodeServices/StringAsTempFile.cs rename to Microsoft.AspNet.NodeServices/Util/StringAsTempFile.cs diff --git a/Microsoft.AspNet.NodeServices/project.json b/Microsoft.AspNet.NodeServices/project.json index d94a210..c071791 100644 --- a/Microsoft.AspNet.NodeServices/project.json +++ b/Microsoft.AspNet.NodeServices/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha1", + "version": "1.0.0-alpha2", "description": "Microsoft.AspNet.NodeServices", "authors": [ "Microsoft" ], "tags": [""], @@ -8,7 +8,8 @@ "dependencies": { "System.Net.Http": "4.0.1-beta-23409", - "Newtonsoft.Json": "8.0.1-beta1" + "Newtonsoft.Json": "8.0.1-beta1", + "Microsoft.Framework.DependencyInjection": "1.0.0-beta8" }, "frameworks": { diff --git a/samples/angular/MusicStore/Startup.cs b/samples/angular/MusicStore/Startup.cs index 89fb223..592302e 100755 --- a/samples/angular/MusicStore/Startup.cs +++ b/samples/angular/MusicStore/Startup.cs @@ -79,6 +79,9 @@ namespace MusicStore Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); + + // Enable Node Services + services.AddNodeServices(); } // Configure is called after ConfigureServices is called. @@ -108,17 +111,6 @@ namespace MusicStore app.UseExceptionHandler("/Home/Error"); } - var nodeInstance = new NodeInstance(); - app.Use(async (context, next) => { - if (context.Request.Path.Value.EndsWith(".less")) { - // Note: check for directory traversal - var output = await nodeInstance.Invoke("lessCompiler.js", env.WebRootPath + context.Request.Path.Value); - await context.Response.WriteAsync(output); - } else { - await next(); - } - }); - // Add static files to the request pipeline. app.UseStaticFiles(); diff --git a/samples/angular/MusicStore/project.json b/samples/angular/MusicStore/project.json index 7a9f18c..76659e2 100755 --- a/samples/angular/MusicStore/project.json +++ b/samples/angular/MusicStore/project.json @@ -19,7 +19,7 @@ "EntityFramework.SQLite": "7.0.0-beta8", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8", "AutoMapper": "4.0.0-alpha1", - "Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha1" + "Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha2" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" diff --git a/samples/misc/ES2015Transpilation/Controllers/HomeController.cs b/samples/misc/ES2015Transpilation/Controllers/HomeController.cs index 9d9dd3e..6ee3ef8 100755 --- a/samples/misc/ES2015Transpilation/Controllers/HomeController.cs +++ b/samples/misc/ES2015Transpilation/Controllers/HomeController.cs @@ -5,7 +5,7 @@ namespace ES2015Example.Controllers { public class HomeController : Controller { - public async Task Index(int pageIndex) + public IActionResult Index(int pageIndex) { return View(); } diff --git a/samples/misc/ES2015Transpilation/Controllers/ScriptController.cs b/samples/misc/ES2015Transpilation/Controllers/ScriptController.cs index cfb1cbf..4b598be 100644 --- a/samples/misc/ES2015Transpilation/Controllers/ScriptController.cs +++ b/samples/misc/ES2015Transpilation/Controllers/ScriptController.cs @@ -6,13 +6,17 @@ namespace ES2015Example.Controllers { public class ScriptController : Controller { - private static NodeInstance nodeInstance = new NodeInstance(); + private INodeServices nodeServices; + + public ScriptController(INodeServices nodeServices) { + this.nodeServices = nodeServices; + } public async Task Transpile(string filename) { // TODO: Don't hard-code wwwroot; use proper path conversions var fileContents = System.IO.File.ReadAllText("wwwroot/" + filename); - var transpiledResult = await nodeInstance.Invoke("transpilation.js", fileContents, Request.Path.Value); + var transpiledResult = await this.nodeServices.Invoke("transpilation.js", fileContents, Request.Path.Value); return Content(transpiledResult, "application/javascript"); } } diff --git a/samples/misc/ES2015Transpilation/Startup.cs b/samples/misc/ES2015Transpilation/Startup.cs index b3584db..ea55a3f 100755 --- a/samples/misc/ES2015Transpilation/Startup.cs +++ b/samples/misc/ES2015Transpilation/Startup.cs @@ -5,6 +5,7 @@ using Microsoft.Dnx.Runtime; using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.AspNet.NodeServices; namespace ES2015Example { @@ -27,6 +28,9 @@ namespace ES2015Example { // Add MVC services to the services container. services.AddMvc(); + + // Enable Node Services + services.AddNodeServices(); } // Configure is called after ConfigureServices is called. diff --git a/samples/misc/ES2015Transpilation/project.json b/samples/misc/ES2015Transpilation/project.json index f6542c9..16aa144 100755 --- a/samples/misc/ES2015Transpilation/project.json +++ b/samples/misc/ES2015Transpilation/project.json @@ -16,7 +16,7 @@ "Microsoft.Framework.Logging": "1.0.0-beta8", "Microsoft.Framework.Logging.Console": "1.0.0-beta8", "Microsoft.Framework.Logging.Debug": "1.0.0-beta8", - "Microsoft.AspNet.NodeServices": "1.0.0-alpha1" + "Microsoft.AspNet.NodeServices": "1.0.0-alpha2" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" diff --git a/samples/react/ReactGrid/Controllers/HomeController.cs b/samples/react/ReactGrid/Controllers/HomeController.cs index dd9a1ab..37dff2b 100755 --- a/samples/react/ReactGrid/Controllers/HomeController.cs +++ b/samples/react/ReactGrid/Controllers/HomeController.cs @@ -1,14 +1,21 @@ using System.Threading.Tasks; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.NodeServices; using Microsoft.AspNet.NodeServices.React; namespace ReactExample.Controllers { public class HomeController : Controller { + private INodeServices nodeServices; + + public HomeController(INodeServices nodeServices) { + this.nodeServices = nodeServices; + } + public async Task Index(int pageIndex) { - ViewData["ReactOutput"] = await ReactRenderer.RenderToString( + ViewData["ReactOutput"] = await ReactRenderer.RenderToString(this.nodeServices, moduleName: "ReactApp/components/ReactApp.jsx", exportName: "ReactApp", baseUrl: Request.Path diff --git a/samples/react/ReactGrid/Startup.cs b/samples/react/ReactGrid/Startup.cs index 46ddd60..9a3a6c9 100755 --- a/samples/react/ReactGrid/Startup.cs +++ b/samples/react/ReactGrid/Startup.cs @@ -1,5 +1,6 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.NodeServices; using Microsoft.Dnx.Runtime; using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; @@ -26,6 +27,9 @@ namespace ReactExample { // Add MVC services to the services container. services.AddMvc(); + + // Enable Node Services + services.AddNodeServices(); } // Configure is called after ConfigureServices is called. diff --git a/samples/react/ReactGrid/project.json b/samples/react/ReactGrid/project.json index 5a346c8..5c33b46 100755 --- a/samples/react/ReactGrid/project.json +++ b/samples/react/ReactGrid/project.json @@ -16,7 +16,7 @@ "Microsoft.Framework.Logging": "1.0.0-beta8", "Microsoft.Framework.Logging.Console": "1.0.0-beta8", "Microsoft.Framework.Logging.Debug": "1.0.0-beta8", - "Microsoft.AspNet.NodeServices.React": "1.0.0-alpha1" + "Microsoft.AspNet.NodeServices.React": "1.0.0-alpha2" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel"