Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor codebase #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ app.use('/', indexRouter);
app.use('/users', usersRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
app.use(function(next) {
next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
app.use(function(err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
Expand Down
3 changes: 1 addition & 2 deletions controllers/stellar/createAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

exports.createAccount = function(req, res, next){
exports.createAccount = function(){

var pair = StellarSdk.Keypair.random();

pair.secret();
console.log(pair.secret());
pair.publicKey();
var request = require('request');
request.get({
Expand Down
4 changes: 1 addition & 3 deletions controllers/stellar/getBalance.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

exports.getBalance = function (req, res, next) {
exports.getBalance = function (req, res) {
var publicKey = req.params.publicKey

var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
Expand All @@ -18,7 +17,6 @@ exports.getBalance = function (req, res, next) {
Balance: balance.balance
});
});
console.log(arr)
res.send({
"publicKey": publicKey,
"assets": arr
Expand Down
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
router.get('/', function(res) {
res.render('index', { title: 'Express' });
});

Expand Down
4 changes: 2 additions & 2 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var router = express.Router();
var User = require('../models/user');
var createAccount = require('../controllers/stellar/createAccount');

router.post('/signup', function(req, res, next){
router.post('/signup', function(req, res){

var user = new User({
firstName: req.body.fname,
Expand All @@ -22,7 +22,7 @@ router.post('/signup', function(req, res, next){
return res.status(201).json(doc);
})

promise.catch(function(err){
promise.catch(function(){
return res.status(501).json({message: 'Error registering user.'})
})

Expand Down