Browse Source

New config

stuff
xcps 7 years ago
parent
commit
f45c70df51
  1. 3
      app.js
  2. 6
      bin/syncBlockchain.babel.js
  3. 9
      config/config.json.example
  4. 4
      models/index.js

3
app.js

@ -4,6 +4,7 @@ var favicon = require('serve-favicon');
var logger = require('morgan'); var logger = require('morgan');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var env = require('./config/config.json')['env'];
var index = require('./routes/index'); var index = require('./routes/index');
var address = require('./routes/address'); var address = require('./routes/address');
@ -42,7 +43,7 @@ app.use(function(req, res, next) {
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
// set locals, only providing error in development // set locals, only providing error in development
res.locals.message = err.message; res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {}; res.locals.error = env === 'development' ? err : {};
// render the error page // render the error page
res.status(err.status || 500); res.status(err.status || 500);

6
bin/syncBlockchain.babel.js

@ -1,10 +1,8 @@
var http = require('http'); var http = require('http');
var models = require('../models'); var models = require('../models');
var rpcConfig = require('../config/config')['rpc'];
const username = 'gostcoinrpc'; const {username, password, hostname, port} = rpcConfig;
const password = 'CEQLt9zrNnmyzosSV7pjb3EksAkuY9qeqoUCwDQc2wPc';
const hostname = '127.0.0.1';
const port = 9376;
function MakeRPCRequest(postData) { function MakeRPCRequest(postData) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {

9
config/config.json.example

@ -1,4 +1,5 @@
{ {
"database": {
"development": { "development": {
"username": "geuser", "username": "geuser",
"password": "geuser", "password": "geuser",
@ -22,4 +23,12 @@
"dialect": "mysql", "dialect": "mysql",
"logging": false "logging": false
} }
},
"rpc": {
"username": "gostcoinrpc",
"password": "CEQLt9zrNnmyzosSV7pjb3EksAkuY9qeqoUCwDQc2wPc",
"hostname": "127.0.0.1",
"port": 9376
},
"env": "production"
} }

4
models/index.js

@ -4,8 +4,8 @@ var fs = require('fs');
var path = require('path'); var path = require('path');
var Sequelize = require('sequelize'); var Sequelize = require('sequelize');
var basename = path.basename(__filename); var basename = path.basename(__filename);
var env = process.env.NODE_ENV || 'development'; var env = require(__dirname + '/../config/config.json')['env'] || 'development';
var config = require(__dirname + '/../config/config.json')[env]; var config = require(__dirname + '/../config/config.json')['database'][env];
var db = {}; var db = {};
if (config.use_env_variable) { if (config.use_env_variable) {

Loading…
Cancel
Save