Giter Site home page Giter Site logo

envented's Introduction

#envented ##Evented node.js server framework ##Install

$ npm install envented

##Run tests

$ npm test

or

$ make test

##Why Node.js has a lot of events. The process object has events. HTTP servers have events. Streams have events. Higher-level modules have events. However, you can't really write a web app with events. Node http servers emit events, but they don't emit events based on the type of request. For example

var server = http.createServer();
server.on('request', function(req, res){
	// do stuff
});

Do you do that? Probably not, you probably just do this:

var server = http.createServer(function(req, res){
	// do stuff
});

Now, those two methods of creating a server are the same. Which means building an actual server out of one or the other is also the same.

##Get to the point

envented lets you do this:

var envented = require('envented');

var server = envented.Server() // this accepts an onRequest callback

server.use(server.router); // server is an EventEmitter2 instance. YOU MUST USE THE ROUTER

server.on('get::/', function(req, res){
	res.end("Hi");
});

server.on('post::/form', function(req, res){
	// handle post data
});

The event namespacing is courtesy of EventEmitter2. All your favorite connect middleware is inside of envented.

envented'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.