npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

connect-owin

v0.4.0

Published

Connect middleware for .NET using OWIN

Downloads

9

Readme

connect-owin Build Status

Implement node.js connect middleware in .NET using OWIN.

Versions are incremented according to semver.

This is a fork of Tomasz Janczuk's original code; thanks go to him for getting this thing started!

Introduction

OWIN itself is not a technology, just a specification to decouple Web applications from the Web server. The goal of connect-owin is to implement this specification to use node.js, through connect framework, as the Web Server.

The connect-owin exports a function that returns a connect middleware. The function takes the path of the OWIN .NET assembly file as a parameter. The following code shows how to use connect-owin with express.js, a Web framework built on connect:

var owin = require('connect-owin'),
    express = require('express');

var app = express();
app.all('/net', owin('MyAssembly.dll'));
// ...
app.listen(3000);

.NET OWIN middlewares can be implemented in two ways with connect-owin:

  • By implementing the OWIN primary interface Func<IDictionary<string, object>, Task>:
public class Startup
{
  public Task Invoke(IDictionary<string, object> env) 
  {
    // ...
  }
}
  • By using the IAppBuilder interface that acts as the glue for any .NET OWIN middleware, exactly how connect in node.js works:
public class Startup
{
  public void Configuration(IAppBuilder builder)
  {
    // ...
  }
}

The connect-owin function uses <assembly name>.Startup as default type name, and Configuration as default method name. Custom type and method name can be provided via an options object:

owin({
    assemblyFile: 'MyAssembly.dll',
    typeName: 'MyNamespace.MyType',
    methodName: 'MyMethodName'
});

Requirements

Building

Grunt is used to build, test and preview the sample on all platforms.

First, install connect-owin dependencies:

$ npm install

Then, you'll need to install Grunt's command line interface (CLI) globally:

$ npm install -g grunt-cli

You can build sources, run tests and preview the sample by using the default Grunt task:

$ grunt

Building sources

$ grunt build

The build creates the lib\clr\Connect.Owin.dll file required by the lib\connect-owin.js library.

Running the sample

Using Grunt

The following command uses the grunt-contrib-connect task to start a connect web server with the .NET OWIN application plugged in as a middleware and open the page in your default browser:

$ grunt hello

Using express.js

An express.js sample is also provided to run the .NET OWIN application:

$ cd examples\hello
$ npm install express
$ node server.js

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

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

More samples available @ connect-owin-samples

Running tests

$ grunt test

mocha is used to run tests.