Skip to content

An Express-like server framework, mostly for shits, partly for giggles

Notifications You must be signed in to change notification settings

ammarm08/bandwagon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bandwagon

An Express-like server framework, mostly for shits, partly for giggles.

Just exploring ... don't actually use this

  • All middleware and route functions must return a Promise

  • All middleware and route functions are passed a Request and Response object.

  • By default, URL is parsed into a req.url property that contains further data on the URL

  • By default, body is parsed into moved into req.body

Sample usage:

const bandwagon = require('index.js');
const app = bandwagon();
const PORT = 3000;

// sample middleware
function someMiddleWare (req, res) {
  return new Promise(resolve => {
    // .... do stuff with req
    console.log(req.url);
    resolve();
  });
}

// sample handler
function handleRoot (req, res) {
  return new Promise(resolve => {
    res.writeHead(200, {'Content-Type': 'application/json'});
    res.end(JSON.stringify({foo: 'bar'}));
    resolve();
  });
}

// add custom middlewares ...
app.set(someMiddleWare);

// add routes
app.get('/', handleRoot);

app.listen(PORT, () => console.log(`Bandwagon listening on http://localhost:${PORT}`));

About

An Express-like server framework, mostly for shits, partly for giggles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published