2.1.1 • Published 10 years ago

rocore v2.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 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

10 years ago

2.1.0

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.7

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.17

11 years ago

0.2.16

11 years ago

0.2.8

11 years ago

0.2.7

11 years ago

0.2.6

11 years ago

0.2.4

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago