mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Switch to using DI to acquire Node instances. Bump versions to alpha2.
This commit is contained in:
@@ -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<ContentResult> 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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user