这个是page包的依赖;里面主要是生成的各个中间件

修改jade为ejs
先npm install 安装这个ejs ,然后需要在app.js 修改以下几句:

利用中间件加载静态资源

这个里面的express.static 其实是一个全局的唯一的中间件函数;所以比较有趣了。
利用es5 开始导出js模块;

在目录routes底下有对应的分模块:这个里面其实有一个混淆点 就是在自己的分模块中get 的路径是'/
这个是为什么呢?
其实这个是为了利用中间件的next机制来做的;在app.js 中 利用use来设定这个中间件的状态,然后寻找到分模块中的函数。这样就做到了分模块的解耦,如同热插拔的形式来做的。


这个里面是处理404 和服务器内部错误--500;
这个里面的404 用了next 来做下一层中间件的传递,可以让服务器来处理具体的错误。
本章就讲解到这,对创建后的目录结构和每一个js文件的作用做了分析。下一章节会对ejs的标签做分析;
网友评论