Git Product home page Git Product logo

gateway-2's Introduction

Gateway

A web server/application interface that works with Node.js's asynchronous nature.

Gateway is a server/application interface that aims to allow developers to reuse web components. It is influenced by many different libraries such as:

The major difference with these libraries and Gateway is the fact that Node.js is fully asynchronous. This means that the "simple" API of those libraries of just returning the response is pretty much useless to Node.js web applications. Instead we mix the specification of those libraries with the simple API of Node.js's own HTTP server.

Here is a simple application that utilizes the CommonLogger and Static middleware.

var Gateway = require('./../lib/gateway');

function MyApp(request, response) {
  var content = "Hello World";
  response.sendHeader(200, {
    'content-type': 'text/html',
    'content-length': content.length
  });
  response.write(content);
  response.close();
};


var builder = new Gateway.Builder();

builder.use(Gateway.Middleware.CommonLogger);
builder.use(Gateway.Middleware.Static, {
  root: process.path.dirname(__filename),
  urls: ["/favicon.ico", "/css"]
});
builder.use(MyApp);

builder.listen(Gateway.Handler.NodeHttp, {port: 8000});

Boot the example app with:

node examples/demo.js

Note

Gateway currently only runs against the HEAD of Node.js, not the last "official" release. This is due to the constantly changing API of Node.js. In the future, once Node.js's API is more stable, Gateway will be maintained in 2 branches, one for Node.js's latest stable and one for Node.js's HEAD.

TODO

  • More Tests!
  • Documentation

gateway-2's People

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.