Authored by 周少峰

auto

Showing 1 changed file with 11 additions and 6 deletions
@@ -30,10 +30,11 @@ const fp = require('lodash/fp'); @@ -30,10 +30,11 @@ const fp = require('lodash/fp');
30 const pkg = require('./package.json'); 30 const pkg = require('./package.json');
31 const app = express(); 31 const app = express();
32 const helpers = global.yoho.helpers; 32 const helpers = global.yoho.helpers;
  33 +
33 app.get('/test1', (req, res) => { 34 app.get('/test1', (req, res) => {
34 res.set('Cache-Control', 'no-cache'); 35 res.set('Cache-Control', 'no-cache');
35 res.send('test1'); 36 res.send('test1');
36 -}) 37 +});
37 app.disable('x-powered-by'); 38 app.disable('x-powered-by');
38 39
39 // tdk 40 // tdk
@@ -66,7 +67,8 @@ app.set('subdomain offset', 2); @@ -66,7 +67,8 @@ app.set('subdomain offset', 2);
66 app.get('/test2', (req, res) => { 67 app.get('/test2', (req, res) => {
67 res.set('Cache-Control', 'no-cache'); 68 res.set('Cache-Control', 'no-cache');
68 res.send('test2'); 69 res.send('test2');
69 -}) 70 +});
  71 +
70 // 添加请求上下文 72 // 添加请求上下文
71 app.use(global.yoho.httpCtx()); 73 app.use(global.yoho.httpCtx());
72 74
@@ -143,10 +145,12 @@ try { @@ -143,10 +145,12 @@ try {
143 const layoutTools = require('./doraemon/middleware/layout-tools'); 145 const layoutTools = require('./doraemon/middleware/layout-tools');
144 const pageCache = require('./doraemon/middleware/page-cache'); 146 const pageCache = require('./doraemon/middleware/page-cache');
145 const devtool = require('./doraemon/middleware/devtools'); 147 const devtool = require('./doraemon/middleware/devtools');
  148 +
146 app.get('/test3', (req, res) => { 149 app.get('/test3', (req, res) => {
147 res.set('Cache-Control', 'no-cache'); 150 res.set('Cache-Control', 'no-cache');
148 res.send('test3'); 151 res.send('test3');
149 - }) 152 + });
  153 +
150 // YOHO 前置中间件 154 // YOHO 前置中间件
151 app.use(setYohoData()); 155 app.use(setYohoData());
152 156
@@ -158,7 +162,8 @@ try { @@ -158,7 +162,8 @@ try {
158 app.get('/test4', (req, res) => { 162 app.get('/test4', (req, res) => {
159 res.set('Cache-Control', 'no-cache'); 163 res.set('Cache-Control', 'no-cache');
160 res.send('test4'); 164 res.send('test4');
161 - }) 165 + });
  166 +
162 // 请求限制中间件 167 // 请求限制中间件
163 if (!app.locals.devEnv) { 168 if (!app.locals.devEnv) {
164 app.use(require('./doraemon/middleware/limiter')); 169 app.use(require('./doraemon/middleware/limiter'));
@@ -166,7 +171,7 @@ try { @@ -166,7 +171,7 @@ try {
166 app.get('/test5', (req, res) => { 171 app.get('/test5', (req, res) => {
167 res.set('Cache-Control', 'no-cache'); 172 res.set('Cache-Control', 'no-cache');
168 res.send('test5'); 173 res.send('test5');
169 - }) 174 + });
170 app.use(seo()); 175 app.use(seo());
171 app.use(setPageInfo()); 176 app.use(setPageInfo());
172 app.use(layoutTools()); 177 app.use(layoutTools());
@@ -178,7 +183,7 @@ try { @@ -178,7 +183,7 @@ try {
178 app.get('/test6', (req, res) => { 183 app.get('/test6', (req, res) => {
179 res.set('Cache-Control', 'no-cache'); 184 res.set('Cache-Control', 'no-cache');
180 res.send('test6'); 185 res.send('test6');
181 - }) 186 + });
182 require('./dispatch')(app); 187 require('./dispatch')(app);
183 188
184 app.all('*', errorHandler.notFound()); // 404 189 app.all('*', errorHandler.notFound()); // 404