yahoi
Version:
Yet Another Highly Opinionated Isomorphic Framework
84 lines (60 loc) • 1.56 kB
JavaScript
//import validate from 'express-validation';
import ActionContext from './ActionContext';
import path from 'path';
import * as Renderer from './Renderer'
export default class Controller {
constructor(props) {
this.app = props.app;
this.config = {};
}
setAppReference(app) {
this.app = app;
}
getEnvironment() {
return this.app.getEnvironment()
}
getService(name) {
return this.app.getService(name)
}
setContainerDirectory(containerDirectory) {
this.__containerDirectory = containerDirectory;
}
getContainerDirectory() {
return this.__containerDirectory;
}
setComponentDirectory(componentDirectory) {
this.__componentDirectory = componentDirectory;
}
getComponentDirectory() {
return this.__componentDirectory;
}
setViewDirectory(viewDirectory) {
this.__viewDirectory = viewDirectory;
}
getViewDirectory() {
return this.__viewDirectory;
}
setProjectDirectory(dir) {
this.__projectDirectory = dir;
}
getProjectDirectory() {
return this.__projectDirectory;
}
renderAction(name, req, res, match) {
return new Promise((fulfill, reject) => {
// console.log('calling Action: ', `${name}Action`);
var action = new ActionContext({
config: this.config,
match: match,
req: req,
res: res,
app: this.app,
action: this[`${name}Action`],
controller: this,
send: fulfill,
reject: reject
});
action.run();
});
}
}