packaged type-mvc
This repo is for distribution on npm
. The source for this module is in the
main repo.
type-mvc is base on koa, with typescript. Decorator, Ioc, AOP MVC frameworker on server. base on ioc @ts-ioc
. help you develop your project easily.
Install
You can install this package either with npm
npm
npm install type-mvc
Documentation
-
1.0.1
- add useServer to add Server Middleware features.
-
0.6.3
- update compile task, zip lib.
- update tsioc for fix bug when inherit class with classAnnations
-
0.5.5
- fix ConsoleLog error console.debug in nuix will not console.
- update components for route.
-
v0.5.3
- fix bug in nuix linux load .d.ts file raise error, set default comfig load module with !./**/*.d.ts exclude.
-
v0.5.1
-
add Log aop aspect service. for Log easy. default user console to log, can config
logLib
,logConfig
in yourconfig.js
to use third logger lib. eg.{ logLib: 'log4js', logConfig:{...} }
. has implements log4js adapter see code -
DebugAspect, config
debug: true
, in yourconfig.js
, will auto log debug info. -
AnnotationLogerAspect @annotation(Logger), logger some state via @Logger decorator config.
-
add Annotation Auth aspect service
AuthAspect
to support yourself auth check easy. eg.
-
- v0.4.1 fix assertUrlRegExp bug.
- v0.3.20 New Feature:
- Router and Cors middleware will check url is right route or not. add default route Url check in Configuartion. isRouteUrl method and routeUrlRegExp field.
- v0.3.19 New Feature: Fix bug, reset context middleware order to fix 500 error, when some time request.
- v0.3.18 New Feature:
- update tsioc to improvement method invoker.
- fix Model not register bug. get Model return empty object.
- v0.3.17 New Feature:
- add hostname for http or https to listen.
- v0.3.12 New Feature:
- es5 support. enable config https http server.
- v0.3.10 New Feature:
- Restfull params or Query String params can auto set to Controller action(Controller method) via the name of param matched.
Start
create application
;// 1.Bootstrap.create__dirname .useConfiguration //.use(middleware: IMiddleware | Middleware | Token<any>) //.useContainerBuilder(...) .run; // 2. Bootstrap.create__dirname .useConfiguration .bootstrapMvcApi; // 3. Bootstrap.create__dirname .useConfiguration .bootstrapMvcApi;
Define Model
- third ORM Model: Configuration ModelOptions in your config file. like:
;
Define Controller
default setting load controllers in your project folder
/controllers
- Each Controller action should return type
ResultValue
, also you can return base type or object, it deal with JsonResult. - The action can be
async
orsync
. Have provideFileResult
,JsonResult
,RedirectResult
,ViewResult
. - Also, you can extend with
BaseController
, it has implements some mothod to create theResultValue
types. - Model can auto create in action, it auto load value from request body.
- Restfull params or Query String params can auto set to Controller action(Controller method) via the name of param matched.
- Cors by
@Cors
decorator in class or method.
define as:
;;;;
Define AOP
Auto load Aspect service from folder /aop
in your project.
see simple demo
;
Define Middlewares
default setting load middlewares in your project folder
/middlewares
;;
Simples
License
MIT © Houjun