munar-plugin-serve
Munar plugin to allow other plugins to serve a web interface.
Last updated 2 years ago by goto-bus-stop .
ISC · Original npm · Tarball · package.json
$ cnpm install munar-plugin-serve 
SYNC missed versions from official npm registry.

munar-plugin-serve

Munar plugin that adds a web interface.

Installation

$ npm install --save munar-plugin-emotes

Usage

{
  "plugins": [
    ["serve", {
      // Required: The URL that you will access your server through.
      "baseUrl": "http://my-website.com/munar/",
      // Defaults to 3000
      "port": 80
    }]
  ]
}

For Plugin Developers

Plugins can define a serve method, which is handled by Micro:

class MyPlugin extends Plugin {
  async serve (req, res, micro) {
    // Objects are returned as JSON
    return { key: 'value' }

    // Text is returned as-is
    return '<h1>Hello World</h1>'

    // `micro` contains helper methods from the Micro module
    const inputParams = await micro.json(req)
    throw micro.createError(403, 'You shall not pass!')
    micro.send(res, 204, null)
  }
}

You can serve anything--files, a JSON API, a full web app, you name it. Your web service will be available at $baseUrl/$pluginName/. If your baseUrl is http://example.com/munar, the service for the emotes plugin can be found at:

http://example.com/munar/emotes

License

ISC

Current Tags

  • 2.0.4                                ...           latest (2 years ago)

6 Versions

  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |