Giter Club home page Giter Club logo

asp-net-core-node-server's Introduction

NodeServer for ASP.NET Core

An extension of NodeServices to execute side by side versions of node packages.

Installation

Install-Package NeuroSpeech.NodePackageService

Install and setup ProGet from https://inedo.com/proget and publish your private packages onto npm registry inside ProGet. Support for authenticated npm registry will come in future.

Features

  1. Side by side execution of different version of same package
  2. Download and extract npm packages along with dependencies from private NPM repository such as ProGet
  3. TempFolder can be configured on D: drive, recommended for Azure VMs.

Security

  1. NodePackageService does not execute npm install or npm start script.
  2. TempFolder drive needs write access
  3. Only packages listed in PrivatePackages will be downloaded and extracted, however dependencies will not be restricted to package whitelist. Your developers must be careful for not include them in package dependencies.

Setup

services.AddSingleton<NodePackageService>(
    sp => new NodePackageService(sp,
        new NodePackageServiceOptions
        {
            // This must be unique to avoid multiple process accessing same
            // folder conflicts
            TempFolder = "D:\\temp\\" + Guid.NewGuid(),
            // ProGet private registry url
            NPMRegistry = "https://private-proget.company.com/npm/PRIVATE",
            PrivatePackages = new string[] {
                "@company/[email protected]",
                "@company/[email protected]"
            }
        }));

Execution

    [HttpGet("template/{version}/{name}")]
    public async Task<string> ProcessTemplate(
        [FromRoute] string name,
        [FromRoute] string version,
        [FromBody] EmailModel model,
        [FromService] NodePackageService packageService
    ) {

        // get node services from the installed package version
        // if version does not exist, it will download package
        // along with all its dependencies
        var package = await 
            packageService.GetInstalledPackageASync($"@company/template@{version}");

        return await package.NodeServices.InvokeExportAsync(
            "index.js",
            "default",
            new {
                fromName: "Sender",
                fromAddress: "senderEmail",
                body: model
            });

    }

GetInstalledPackageAsync method will create a folder {TempFolder}\npm\{package}\v{version} and it will extract package from given npm registry.

It will not install npm package, as IIS Website may not have sufficient rights to execute npm command. So in order to make things simpler, NodeServer inspects package.json file and downloads all dependencies in node_modules folder. It does not execute any scripts.

asp-net-core-node-server's People

Contributors

ackava avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.