1.0.2 • Published 8 years ago

mcrsvc v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

mcrsvc

Build Status

micro + routes! <3.

install

$ npm install mcrsvc --save

example

// using promise
const app = require('mcrsvc');

app.router.add('GET', '/hello', (req, res) => {
  // some async process
  return new Promise((resolve) => {
    setTimeout(() => resolve({'OK': 1}), 100);
  });
});
const app = require('mcrsvc');

app.router.add('GET', '/hello/:id', async (req, res) => {
  return req.params;
});

app.router.add('POST', '/hello/:id', async (req, res) => {
  return req.body;
});

// module.exports = app;
// put it in index.js, then
// $ micro -p 3000

// to make it standalone, you might need babel or async-to-gen.
const micro = require('micro');
micro(app)
  .listen(3000, (err) => {
    if (err) {
      throw err;
    }
    console.log('~>', 3000);
  });

license

MIT

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago