Skip to content

Commit ac23afc

Browse files
Fix some build issues
1 parent 71cb3ab commit ac23afc

File tree

4 files changed

+99
-93
lines changed

4 files changed

+99
-93
lines changed
Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
using Microsoft.AspNet.Builder;
2-
using Microsoft.AspNet.Hosting;
3-
using Microsoft.AspNet.NodeServices;
4-
using Microsoft.AspNet.Http;
5-
using Microsoft.Extensions.PlatformAbstractions;
6-
using Microsoft.Extensions.Configuration;
7-
using Microsoft.Extensions.DependencyInjection;
8-
using Microsoft.Extensions.Logging;
9-
10-
namespace ES2015Example
11-
{
12-
public class Startup
13-
{
14-
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
15-
{
16-
// Setup configuration sources.
17-
var builder = new ConfigurationBuilder()
18-
.SetBasePath(appEnv.ApplicationBasePath)
19-
.AddJsonFile("appsettings.json")
20-
.AddEnvironmentVariables();
21-
Configuration = builder.Build();
22-
}
23-
24-
public IConfigurationRoot Configuration { get; set; }
25-
26-
// This method gets called by the runtime.
27-
public void ConfigureServices(IServiceCollection services)
28-
{
29-
// Add MVC services to the services container.
30-
services.AddMvc();
31-
32-
// Enable Node Services
33-
services.AddNodeServices();
34-
}
35-
36-
// Configure is called after ConfigureServices is called.
37-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, INodeServices nodeServices)
38-
{
39-
loggerFactory.MinimumLevel = LogLevel.Warning;
40-
loggerFactory.AddConsole();
41-
loggerFactory.AddDebug();
42-
43-
// Configure the HTTP request pipeline.
44-
45-
// Add the platform handler to the request pipeline.
46-
app.UseIISPlatformHandler();
47-
48-
// Add the following to the request pipeline only in development environment.
49-
if (env.IsDevelopment())
50-
{
51-
app.UseDeveloperExceptionPage();
52-
}
53-
else
54-
{
55-
// Add Error handling middleware which catches all application specific errors and
56-
// send the request to the following path or controller action.
57-
app.UseExceptionHandler("/Home/Error");
58-
}
59-
60-
// Dynamically transpile any .js files under the '/js/' directory
61-
app.Use(next => async context => {
62-
var requestPath = context.Request.Path.Value;
63-
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
64-
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
65-
if (fileInfo.Exists) {
66-
var transpiled = await nodeServices.Invoke<string>("transpilation.js", fileInfo.PhysicalPath, requestPath);
67-
await context.Response.WriteAsync(transpiled);
68-
return;
69-
}
70-
}
71-
72-
// Not a JS file, or doesn't exist - let some other middleware handle it
73-
await next.Invoke(context);
74-
});
75-
76-
// Add static files to the request pipeline.
77-
app.UseStaticFiles();
78-
79-
// Add MVC to the request pipeline.
80-
app.UseMvc(routes =>
81-
{
82-
routes.MapRoute(
83-
name: "default",
84-
template: "{controller}/{action?}/{id?}",
85-
defaults: new { controller="Home", action = "Index" });
86-
});
87-
}
88-
}
89-
}
1+
using Microsoft.AspNet.Builder;
2+
using Microsoft.AspNet.Hosting;
3+
using Microsoft.AspNet.NodeServices;
4+
using Microsoft.AspNet.Http;
5+
using Microsoft.Extensions.PlatformAbstractions;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace ES2015Example
11+
{
12+
public class Startup
13+
{
14+
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
15+
{
16+
// Setup configuration sources.
17+
var builder = new ConfigurationBuilder()
18+
.SetBasePath(appEnv.ApplicationBasePath)
19+
.AddJsonFile("appsettings.json")
20+
.AddEnvironmentVariables();
21+
Configuration = builder.Build();
22+
}
23+
24+
public IConfigurationRoot Configuration { get; set; }
25+
26+
// This method gets called by the runtime.
27+
public void ConfigureServices(IServiceCollection services)
28+
{
29+
// Add MVC services to the services container.
30+
services.AddMvc();
31+
32+
// Enable Node Services
33+
services.AddNodeServices();
34+
}
35+
36+
// Configure is called after ConfigureServices is called.
37+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, INodeServices nodeServices)
38+
{
39+
loggerFactory.MinimumLevel = LogLevel.Warning;
40+
loggerFactory.AddConsole();
41+
loggerFactory.AddDebug();
42+
43+
// Configure the HTTP request pipeline.
44+
45+
// Add the platform handler to the request pipeline.
46+
app.UseIISPlatformHandler();
47+
48+
// Add the following to the request pipeline only in development environment.
49+
if (env.IsDevelopment())
50+
{
51+
app.UseDeveloperExceptionPage();
52+
}
53+
else
54+
{
55+
// Add Error handling middleware which catches all application specific errors and
56+
// send the request to the following path or controller action.
57+
app.UseExceptionHandler("/Home/Error");
58+
}
59+
60+
// Dynamically transpile any .js files under the '/js/' directory
61+
app.Use(next => async context => {
62+
var requestPath = context.Request.Path.Value;
63+
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
64+
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
65+
if (fileInfo.Exists) {
66+
var transpiled = await nodeServices.Invoke<string>("transpilation.js", fileInfo.PhysicalPath, requestPath);
67+
await context.Response.WriteAsync(transpiled);
68+
return;
69+
}
70+
}
71+
72+
// Not a JS file, or doesn't exist - let some other middleware handle it
73+
await next.Invoke(context);
74+
});
75+
76+
// Add static files to the request pipeline.
77+
app.UseStaticFiles();
78+
79+
// Add MVC to the request pipeline.
80+
app.UseMvc(routes =>
81+
{
82+
routes.MapRoute(
83+
name: "default",
84+
template: "{controller}/{action?}/{id?}",
85+
defaults: new { controller="Home", action = "Index" });
86+
});
87+
}
88+
}
89+
}

