Comparing version 3.1.3 to 3.1.4
'use strict'; | ||
const Koa = require('koa'); | ||
const LarkMVC = require('..'); | ||
const LarkMVC = require('lark-mvc'); | ||
@@ -6,0 +6,0 @@ class ShowIntroduction extends LarkMVC.Controller { |
@@ -7,2 +7,3 @@ /** | ||
const assert = require('assert'); | ||
const debug = require('debug')('lark-mvc.MVC'); | ||
const Config = require('lark-config'); | ||
@@ -16,2 +17,3 @@ | ||
constructor() { | ||
debug('construct'); | ||
this.controllers = new Config(); | ||
@@ -23,8 +25,11 @@ this.models = new Config(); | ||
controller(path) { | ||
debug(`get controller ${path || '<default>'}`); | ||
return path ? this.controllers.get(path) : this.controllers.config; | ||
} | ||
model(path) { | ||
debug(`get model ${path || '<default>'}`); | ||
return path ? this.models.get(path) : this.models.config; | ||
} | ||
view(path) { | ||
debug(`get view ${path || '<default>'}`); | ||
const viewKeys = Object.keys(this.views.config); | ||
@@ -36,2 +41,3 @@ assert(Object.keys(viewKeys).length > 0, 'No views found'); | ||
use(component, options = {}) { | ||
debug('using component'); | ||
const maps = { | ||
@@ -42,3 +48,3 @@ [Controller.MVC_TYPE]: this.controllers, | ||
}; | ||
assert(component instanceof Function, 'Componennt must be a class'); | ||
assert(component instanceof Function, 'Component must be a class'); | ||
assert('string' === typeof component.name, 'Invalid component name, should be a string'); | ||
@@ -62,2 +68,3 @@ assert(options instanceof Object, 'Options must be an object'); | ||
_inject(component) { | ||
debug('inject'); | ||
let mvc = this; | ||
@@ -105,2 +112,3 @@ let result = null; | ||
dispatch(controller, ...args) { | ||
debug('dispatch'); | ||
assert(controller, 'Invalid controller'); | ||
@@ -107,0 +115,0 @@ if ('string' === typeof controller) { |
{ | ||
"name": "lark-mvc", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "MVC for building web service", | ||
"main": "./lib/MVC", | ||
"scripts": { | ||
"test": "./node_modules/.bin/eslint index.js example/** lib/** && ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require should --recursive test", | ||
"debug": "node --inspect-brk=9229 example/app.js" | ||
"lint": "./node_modules/.bin/eslint index.js example/** lib/**", | ||
"pretest": "npm run lint && npm link && npm link lark-mvc", | ||
"test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require should --recursive test", | ||
"posttest": "npm unlink", | ||
"debug": "node --inspect-brk=9229 example/index.js" | ||
}, | ||
@@ -28,3 +31,4 @@ "repository": { | ||
"dependencies": { | ||
"lark-config": "^2.4.0" | ||
"debug": "^2.6.8", | ||
"lark-config": "^2.6.0" | ||
}, | ||
@@ -34,2 +38,3 @@ "devDependencies": { | ||
"eslint": "^3.19.0", | ||
"eslint-plugin-spellcheck": "0.0.8", | ||
"istanbul": "^1.1.0-alpha.1", | ||
@@ -36,0 +41,0 @@ "koa": "^2.0.0-alpha.8", |
@@ -6,3 +6,3 @@ /** | ||
const mvc = require('../example/app'); | ||
const mvc = require('lark-mvc/example'); | ||
@@ -9,0 +9,0 @@ describe('mvc', () => { |
Sorry, the diff of this file is not supported yet
13177
257
2
7
+ Addeddebug@^2.6.8
+ Addeddebug@2.6.9(transitive)
+ Addedms@2.0.0(transitive)
Updatedlark-config@^2.6.0