oxygen

Oxygen Web Framework

Usage no npm install needed!

<script type="module">
  import oxygen from 'https://cdn.skypack.dev/oxygen';
</script>

README

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);