Expressive, class based approach web framework. It uses the latest ES7 features like async/await and decorators to make writing web apps and apis simple and fun. It can be used thru typescript only at the moment
This framework is not actively developed for couple of years now and should not be used in production.
It stays here for historical reasons as the first(to my knowledge) framework with async-await and decorators support (through typescript at the time).
Additionally, it may be a good resource for learning due to its relatively small code base.
$ npm install ccd
//you can bundle the controllers logic in a single or multiple classesclassHelloCtrlextendsCCController{//use decorators on the controllers to
@get('/hello')//or get('/hello', ...any middleware methods)helloWorld(req,res){//return anything, object|(err,data)=void, promise .. it works with all of themreturn'helloWorld'}
@get('/db')getFromDb(req,res){//simple as that, no callbacks no waitingreturnthis.svc.getById(req.params.id)}
@get('/db-more')asyncgetFromDb(req,res){//simple as that, no callbacks no waitingletresult=awaitthis.svc.getById(req.params.id)//... more workreturnresult;}
@put('/crash')crash(req,res){//server will keep working and will return 500 throw'whatever'}
@get('/async')helloWorldAsync(req,res){returnnewPromise((resolve)=>{setTimeout(function(){resolve({value:'hello async'});},200);})}
@get('/async-error')asyncerrorWorldAsync(req,res){returnawaitnewPromise((resolve,reject)=>{setTimeout(function(){reject('I just crashed in error world');},200);})}}//Attach the controller to expressconstctrl=newHelloCtrl()app.use('/',ctrl.router)app.use('/hello',ctrl.router)app.listen(3000); typescript
debug
express>
mongoose
1. ccd-mongo
- Integration with mongod for rapid development of db driven services
npm install ccd-mongo- Example:
classUserCtrlextendsCCServiceController<User>{
@post('/login')login(req,res){//yes, that simple, //model is regulat mongoose modelreturnthis.model.findOne(req.body);}}//Or If you preffer to separate services and controllers then:classSpiecesSvcextendsCCService<Spiece>{ofKind(kind:string){returnthis.model.find({Kind:kind}).exec();}}//----------classSpiecesCtrlextendsCCController{spieces: newSpiecesSvc('Spieces')
@get('/spieces/:kind')ofKind(req,res){returnspieces.ofKind(req.params.kind);}}1. ccd-ng2
- Provides
@ngGenSvcdecorator that generates angular2 services for a givenCCController
@ngSvcGen('./client/svc',true)classHelloCtrlextendsCCController{
@get('/hello/:name')helloWorld(req,res){return`hello ${req.params.name}`}
@post('/:id')doSomething(req,res){return ....}
...
}import{Injectable}from'@angular/core';import{SimpleRestService}from'ccNgRest';
@Injectable()exportclassHelloCtrlSvc{constructor(privaterest: SimpleRestService){}helloWorld(name){returnthis.rest.get('/hello/'+name);}doSomething(id,payload){returnthis.rest.post('/'+id,payload);}}1. ccd-doc
- Not published yet
