-
Notifications
You must be signed in to change notification settings - Fork 0
/
bs-config.uni.js
41 lines (35 loc) · 1.02 KB
/
bs-config.uni.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module.exports = function(bs) {
return {
"open": true,
"port": 3200,
"server": {
"baseDir": "aot",
"routes": {
"/node_modules": "node_modules"
},
"middleware": [
testMiddleware
]
}
};
};
function testMiddleware (req, res, next) {
var routes = []; //['/', '/dashboard', '/heroes'];
var prefixRoutes = ['/detail/', '/styles.css'];
var url = req.originalUrl;
if (routes.indexOf(url) >= 0 || prefixRoutes.some(function(r) { return url.startsWith(r); })) {
console.log('test handling ' + url);
res.setHeader('Content-Type', 'text/css');
res.end("this should be css");
return;
}
console.log('test skipping ' + url);
// var parsed = require("url").parse(req.url);
// if (parsed.pathname.match(/\.less$/)) {
// return less(parsed.pathname).then(function (o) {
// res.setHeader('Content-Type', 'text/css');
// res.end(o.css);
// });
// }
next();
}