Objective
Kraken.js A quick development tool for rapid development based on Express.js framework applications by PayPal, because Kraken does not change much on express.js basis. Only in the original express based on the addition of a number of agreed development rules, so that development based on convenience.
Hello, world!
To create a Kraken project requires only a very simple three-step walk:
Install Prerequisite Tools
Linux or Mac
sudo npm install-g generator-kraken
Windows
NPM install-g Generator-kraken
Create a Kraken Project
You just need one line of code, and then, looking at the prompt, enter something, and a project is created.
Yo Kraken
Run Kraken Project
Or just one line of code
NPM start
The above three lines of code can complete the creation of a Kraken project.
Precautions:
Yo Kraken you enter the name of the project, you will create a folder with the name of the project in the current project, remember the CD in the folder and run NPM start
Note that the configuration of the Kraken is based on the current node_env, so it's best to check the current node_env if it's node_env. By default, Node_env is not set or set to development, when started , Kraken will load the./public/templates under the template, set the other values, it will be loaded./.build/templates and this happens when you run the grunt build in the Kraken project directory. Build This directory is used for deployment when the node_env is set to production or other values are loaded.
View the NODE_ENV environment of your current system
Linux or Mac
Echo $NODE _env
Windows
Echo%node_env%
Agreed development
Personal opinion Kraken is not so much a framework as it simply provides a flexible and convenient way to build express applications.
Configuration (/config)
Kraken in./config the two types of configuration files are agreed:
App.json for configuration, host, Port, i18n, Express and so on.
Middleware is used for the configuration of the default middleware, currently supported middleware has APPSEC, compiler, session, Errorpages, static, detailed parameter configuration please read the Official document, here is not to repeat.
In addition, Kraken also agreed to support automatic matching of the corresponding configuration file according to the node_env rule:
App-node_env.json
For example, the current node_env is development, you have a App-development.json file in the directory, you will first read the configuration of the file.
Controller (/controllers)
Routing control
Kraken is automatically loaded by default./controllers the file under the routing control, personal feel, this really worry. The next way to do this is exactly the same as express!
Module.exports = function (server) {
Server.get ('/customer ', function (req, res) {
Res.send (' Hello world ');
});
};
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/