[The Great Migration p2] - Migrating from Java+Spring to Node.js+Express

Whelp

I started my Migration a few weeks ago.
Step 1: I decided to use Sequelize.js as my ORM. It was going swimmingly until I was running hundreds of test cases and it was taking forever continually dropping and recreating databases. 15000 ms timeouts so tests wouldn't arbitrarily fail.

THEN!!

I started developing at home on my linux boxes (because cross platform is important) and all my tests failed.

EVERY SINGLE ONE!

Sequelize.js and my Ubuntu environment just did not work for me.

I did a bit of investigation and have now migrated my migration's ORM to Bookshelf.js. Let me tell you how boss this is.
Using Knex.js migrations and Bookshelf.js mappings coding has gotten ridiculously faster.

I'm using Bookshelf.js' plugins Registry, Virtuals, and the Bookshelf-ModelBase and let me tell you. All my basic crud operations have just been flying. With a load of code removed by the ModelBase, hiding the JSON stuff I don't want visualized (mostly just user passwords) this has been a breeze.

My bookshelf.js global file is literally this:

const env = process.env.NODE_ENV || 'development';

const path = require('path');  
const config = require(path.join(__dirname, 'knexfile'))[env];

const knex = require('knex')(config);  
const bookshelf = require('bookshelf')(knex);

//enable plugins
// - Plugin for pagination with fetch / fetchall
bookshelf.plugin('pagination');  
// - Plugin for field visibility. Users password, for example
bookshelf.plugin('visibility');  
// - Plugin for requiring and using strings for relations
bookshelf.plugin('registry');  
// - Plugin for basic crud operations
bookshelf.plugin(require('bookshelf-modelbase').pluggable);

//Export bookshelf
module.exports = bookshelf;  

A typical model is as simple as :

const bookshelf = require('../bookshelf');  
const bcrypt = require('bcrypt');

require('./role');  
require('./profile');

const User = bookshelf.Model.extend({  
  tableName:'users',
  hidden:['password'],
  roles: function(){
    return this.belongsToMany('Role', 'user_roles', 'user_id', 'role_id');
  },
  profile:function(){
    return this.hasOne('Profile')
  },
  hasTimestamps:true
}, {
  hashPassword:function(password){
    return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
  },
  create:function(user, callback){
    user.password = User.hashPassword(user.password); 
    let u = new User(user);
    return u.save();
  },
  getRoles:function(id){
    return new User({id:id}).roles().fetch();
  },
  addRole:function(id, role){
   return new User({id:id}).roles().attach(role.id);
  },
  getProfile:function(id){
    return new User({id:id}).profile().fetch();
  }
});

module.exports = bookshelf.model('User', User);  

This covers most of my use cases for my Users authentication.

Testing is boss too.

In a globalBefore.js file and using knex-cleaner I can clear out my test database and start testing in seconds as opposed to minutes.

So, Long story short.

The migration is going swimmingly.

Check back for more stories of pointless nerd excitement!