正在显示
9 个修改的文件
包含
7 行增加
和
183 行删除
@@ -4,10 +4,10 @@ | @@ -4,10 +4,10 @@ | ||
4 | var express = require('express') | 4 | var express = require('express') |
5 | var winstonRequestLogger = require('winston-request-logger') | 5 | var winstonRequestLogger = require('winston-request-logger') |
6 | var bootable = require('bootable') | 6 | var bootable = require('bootable') |
7 | -var bootableEnvironment = require('bootable-environment') | ||
8 | var _ = require('underscore') | 7 | var _ = require('underscore') |
9 | var updateNotifier = require('update-notifier') | 8 | var updateNotifier = require('update-notifier') |
10 | var path = require('path') | 9 | var path = require('path') |
10 | +var Resource = require('express-resource') | ||
11 | 11 | ||
12 | exports = module.exports = function(logger, settings) { | 12 | exports = module.exports = function(logger, settings) { |
13 | 13 | ||
@@ -40,10 +40,6 @@ exports = module.exports = function(logger, settings) { | @@ -40,10 +40,6 @@ exports = module.exports = function(logger, settings) { | ||
40 | if (settings.logger.requests) | 40 | if (settings.logger.requests) |
41 | app.use(winstonRequestLogger.create(logger)) | 41 | app.use(winstonRequestLogger.create(logger)) |
42 | 42 | ||
43 | - app.phase(bootableEnvironment()) | ||
44 | - app.phase(bootable.initializers()) | ||
45 | - app.phase(bootable.routes()) | ||
46 | - | ||
47 | return app | 43 | return app |
48 | 44 | ||
49 | } | 45 | } |
@@ -31,15 +31,6 @@ module.exports = function(lib, callback) { | @@ -31,15 +31,6 @@ module.exports = function(lib, callback) { | ||
31 | // trust proxy | 31 | // trust proxy |
32 | app.enable('trust proxy') | 32 | app.enable('trust proxy') |
33 | 33 | ||
34 | - // set-up electrolyte | ||
35 | - ioc.loader('controllers', ioc.node('app/controllers')); | ||
36 | - ioc.loader('models', ioc.node('app/models')); | ||
37 | - ioc.loader(ioc.node('config')); | ||
38 | - | ||
39 | - // set-up data nodes (inject data) | ||
40 | - ioc.loader(dataNode(lib, 'lib')); | ||
41 | - ioc.loader(dataNode(app, 'app')); | ||
42 | - | ||
43 | // set the default views directory | 34 | // set the default views directory |
44 | app.set('views', lib.config.viewsDir) | 35 | app.set('views', lib.config.viewsDir) |
45 | 36 |
config/development.js
已删除
100644 → 0
1 | - | ||
2 | -// # development | ||
3 | - | ||
4 | -var winstonRequestLogger = require('winston-request-logger') | ||
5 | -var lessMiddleware = require('less-middleware') | ||
6 | - | ||
7 | -var lib, app | ||
8 | - | ||
9 | -module.exports = function(_lib, _app) { | ||
10 | - lib = _lib | ||
11 | - app = _app | ||
12 | - return development | ||
13 | -} | ||
14 | - | ||
15 | -function development() { | ||
16 | - | ||
17 | - // winston logger | ||
18 | - app.use(winstonRequestLogger.create(lib.logger)) | ||
19 | - | ||
20 | - // less middleware | ||
21 | - app.use(lessMiddleware(lib.config.lessMiddleware)) | ||
22 | - | ||
23 | -} |
config/index.js
已删除
100644 → 0
1 | - | ||
2 | -// # config | ||
3 | - | ||
4 | -var _ = require('underscore') | ||
5 | -var path = require('path') | ||
6 | - | ||
7 | -var maxAge = 24 * 60 * 60 * 1000 | ||
8 | - | ||
9 | -var config = module.exports = {} | ||
10 | - | ||
11 | -var env = 'development' | ||
12 | - | ||
13 | -var rootDir = path.join(__dirname, '..') | ||
14 | - | ||
15 | -var environments = { | ||
16 | - development: { | ||
17 | - port: 3000, | ||
18 | - host: 'localhost', | ||
19 | - db: { | ||
20 | - host: 'localhost', | ||
21 | - dbname: 'mydb', | ||
22 | - port: '27017', | ||
23 | - opts: {} | ||
24 | - }, | ||
25 | - redis: { | ||
26 | - host: 'localhost', | ||
27 | - port: 6379, | ||
28 | - prefix: 'TODO', | ||
29 | - maxAge: maxAge | ||
30 | - }, | ||
31 | - cookieParser: 'TODO', | ||
32 | - session: { | ||
33 | - secret: 'TODO', | ||
34 | - key: 'TODO', | ||
35 | - cookie: { | ||
36 | - maxAge: maxAge | ||
37 | - } | ||
38 | - }, | ||
39 | - publicDir: path.join(rootDir, 'assets', 'public'), | ||
40 | - lessMiddleware: { | ||
41 | - src: path.join(rootDir, 'assets', 'public'), | ||
42 | - force: true | ||
43 | - } | ||
44 | - }, | ||
45 | - production: { | ||
46 | - port: 80, | ||
47 | - host: '', | ||
48 | - db: {}, | ||
49 | - redis: {}, | ||
50 | - cookieParser: '', | ||
51 | - session: {}, | ||
52 | - publicDir: path.join(rootDir, 'assets', 'dist') | ||
53 | - } | ||
54 | -} | ||
55 | - | ||
56 | -if (_.isString(process.env.NODE_ENV) && _.contains(_.keys(environments), env)) | ||
57 | - env = process.env.NODE_ENV | ||
58 | - | ||
59 | -_.defaults(config, { | ||
60 | - staticServer: { | ||
61 | - maxAge: maxAge, | ||
62 | - }, | ||
63 | - ssl: false, | ||
64 | - env: env, | ||
65 | - rootDir: rootDir, | ||
66 | - viewsDir: path.join(rootDir, 'app', 'views'), | ||
67 | -}) | ||
68 | - | ||
69 | -_.extend(config, environments[config.env]) | ||
70 | - | ||
71 | -config.protocol = (config.ssl) ? 'https' : 'http' | ||
72 | - | ||
73 | -config.favicon = path.join(config.publicDir, 'favicon.ico') | ||
74 | - | ||
75 | -config.winstonMongoDB = _.extend(config.db, { | ||
76 | - // don't perform second req to verify | ||
77 | - safe: false, | ||
78 | - port: parseInt(config.db.port, 10) | ||
79 | -}) |
config/production.js
已删除
100644 → 0
1 | - | ||
2 | -// # production | ||
3 | - | ||
4 | -var winston = require('winston') | ||
5 | -var winstonMongoDB = require('winston-mongodb') | ||
6 | -var express = require('express') | ||
7 | - | ||
8 | -var lib, app | ||
9 | - | ||
10 | -module.exports = function(_lib, _app) { | ||
11 | - lib = _lib | ||
12 | - app = _app | ||
13 | - return production | ||
14 | -} | ||
15 | - | ||
16 | -function production() { | ||
17 | - | ||
18 | - // enable view caching | ||
19 | - app.enable('view cache') | ||
20 | - | ||
21 | - // compress response data with gzip/deflate | ||
22 | - // this overwrites res.write and res.end functions | ||
23 | - app.use(express.compress()) | ||
24 | - | ||
25 | - // mongo transport for winston logging | ||
26 | - lib.logger.remove(winston.transports.Console) | ||
27 | - winstonMongoDB.add(winstonMongoDB.MongoDB, lib.config.winstonMongoDB) | ||
28 | - | ||
29 | -} |
config/routes.js
已删除
100644 → 0
1 | - | ||
2 | -// # routes | ||
3 | - | ||
4 | -var IoC = require('electrolyte') | ||
5 | -var lib, app | ||
6 | - | ||
7 | - | ||
8 | -module.exports = function(_lib, _app) { | ||
9 | - lib = _lib | ||
10 | - app = _app | ||
11 | - return routes | ||
12 | -} | ||
13 | - | ||
14 | -function routes() { | ||
15 | - | ||
16 | - var home = IoC.create('controllers/home') | ||
17 | - | ||
18 | - app.get('/', home.render) | ||
19 | - app.get('/about', home.about) | ||
20 | - | ||
21 | -} | ||
22 | - |
@@ -14,27 +14,17 @@ | @@ -14,27 +14,17 @@ | ||
14 | "license": "MIT", | 14 | "license": "MIT", |
15 | "homepage": "https://github.com/niftylettuce/igloo", | 15 | "homepage": "https://github.com/niftylettuce/igloo", |
16 | "dependencies": { | 16 | "dependencies": { |
17 | - "async": "~0.2.10", | ||
18 | - "body-parser": "~1.2.0", | ||
19 | "bootable": "^0.2.3", | 17 | "bootable": "^0.2.3", |
20 | - "bootable-environment": "^0.2.0", | ||
21 | "chalk": "^0.4.0", | 18 | "chalk": "^0.4.0", |
22 | "commander": "^2.2.0", | 19 | "commander": "^2.2.0", |
23 | - "connect-flash": "~0.1.1", | ||
24 | "connect-redis": "~2.0.0", | 20 | "connect-redis": "~2.0.0", |
25 | - "cookie-parser": "~1.1.0", | ||
26 | - "errorhandler": "~1.0.1", | ||
27 | "express": "~4.2.0", | 21 | "express": "~4.2.0", |
22 | + "express-resource": "^1.0.0", | ||
28 | "merge-defaults": "^0.1.0", | 23 | "merge-defaults": "^0.1.0", |
29 | - "method-override": "~1.0.1", | ||
30 | "mongoose": "~3.8.7", | 24 | "mongoose": "~3.8.7", |
31 | - "mongoose-json-select": "^0.2.1", | ||
32 | - "nifty-mongoose-types": "0.0.1", | ||
33 | - "passport": "~0.2.0", | ||
34 | - "passport-local-mongoose": "^0.3.0", | ||
35 | - "serve-favicon": "~2.0.0", | 25 | + "to-camel-case": "^0.2.1", |
36 | "underscore": "~1.6.0", | 26 | "underscore": "~1.6.0", |
37 | - "update-notifier": "^0.1.8", | 27 | + "update-notifier": "git://github.com/niftylettuce/update-notifier", |
38 | "winston": "git://github.com/niftylettuce/winston", | 28 | "winston": "git://github.com/niftylettuce/winston", |
39 | "winston-mongodb": "~0.4.3", | 29 | "winston-mongodb": "~0.4.3", |
40 | "winston-request-logger": "^1.0.5" | 30 | "winston-request-logger": "^1.0.5" |
请
注册
或
登录
后发表评论