oxygen

0.0.2 • Public • Published

oxygen

oxygen is a small web middleware framework which is inspired by express and koa.

The main differences between express/koa and oxygen are

  • oxygen is written fully in ES6
  • oxygen uses async functions to control middleware flow

--

Using oxygen

This is an example app built with oxygen

import oxygen from './'; // assumes that this file is in the root of this project
import rp from 'request-promise';
 
const app = oxygen();
 
// basic error handling
app.use(async function(next){
    try {
        await next();
    } catch(e) {
        console.log(e);
    }
});
 
// request logging
app.use(async function(next){
    var start = new Date;
    await next();
    var ms = new Date - start;
    console.log('%s %s - %s', this.req.method, this.req.url, ms);
})
 
app.use(async function(next){
    const google = await rp('https://www.google.com');
    this.res.end(google);
});
 
app.listen(1337);

Readme

Keywords

none

Package Sidebar

Install

npm i oxygen

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • tikotzky