Commit 80dc8fdc authored by Andrew Danger Lyon's avatar Andrew Danger Lyon

fixes. working great now.

parent 80c8d075
"use strict";
const Promise = require('bluebird');
const config = require('../helpers/config');
const trans = require('../helpers/transactions');
const config = require('./config').config;
const trans = require('./transactions');
const tx = trans.types;
const Users = require('../models/users');
......
......@@ -5,7 +5,7 @@ const path = require('path');
const Promise = require('bluebird');
const protobuf = require('protobufjs');
const Exonum = require('exonum-client');
const config = require('./config');
const config = require('./config').config;
const Timestamp = {
type: (function() {
......@@ -144,7 +144,9 @@ protos.define('exonum').add(Pubkey.type);
protos.define('exonum').add(Hash.type);
exports.root = protos;
function load() {
let has_loaded = false;
exports.load = function() {
if(has_loaded) return;
const files = fs.readdirSync(config.protobuf_dir)
files.forEach(function(protofile) {
if(protofile.match(/^\./) || !protofile.match(/\.proto$/)) return;
......@@ -153,5 +155,6 @@ function load() {
if(protos[name]) return protos[name];
protos.loadSync(fullpath, {keepCase: true});
});
has_loaded = true;
};
......@@ -2,9 +2,8 @@
const rp = require('request-promise');
const Exonum = require('exonum-client');
const config = require('../helpers/config');
const protobuf = require('../helpers/protobuf');
const standard_api = require('../helpers/standard-api');
const config = require('./config').config;
const protobuf = require('./protobuf');
exports.generate = function(path, type) {
function verify(res) {
......
......@@ -3,7 +3,7 @@
const Exonum = require('exonum-client');
const rp = require('request-promise');
const protobuf = require('./protobuf');
const config = require('./config');
const config = require('./config').config;
const types = {};
const message_id_map = (function() {
......
......@@ -8,20 +8,24 @@ const reexport_helpers = [
];
const models = {};
let has_init = false;
exports.init = function(configdir) {
if(has_init) return;
config.init(configdir);
protobuf.load();
const modeldir = __dirname + '/models';
fs.readdirSync(modeldir).forEach(function(file) {
if(file.match(/^\./) || !file.match(/\.js$/)) return;
const model = require(controller_dir + '/'+ file);
const model = require(modeldir + '/'+ file);
const slug = file.replace(/\.js/, '').replace(/-/g, '_');
models[slug] = model;
});
has_init = true;
};
exports.config = config.config;
exports.protobuf = protobuf;
exports.models = models;
reexport_helpers.forEach((helper) => {
const slug = helper.replace(/-/g, '_');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment