diff --git a/templates/js/app.js.ejs b/templates/js/app.js.ejs index 2ef75aec..2ce2f8da 100644 --- a/templates/js/app.js.ejs +++ b/templates/js/app.js.ejs @@ -1,51 +1,51 @@ <% if (view) { -%> -var createError = require('http-errors'); +var createError = require('http-errors') <% } -%> -var express = require('express'); -var path = require('path'); +var express = require('express') +var path = require('path') <% Object.keys(modules).sort().forEach(function (variable) { -%> -var <%- variable %> = require('<%- modules[variable] %>'); -<% }); -%> +var <%- variable %> = require('<%- modules[variable] %>') +<% }) -%> <% Object.keys(localModules).sort().forEach(function (variable) { -%> -var <%- variable %> = require('<%- localModules[variable] %>'); -<% }); -%> +var <%- variable %> = require('<%- localModules[variable] %>') +<% }) -%> -var app = express(); +var app = express() <% if (view) { -%> // view engine setup <% if (view.render) { -%> -app.engine('<%- view.engine %>', <%- view.render %>); +app.engine('<%- view.engine %>', <%- view.render %>) <% } -%> -app.set('views', path.join(__dirname, 'views')); -app.set('view engine', '<%- view.engine %>'); +app.set('views', path.join(__dirname, 'views')) +app.set('view engine', '<%- view.engine %>') <% } -%> <% uses.forEach(function (use) { -%> -app.use(<%- use %>); -<% }); -%> +app.use(<%- use %>) +<% }) -%> <% mounts.forEach(function (mount) { -%> -app.use(<%= mount.path %>, <%- mount.code %>); -<% }); -%> +app.use(<%= mount.path %>, <%- mount.code %>) +<% }) -%> <% if (view) { -%> // catch 404 and forward to error handler -app.use(function(req, res, next) { - next(createError(404)); -}); +app.use(function (req, res, next) { + next(createError(404)) +}) // error handler -app.use(function(err, req, res, next) { +app.use(function (err, req, res, next) { // set locals, only providing error in development - res.locals.message = err.message; - res.locals.error = req.app.get('env') === 'development' ? err : {}; + res.locals.message = err.message + res.locals.error = req.app.get('env') === 'development' ? err : {} // render the error page - res.status(err.status || 500); - res.render('error'); -}); + res.status(err.status || 500) + res.render('error') +}) <% } -%> -module.exports = app; +module.exports = app diff --git a/templates/js/routes/index.js b/templates/js/routes/index.js index ecca96a5..956680bd 100644 --- a/templates/js/routes/index.js +++ b/templates/js/routes/index.js @@ -1,9 +1,9 @@ -var express = require('express'); -var router = express.Router(); +var express = require('express') +var router = express.Router() /* GET home page. */ -router.get('/', function(req, res, next) { - res.render('index', { title: 'Express' }); -}); +router.get('/', function (req, res, next) { + res.render('index', { title: 'Express' }) +}) -module.exports = router; +module.exports = router diff --git a/templates/js/routes/users.js b/templates/js/routes/users.js index 623e4302..8cfe88f7 100644 --- a/templates/js/routes/users.js +++ b/templates/js/routes/users.js @@ -1,9 +1,9 @@ -var express = require('express'); -var router = express.Router(); +var express = require('express') +var router = express.Router() /* GET users listing. */ -router.get('/', function(req, res, next) { - res.send('respond with a resource'); -}); +router.get('/', function (req, res, next) { + res.send('respond with a resource') +}) -module.exports = router; +module.exports = router diff --git a/templates/js/www.ejs b/templates/js/www.ejs index 690fc488..faa18436 100644 --- a/templates/js/www.ejs +++ b/templates/js/www.ejs @@ -4,49 +4,49 @@ * Module dependencies. */ -var app = require('../app'); -var debug = require('debug')('<%- name %>:server'); -var http = require('http'); +var app = require('../app') +var debug = require('debug')('<%- name %>:server') +var http = require('http') /** * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '3000'); -app.set('port', port); +var port = normalizePort(process.env.PORT || '3000') +app.set('port', port) /** * Create HTTP server. */ -var server = http.createServer(app); +var server = http.createServer(app) /** * Listen on provided port, on all network interfaces. */ -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); +server.listen(port) +server.on('error', onError) +server.on('listening', onListening) /** * Normalize a port into a number, string, or false. */ function normalizePort(val) { - var port = parseInt(val, 10); + var port = parseInt(val, 10) if (isNaN(port)) { // named pipe - return val; + return val } if (port >= 0) { // port number - return port; + return port } - return false; + return false } /** @@ -55,25 +55,25 @@ function normalizePort(val) { function onError(error) { if (error.syscall !== 'listen') { - throw error; + throw error } var bind = typeof port === 'string' ? 'Pipe ' + port - : 'Port ' + port; + : 'Port ' + port // handle specific listen errors with friendly messages switch (error.code) { case 'EACCES': - console.error(bind + ' requires elevated privileges'); - process.exit(1); - break; + console.error(bind + ' requires elevated privileges') + process.exit(1) + break case 'EADDRINUSE': - console.error(bind + ' is already in use'); - process.exit(1); - break; + console.error(bind + ' is already in use') + process.exit(1) + break default: - throw error; + throw error } } @@ -82,9 +82,9 @@ function onError(error) { */ function onListening() { - var addr = server.address(); + var addr = server.address() var bind = typeof addr === 'string' ? 'pipe ' + addr - : 'port ' + addr.port; - debug('Listening on ' + bind); + : 'port ' + addr.port + debug('Listening on ' + bind) } diff --git a/test/cmd.js b/test/cmd.js index 49ad8784..de8240d1 100644 --- a/test/cmd.js +++ b/test/cmd.js @@ -1,6 +1,7 @@ var assert = require('assert') var AppRunner = require('./support/app-runner') +var CLIEngine = require('eslint').CLIEngine var exec = require('child_process').exec var fs = require('fs') var mkdirp = require('mkdirp') @@ -79,6 +80,12 @@ describe('express(1)', function () { '}\n') }) + it('should be standard', function () { + var cli = new CLIEngine() + var report = cli.executeOnFiles([ctx.dir]) + assert.equal(report.results.length, 0, 'should not have warnings or errors') + }) + it('should have installable dependencies', function (done) { this.timeout(NPM_INSTALL_TIMEOUT) npmInstall(ctx.dir, done)