Skip to content

Commit

Permalink
Merge remote-tracking branch 'trollixx/dialect-http' into dialect-http
Browse files Browse the repository at this point in the history
  • Loading branch information
masylum committed Apr 13, 2011
2 parents 92480cf + f945611 commit 59f7709
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
7 changes: 6 additions & 1 deletion bin/dialect-http.js
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/*
* dialect-http
* Copyright(c) Pau Ramon <masylum@gmail.com>
Expand All @@ -6,7 +7,8 @@

require('colors');

var _lib_path = require('path').join(__dirname, '..', 'lib'),
var path = require('path'),
_lib_path = path.join(__dirname, '..', 'lib'),

_utils = require(_lib_path + '/utils'),
_dialect_http = require(_lib_path + '/dialect_http'),
Expand Down Expand Up @@ -40,6 +42,9 @@ while (_args.length) {
case '--config':
arg = _args.shift();
if (arg) {
if (arg[0] != '/') {
arg = path.normalize(path.join(process.cwd(), arg));
}
_dialect_http.options = _utils.merge(_dialect_http.options, require(arg));
} else {
throw Error('--config requires an path');
Expand Down
13 changes: 5 additions & 8 deletions lib/dialect_http.js
Expand Up @@ -2,9 +2,6 @@ var DIALECT_HTTP = {},
express = require('express'),
connect_auth = require('connect-auth'),

// TODO: use npm instead
dialect = require('../../dialect'),

_lib_path = require('path').join(__dirname, '..', 'lib'),
_controllers_path = require('path').join(_lib_path, 'controllers'),

Expand Down Expand Up @@ -54,12 +51,12 @@ DIALECT_HTTP.options = {
port: 3001,
dialect: {
locales: ['en', 'es', 'de', 'fr', 'pt'],
store: {mongodb: {dbname: 'dialect'}}
store: {mongodb: {database: 'dialect'}}
}
};

DIALECT_HTTP.app = express.createServer();
DIALECT_HTTP.dialect = dialect.dialect(DIALECT_HTTP.options.dialect);
DIALECT_HTTP.dialect = {};

DIALECT_HTTP.authenticate = function (req, res, next) {
if (req.session.auth && req.session.auth.user) {
Expand All @@ -73,8 +70,8 @@ DIALECT_HTTP.authenticate = function (req, res, next) {

DIALECT_HTTP.run = function () {
var app = DIALECT_HTTP.app,
dialect = DIALECT_HTTP.dialect,
options = DIALECT_HTTP.options;
options = DIALECT_HTTP.options,
dialect = DIALECT_HTTP.dialect = require('dialect').dialect(options.dialect);

app.configure(function () {
app.use(express.favicon());
Expand All @@ -86,7 +83,7 @@ DIALECT_HTTP.run = function () {
app.use(express.session({
cookie: options.session.cookie,
secret: options.session.secret,
store: require('connect-mongodb')(options.dialect.store.mongodb)
store: require('connect-mongodb')(options.sessions_db)
}));

app.use(express['static'](_lib_path + '/public'));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -13,5 +13,5 @@
"connect-i18n": "0.0.1"
},
"main": "./lib/express-dialect",
"engines": { "node": ">= 4.0" }
"engines": { "node": ">= 0.4.0" }
}

0 comments on commit 59f7709

Please sign in to comment.