Skip to content
This repository was archived by the owner on Feb 2, 2019. It is now read-only.

Commit 2dafc03

Browse files
author
codekraft-studio
committed
Added middleware for example
1 parent 5d33442 commit 2dafc03

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

Gruntfile.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ module.exports = function(grunt) {
44

55
pkg: grunt.file.readJSON('package.json'),
66

7+
banner: '/**\n' +
8+
'* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
9+
'* Description: <%= pkg.description %> \n' +
10+
'* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
11+
'* @author <%= pkg.author %> \n' +
12+
'* @license <%= pkg.license %> \n'+
13+
'*/\n',
14+
715
jshint: {
816
gruntfile: ['Gruntfile.js'],
917
scripts: ['src/**/*.js']
1018
},
1119

1220
concat: {
1321
options: {
14-
banner: '/**\n' +
15-
'* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
16-
'* Description: <%= pkg.description %> \n' +
17-
'* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
18-
'* @author <%= pkg.author %> \n' +
19-
'* @license <%= pkg.license %> \n'+
20-
'*/\n'
22+
banner: '<%= banner %>'
2123
},
2224
dist: {
2325
src: ['src/<%= pkg.name %>.module.js', 'src/<%= pkg.name %>.*.js'],
@@ -28,13 +30,7 @@ module.exports = function(grunt) {
2830
uglify: {
2931
options: {
3032
mangle: false,
31-
banner: '/**\n' +
32-
'* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
33-
'* Description: <%= pkg.description %> \n' +
34-
'* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
35-
'* @author <%= pkg.author %> \n' +
36-
'* @license <%= pkg.license %> \n'+
37-
'*/\n'
33+
banner: '<%= banner %>'
3834
},
3935
dist: {
4036
files: {
@@ -73,12 +69,37 @@ module.exports = function(grunt) {
7369
port: 8080,
7470
open: true,
7571
livereload: true,
72+
hostname: 'localhost',
7673
base: {
7774
path: '.',
7875
options: {
7976
index: 'example/index.html'
8077
}
81-
}
78+
},
79+
middleware: function(connect, options, middlewares) {
80+
81+
var url = require('url');
82+
83+
// inject a custom middleware into the array of default middlewares
84+
middlewares.unshift(function(req, res, next) {
85+
86+
if (req.url.indexOf('/api/test/') === -1) return next();
87+
88+
var value = req.url.replace('/api/test/', '');
89+
90+
if( value === '[email protected]' ) {
91+
res.writeHead(200);
92+
res.end('ok');
93+
return;
94+
}
95+
96+
res.writeHead(200);
97+
res.end();
98+
99+
});
100+
101+
return middlewares;
102+
},
82103
}
83104
}
84105
}

0 commit comments

Comments
 (0)