Giter Site home page Giter Site logo

edge-connect's Introduction

owin-connect

Implement node.js express handlers and connect middleware in .NET using OWIN

The lay of the land

This module has a package.json dependency on the [email protected] module which provides basic .NET to node.js interop mechanisms.

The src\Owin.Connect directory contains a C# library project that implements an OWIN HTTP server. The server implements two functions: Configure and Invoke. The Configure is responsible for loading and configuring an OWIN .NET application. This is where all the patterns of OWIN OM would need to be implemented. The Invoke is responsible for processing a single HTTP request using one of the previously loaded OWIN .NET applications, normalized to Func<IDictionary<string,object>,Task> form.

Both Configure and Invoke are exposed to node.js using the fundational capabilities of owin. The lib\owin-connect.js calls these functions from node.js. The lib\owin-connect.js exports a function that is a factory of connect middleware. The function takes the name of the OWIN .NET assembly file as a parameter, and passes it (along with other optional parameters) to the Configure method of the OWIN HTTP server.

Building

The Owin.Connect library needs to be built first. Once we arrive in a stable place, a binary will be checked into git to make consuming owin-connect easier.

From a VS 2012 command prompt, go to the root of the project and

msbuild src\Owin.Connect\Owin.Connect.sln
set OWIN_CONNECT_NATIVE=C:\projects\owin-connect\src\Owin.Connect\bin\Debug\Owin.Connect.dll

The OWIN_CONNECT_NATIVE must be set to the location of the built Owin.Connect.dll. The owin-connect.js will use that location if specified. This is helpful during development and required until a stable binary is checked into the repo.

Running the sample

You need Windows, node.js 0.8.x (tested with 0.8.19), and .NET 4.5 along with VS 2012 toolset for building.

Assuming the project was git-cloned and built, run this from the VS 2012 command prompt from the root of the project:

npm install
cs samples\hello
npm install express
build.bat
node server.js

The go to http://localhost:3000/node. This should display a message from an express handler in node.js.

If you go to http://localhost:3000/net, you should see a similar message from the .NET OWIN application in Owin.Samples.dll plugged in as a handler to the express pipeline.

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.