0.4.2 • Published 9 years ago
microscope-web v0.4.2
microscope-web
ES6, Express/Connect fully compatible, POO & Modular Web framework.
Requirements
- node
- npm
- gulp
Node.js installation
Install on OSX
Using homebrew:
brew install node
Install on Linux (Ubuntu/Mint)
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Install on Windows
Installation
install gulp (sudo on linux/OSX) :
npm install gulp -g
install dependencies (sudo on linux/OSX) :
npm install
Development commands
test (run gulp test):
npm test
test:
gulp test
- validate source code (jsHint).
docs:
gulp docs
- generate annoted code documentation (docco).
- generate annoted code samples documentation (docco).
How to use ?
Check out project samples !!!
Application class
With ES5
var HttpApplication = require('microscope-web').HttpApplication;
var HomeController = require('./controllers/HomeController');
var AuthApplication = require('../auth/AuthApplication');
var logger = require('./middlewares/commonMiddleware');
var Application = HttpApplication.extend({
// register application controllers in array
controllers: [HomeController],
// register application middlewares in array
// templateEngine, logging, authentication, ...
// call middleware with express instance in parameter.
// configure using app.use([middleware]);
middlewares: [logger],
// use AuthApplication class as sub application
// map to /auth/{controller}/{action}
areas: {
'/auth': AuthApplication
}
});
module.exports = Application;
With ES6
import {HttpApplication} from 'microscope-web';
import HomeController from './controllers/HomeController';
import AuthApplication from '../auth/AuthApplication';
import {logger} from './middlewares/commonMiddleware';
class Application extends HttpApplication {
// register application controllers in array
get controllers(){
return [HomeController];
}
// register application middlewares in array
// templateEngine, logging, authentication, ...
// call middleware with express instance in parameter.
// configure using app.use([middleware]);
get middlewares(){
return [logger];
}
// use AuthApplication class as sub application
// map to /auth/{controller}/{action}
get areas(){
return {'/auth': AuthApplication}
}
}
var a = new Application();
a.run(() => console.log('application running'));
With experimental ES7
import {HttpApplication, decorators} from 'microscope-web';
import AuthApplication from '../auth/AuthApplication';
import HomeController from './controllers/HomeController';
import {logger} from './middlewares/commonMiddleware';
var {controllers, middlewares, areas} = decorators;
@controllers([HomeController])
@middlewares([logger])
@areas({'/auth': AuthApplication})
class Application extends HttpApplication {
}
var a = new Application();
a.run(() => console.log('application running'));
Controller class
With ES5:
var Controller = require('microscope-web').Controller;
var filters = require('../filters/commonFilters');
var HomeController = Controller.extend({
filters: [filters.controllerFilter],
routes: {
'get /': [filters.actionFilter, 'index'],
'get /home/about': 'about'
},
// index action
// GET /
index: function(request, response){
response.send('index HomeController');
},
// about action
// GET /home/about
about: function(request, response){
response.send('about HomeController');
}
});
module.exports = HomeController;
With ES6:
import {Controller} from 'microscope-web';
import {controllerFilter, actionFilter} from '../filters/commonFilters';
class HomeController extends Controller {
// add some controllers filter
get filters(){
return [controllerFilter];
}
// configure controller routing with callback array
get routes(){
return {
'get /': [actionFilter, 'index'],
'get /home/about': 'about'
}
}
// index action
// GET /
index(request, response){
response.send('index HomeController');
}
// about action
// GET /home/about
about(request, response){
response.send('about HomeController');
}
}
export default HomeController;
With experimental ES7
import {Controller, decorators} from 'microscope-web';
import {controllerFilter, actionFilter} from '../filters/commonFilters';
var {filters, routes} = decorators;
@filters([controllerFilter])
@routes({
'get /': [actionFilter, 'index'],
'get /home/about': 'about'
})
class HomeController extends Controller {
// index action
// GET /
index(request, response){
response.send('index HomeController');
}
// about action
// GET /home/about
about(request, response){
response.send('about HomeController');
}
}
export default HomeController;
Roadmap
- TypeScript definition support
0.4.2
9 years ago
0.4.1
9 years ago
0.4.0
9 years ago
0.3.1
9 years ago
0.3.0
9 years ago
0.2.2
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.1
9 years ago
0.1.0
9 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago