2.1.1 • Published 9 years ago

rocore v2.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

rocore

code async with ECMAScript 6 generator.

Install

$ npm install rocore

Useage

// server.js

import * as Rocore from 'rocore';
import      Http   from 'http';
import      Qs     from 'querystring';
import      Fs     from 'fs';

var server = Http.createServer();
var app    = Rocore.createApplication();

app
    .on('found', (route, req, res) => { 
        req.body = {};  // parsing body  
        app.exec(route, req, res);
    })  
    .on('notfound', (req, res) => { 
        res.writeHead(404);
        res.end();
    })
    .get('/demo/:username?mark=1', who, send);

server
    .on('request', (req, res) => { 
        app.match(req, res); 
    })
    .listen(8000);

function* who(ynext, next, req, res) {
    console.log(req.protocol);
    console.log(req.auth);
    console.log(req.hostname);
    console.log(req.port);
    console.log(req.pathname);
    console.log(req.params.username);
    console.log(req.query.mark);
    console.log(req.hash);
    yield* next;
}

function* send(ynext, next, req, res) {
    var [err, data] = yield Fs.readFile('/home/username/test.js', 'utf8', ynext);
    res.write(data);
    res.end();
}

Need https://github.com/babel/babel (ECMAScript 6)

$ npm install -g babel $ babel-node server.js

→ API document

2.1.1

9 years ago

2.1.0

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.7

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.2.17

9 years ago

0.2.16

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago