Может и баян старый, но я тут наступил сегодня: циклические зависимости в ноде резолвятся в пустой объект. Вот немного сильно упрощенного кода.
Есть модуль models/user:
var api = require('../lib/api');
function UserModel() {
}
| /* | |
| Example of legacy lib | |
| ./legacy_lib.js | |
| */ | |
| App = App || {}; | |
| App.Tool = function () { | |
| }; | |
| Let's pretend I've decided to build a spice rack. | |
| I've done small woodworking projects before, and I think I have a pretty good idea of what I need: some wood and a few basic tools: a tape measure, a saw, a level, and a hammer. | |
| If I were going to build a whole house, rather than just a spice rack, I'd still need a tape measure, a saw, a level, and a hammer (among other things). | |
| So I go to the hardware store to buy the tools, and I ask the sales clerk where I can find a hammer. | |
| "A hammer?" he asks. "Nobody really buys hammers anymore. They're kind of old fashioned." |
Может и баян старый, но я тут наступил сегодня: циклические зависимости в ноде резолвятся в пустой объект. Вот немного сильно упрощенного кода.
Есть модуль models/user:
var api = require('../lib/api');
function UserModel() {
}
| # .bashrc | |
| PS1="\[\033[1;30m\][\[\033[1;34m\]\u\[\033[1;30m\]@\[\033[0;35m\]\h\[\033[1;30m\]] \[\033[0;37m\]\W \[\033[1;30m\]\$\[\033[0m\] " | |
| export PATH=~/npm/bin:$PATH | |
| # Source global definitions | |
| if [ -f /etc/bashrc ]; then | |
| . /etc/bashrc | |
| fi |
| "apps": { | |
| "twitter": { | |
| "consumerKey": "1234", | |
| "consumerSecret": "1234", | |
| "callbackURL": "http://localhost/auth/twitter/callback" | |
| }, | |
| "linkedin": { | |
| "consumerKey": "1234", | |
| "consumerSecret": "1234", | |
| "callbackURL": "http://localhost/auth/linkedin/callback" |
| "use strict"; | |
| var passport = require('./passport'); | |
| var config = { | |
| redirectBack: redirectBack | |
| } | |
| function redirectBack(req, res) { | |
| res.redirect(req.param('__back') && decodeURIComponent(req.param('__back')) || '/'); | |
| } |
| ar TwitterStrategy = require('passport-twitter').Strategy; | |
| var FacebookStrategy = require('passport-facebook').Strategy; | |
| var LinkedinStrategy = require('passport-linkedin').Strategy; | |
| var passport = require('passport'); | |
| var _ = require('underscore'); | |
| var configurable = require('configurable-module'); | |
| function configure(options) { |
| var _ = require('underscore'); | |
| var async = require('async'); | |
| async.auto({ | |
| first: function(next) { | |
| setTimeout(next, 500); | |
| }, | |
| second: function(next) { | |
| setTimeout(next, 700); | |
| }, |
| it('should return error if at least one domain is unavailable', function (done) { | |
| nock(test.mock.user) | |
| .intercept('/info', 'SEARCH', {"count": 100, "query": "data.name:\"test.test\" AND type:\"domain\" AND name:\"reseller.pb\""}) | |
| .replyWithFile(200, __dirname + '/fixtures/info/found.json'); | |
| nock(test.mock.admin) | |
| .get('/user/aaaa11112222333344445555', {}) | |
| .replyWithFile(200, __dirname + '/fixtures/user/_nkbt.json'); |
| define('app/chat', [ | |
| 'dom', 'underscore', 'lib/app' | |
| ], function ($, _, app) { | |
| "use strict"; | |
| function init() { | |
| var $element = $('.jsAppChat').html(app.template('template/app/chat')); | |
| $element.find('.jsAppChat-formContainer') | |
| .html(app.template('template/app/chat/form')); | |
| } |