mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Switch to using DI to acquire Node instances. Bump versions to alpha2.
This commit is contained in:
@@ -79,6 +79,9 @@ namespace MusicStore
|
||||
Mapper.CreateMap<ArtistResultDto, Artist>();
|
||||
Mapper.CreateMap<Genre, GenreResultDto>();
|
||||
Mapper.CreateMap<GenreResultDto, Genre>();
|
||||
|
||||
// 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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user