Skip to content

Commit b17bd6f

Browse files
committed
Create bare Express app with lint and test
1 parent de77c43 commit b17bd6f

13 files changed

Lines changed: 204 additions & 2 deletions

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ coverage
2020
build/Release
2121

2222
# Dependency directory
23-
# Commenting this out is preferred by some people, see
24-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
2523
node_modules
2624

2725
# Users Environment Variables
2826
.lock-wscript
27+
28+
config/env/development.js
29+
config/env/test.js
30+
config/env/production.js
31+
32+
coverage/coverage.html

.jshintrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"curly": true,
3+
"eqnull": true,
4+
"eqeqeq": true,
5+
"undef": true,
6+
"indent": 4,
7+
"latedef": "nofunc",
8+
"noarg": true,
9+
"nonew": true,
10+
"plusplus": true,
11+
"quotmark": true,
12+
"unused": true,
13+
"maxparams": 3,
14+
"maxstatements": 10,
15+
"maxlen": 120
16+
}

Gruntfile.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module.exports = function(grunt) {
2+
3+
grunt.loadNpmTasks('grunt-env');
4+
grunt.loadNpmTasks('grunt-mocha-test');
5+
grunt.loadNpmTasks('grunt-contrib-jshint');
6+
grunt.loadNpmTasks('grunt-express-server');
7+
grunt.loadNpmTasks('grunt-contrib-watch');
8+
9+
grunt.initConfig({
10+
11+
env: {
12+
development: { NODE_ENV: 'development' },
13+
test: { NODE_ENV: 'test' },
14+
prod: { NODE_ENV: 'prod' },
15+
},
16+
17+
18+
express: {
19+
options: { script: './server.js' },
20+
dev: { node_env: 'development' },
21+
test: { node_env: 'test' },
22+
prod: { node_env: 'prod' },
23+
},
24+
25+
26+
watch: {
27+
scripts: {
28+
files: [ '**/*.js' ],
29+
tasks: [ 'jshint' ],
30+
options: { spawn: false },
31+
},
32+
},
33+
34+
35+
mochaTest: {
36+
test: {
37+
options: {
38+
reporter: 'spec',
39+
require: 'coverage/blanket',
40+
},
41+
src: [ 'test/**/*.js' ],
42+
},
43+
coverage: {
44+
options: {
45+
reporter: 'html-cov',
46+
quiet: true,
47+
captureFile: 'coverage/coverage.html',
48+
},
49+
src: ['test/**/*.js'],
50+
},
51+
},
52+
53+
54+
jshint: {
55+
options: {
56+
reporter: require('jshint-stylish'),
57+
},
58+
all: [
59+
'gruntfile.js',
60+
'src/**/*.js',
61+
'test/**/*.js',
62+
],
63+
},
64+
});
65+
66+
grunt.registerTask('serve', [ 'express:dev', 'watch' ]);
67+
grunt.registerTask('test', [ 'env:test', 'express:dev', 'mochaTest' ]);
68+
grunt.registerTask('lint', 'jshint');
69+
grunt.registerTask('default', [ 'lint', 'test' ]);
70+
};

config/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var _ = require('lodash');
2+
3+
module.exports = _.merge(
4+
require('./env/all.js'),
5+
require('./env/'+process.env.NODE_ENV+'.js'));

config/env/all.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var path = require('path');
2+
3+
var rootPath = path.normalize(__dirname + '/../..');
4+
5+
module.exports = {
6+
root_path: rootPath,
7+
ip: '0.0.0.0',
8+
port: process.env.PORT || 9000,
9+
};

config/env/development.js.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
env: 'development',
3+
};

config/env/production.js.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
env: 'production',
3+
ip: process.env.IP || '0.0.0.0',
4+
port: process.env.PORT || 8080,
5+
};

config/env/test.js.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
env: 'test',
3+
};

config/express.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var bodyParser = require('body-parser');
2+
3+
module.exports = function(app) {
4+
app.use(bodyParser.urlencoded({ extended: true }));
5+
app.use(bodyParser.json({ extended: true }));
6+
};

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "in-app-event-collector",
3+
"version": "0.0.0",
4+
"description": "Simple version of a server that collects in-app events sent from (mobile) devices",
5+
"main": "src/app.js",
6+
"scripts": {
7+
"test": "grunt"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/sheac/in-app-event-collector.git"
12+
},
13+
"author": "Shea Clare",
14+
"license": "MIT",
15+
"bugs": {
16+
"url": "https://github.com/sheac/in-app-event-collector/issues"
17+
},
18+
"homepage": "https://github.com/sheac/in-app-event-collector",
19+
"devDependencies": {
20+
"blanket": "^1.1.6",
21+
"grunt": "^0.4.5",
22+
"grunt-contrib-jshint": "^0.10.0",
23+
"grunt-contrib-watch": "^0.6.1",
24+
"grunt-env": "^0.4.1",
25+
"grunt-mocha-test": "^0.12.0",
26+
"jshint-stylish": "^1.0.0",
27+
"mocha": "^1.21.4",
28+
"should": "^4.0.4"
29+
},
30+
"dependencies": {
31+
"body-parser": "^1.8.2",
32+
"express": "^4.9.3",
33+
"grunt-env": "^0.4.1",
34+
"grunt-express-server": "^0.4.19",
35+
"lodash": "^2.4.1",
36+
"node-strict": "^1.0.0",
37+
"request": "^2.44.0",
38+
"winston": "^0.8.0"
39+
}
40+
}

0 commit comments

Comments
 (0)