提交 f45bb33b41e35a2d0919c37bbc932292ae621e7d

作者 Nick Baugh
1 个父辈 7eff7cd8

added update notifier, moved lib/boot to boot, removed old test file

@@ -2,12 +2,42 @@ @@ -2,12 +2,42 @@
2 // # app 2 // # app
3 3
4 var express = require('express') 4 var express = require('express')
  5 +var updateNotifier = require('update-notifier')
  6 +var winstonRequestLogger = require('winston-request-logger')
5 var bootable = require('bootable') 7 var bootable = require('bootable')
6 var bootableEnvironment = require('bootable-environment') 8 var bootableEnvironment = require('bootable-environment')
  9 +var path = require('path')
  10 +var pkg = require(path.join(__dirname, '..', 'package'))
7 11
8 exports = module.exports = function(logger, settings) { 12 exports = module.exports = function(logger, settings) {
9 13
  14 + // check for updates to igloo
  15 + if (settings.updateNotifier) {
  16 +
  17 + var notifier = updateNotifier({
  18 + packageName: pkg.name,
  19 + packageVersion: pkg.version
  20 + })
  21 +
  22 + if (notifier.update)
  23 + logger.warn(
  24 + 'v%s of %s is now available (current: %s), run `npm update %s` to upgrade',
  25 + notifier.update.latest,
  26 + pkg.version,
  27 + pkg.name,
  28 + pkg.name
  29 + )
  30 +
  31 + }
  32 +
  33 + // create the app
10 var app = bootable(express()) 34 var app = bootable(express())
  35 +
  36 + // winston request logger before everything else
  37 + // but only if it was enabled in settings
  38 + if (settings.logger.requests)
  39 + app.use(winstonRequestLogger.create(logger))
  40 +
11 app.phase(bootableEnvironment()) 41 app.phase(bootableEnvironment())
12 app.phase(bootable.initializers()) 42 app.phase(bootable.initializers())
13 app.phase(bootable.routes()) 43 app.phase(bootable.routes())
@@ -40,6 +40,7 @@ exports = module.exports = function(settings) { @@ -40,6 +40,7 @@ exports = module.exports = function(settings) {
40 transports: transports 40 transports: transports
41 }) 41 })
42 42
  43 +
43 return logger 44 return logger
44 45
45 } 46 }
1 1
  2 +// igloo
  3 +// Copyright (c) 2014- Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)
  4 +// MIT Licensed
  5 +
  6 +// Igloo is a lightweight, fast, and minimal framework for rapid development
  7 +
  8 +// * Author: [@niftylettuce](https://twitter.com/#!/niftylettuce)
  9 +// * Source: <https://github.com/niftylettuce/igloo>
  10 +
  11 +// Special thanks to TJ Holowaychuk for being an inspiration,
  12 +// Jared Hanson for introducing me to `electrolyte`,
  13 +// and many others which I'd love to credit...
  14 +
  15 +// # igloo
  16 +
2 var path = require('path') 17 var path = require('path')
  18 +var os = require('os')
  19 +var cluster = require('cluster')
  20 +
  21 +var bootDir = path.join(__dirname, 'boot')
3 22
4 module.exports = { 23 module.exports = {
5 loader: function(id) { 24 loader: function(id) {
6 - return require(path.join(__dirname, 'lib', 'boot', id)) 25 + return require(path.join(bootDir, id))
7 }, 26 },
8 app: function(IoC) { 27 app: function(IoC) {
9 - return require(path.join(__dirname, 'lib'))(IoC) 28 + IoC.loader(IoC.node(bootDir))
  29 + var app = IoC.create('app')
  30 + return app
10 } 31 }
11 } 32 }
1 -  
2 -// igloo  
3 -// Copyright (c) 2014- Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)  
4 -// MIT Licensed  
5 -  
6 -// Igloo is a lightweight, fast, and minimal framework for rapid development  
7 -  
8 -// * Author: [@niftylettuce](https://twitter.com/#!/niftylettuce)  
9 -// * Source: <https://github.com/niftylettuce/igloo>  
10 -  
11 -// Special thanks to TJ Holowaychuk for being an inspiration,  
12 -// Jared Hanson for introducing me to `electrolyte`,  
13 -// and many others which I'd love to credit...  
14 -  
15 -// # igloo  
16 -  
17 -var path = require('path')  
18 -var os = require('os')  
19 -var cluster = require('cluster')  
20 -  
21 -exports = module.exports = function(IoC) {  
22 -  
23 - IoC.loader(IoC.node(path.join(__dirname, 'boot')))  
24 - var app = IoC.create('app')  
25 - return app  
26 -  
27 -}  
@@ -25,10 +25,6 @@ @@ -25,10 +25,6 @@
25 "cookie-parser": "~1.1.0", 25 "cookie-parser": "~1.1.0",
26 "errorhandler": "~1.0.1", 26 "errorhandler": "~1.0.1",
27 "express": "~4.2.0", 27 "express": "~4.2.0",
28 - "express-rate": "0.0.1",  
29 - "express-session": "~1.1.0",  
30 - "jade": "~1.1.5",  
31 - "less-middleware": "~0.1.15",  
32 "merge-defaults": "^0.1.0", 28 "merge-defaults": "^0.1.0",
33 "method-override": "~1.0.1", 29 "method-override": "~1.0.1",
34 "mongoose": "~3.8.7", 30 "mongoose": "~3.8.7",
@@ -38,8 +34,9 @@ @@ -38,8 +34,9 @@
38 "passport-local-mongoose": "^0.3.0", 34 "passport-local-mongoose": "^0.3.0",
39 "serve-favicon": "~2.0.0", 35 "serve-favicon": "~2.0.0",
40 "underscore": "~1.6.0", 36 "underscore": "~1.6.0",
  37 + "update-notifier": "^0.1.8",
41 "winston": "git://github.com/niftylettuce/winston", 38 "winston": "git://github.com/niftylettuce/winston",
42 "winston-mongodb": "~0.4.3", 39 "winston-mongodb": "~0.4.3",
43 - "winston-request-logger": "~1.0.4" 40 + "winston-request-logger": "^1.0.5"
44 } 41 }
45 } 42 }
1 -  
2 -// # test  
3 -  
4 -var igloo = require('../')  
注册登录 后发表评论