https://github.com/vstirbu/regio
Minimalist web framework with express-like aspirations
https://github.com/vstirbu/regio
Last synced: 6 months ago
JSON representation
Minimalist web framework with express-like aspirations
- Host: GitHub
- URL: https://github.com/vstirbu/regio
- Owner: vstirbu
- License: mit
- Created: 2014-10-04T14:18:11.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-26T21:29:10.000Z (over 10 years ago)
- Last Synced: 2025-04-20T06:35:20.243Z (6 months ago)
- Language: JavaScript
- Size: 201 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# regio
Minimalist web framework with express-like aspirations, targeted at embedded devices like [Tessel](https://tessel.io) and [Espruino](http://www.espruino.com). Therefore, instead being a mighty express it is just a regional train...
[](https://travis-ci.org/vstirbu/regio) [](https://codeclimate.com/github/vstirbu/regio) [](https://gitter.im/vstirbu/regio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
## Motivation
So why another framework?
This framework started as a test suite while investigating how to get [express](http://expressjs.com) running on Tessel.
Because there were simply too many moving parts in slimming down express, I've decided to start with a clean slate and incorporate express middlewares one at a time.
In the process I found out that there is quite a lot of stuff to handle pre 4.x API, disambiguation of function parameters and also too many convenience methods for such a constrained environment as on the devices I was targeting.
So, I've decided to keep the test framework around and use express middleware and components where it does feel appropriate, especially as Espruino is also a target environment.
## Installation
```sh
npm install regio
```## Usage
```javascript
var regio = require('regio');var app = regio();
app.get('/', function(req, res) {
res.status(200).send({
message: 'Hello World'
}).end();
});app.use(function (req, res, next) {
req.message = 'added by middleware';
next();
});var subapp = regio.router();
subapp.get('/', function(req, res) {
res.status(200).send({
message: 'I\'m a mounted application'
}).end();
});subapp.on('active', function() {
// server is up, I can receive requests
});app.use('/mounted', subapp);
var server = app.listen(8080, function() {
console.log('app started on port', server.address().port);
});
```## Express compatibility
* Application
* regio() similar to [express()](http://expressjs.com/4x/api.html#express)
* [use](http://expressjs.com/4x/api.html#app.use)
* [all](http://expressjs.com/4x/api.html#app.all)
* [listen](http://expressjs.com/4x/api.html#app.listen)
* mountpath* Request
* req.params* Response
* res.status
* res.set
* res.get
* res.send* Router
* [router()](http://expressjs.com/4x/api.html#router)
* [router.use](http://expressjs.com/4x/api.html#router.use)
* [router.VERB](http://expressjs.com/4x/api.html#router.VERB)
* [router.all](http://expressjs.com/4x/api.html#router.all)
* events
* _mounted_ is triggered when router is mounted
* _active_ is triggered when server is listeningMiddleware
* can be used application and router level, using ```.use``` or ```.verb```.## Tests
Currently the test run in node but the plan is to move them to colony.
```sh
npm test
```