samples/react/ReactGrid/ReactApp/boot-server.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { renderToString } from 'react-dom/server';
33
import { match, RouterContext } from 'react-router';
4-
import createMemoryHistory from 'history/lib/createMemoryHistory';
54
import { routes } from './components/ReactApp';
65
React;
76

@@ -14,7 +13,6 @@ export default function renderApp (params) {
1413
}
1514

1615
// Build an instance of the application
17-
const history = createMemoryHistory(params.url);
1816
const app = <RouterContext {...renderProps} />;
1917

2018
// Render it as an HTML string which can be injected into the response

src/Microsoft.AspNet.AngularServices/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"typings": "dist/Exports",
1515
"author": "Microsoft",
1616
"license": "Apache-2.0",
17-
"peerDependencies": {
17+
"dependencies": {
1818
"angular2": "2.0.0-beta.1",
1919
"rxjs": "5.0.0-beta.0"
2020
},

src/Microsoft.AspNet.NodeServices/Configuration.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
namespace Microsoft.AspNet.NodeServices {
55
public static class Configuration {
6-
private static string[] defaultWatchFileExtensions = new[] { ".js", ".jsx", ".ts", ".tsx", ".json", ".html" };
6+
private readonly static string[] defaultWatchFileExtensions = new[] { ".js", ".jsx", ".ts", ".tsx", ".json", ".html" };
7+
private readonly static NodeServicesOptions defaultOptions = new NodeServicesOptions {
8+
HostingModel = NodeHostingModel.Http,
9+
WatchFileExtensions = defaultWatchFileExtensions
10+
};
11+
12+
public static void AddNodeServices(this IServiceCollection serviceCollection) {
13+
AddNodeServices(serviceCollection, defaultOptions);
14+
}
715

816
public static void AddNodeServices(this IServiceCollection serviceCollection, NodeServicesOptions options) {
917
serviceCollection.AddSingleton(typeof(INodeServices), (serviceProvider) => {

0 commit comments

Comments
 (0)