My folder structure:
-base directory  
--app.js
--models  
---property.js  
--routers  
---api  
----v1
-----properties.js  
My Problem
In routers/api/v1/properties.js, how do I do get the base directory so I can stop doing this:
const Property = require('../../../models/property');
I want to remove the repetitive ../../../
My Current Solution
In my app.js, I add a line:
global.__basedir = __dirname;
And then in routers/api/v1/properties.js,
const path = require('path');
const Property = require(__basedir + '/models/property');
So what do you think? Are there pitfalls to this method? Is this the best way to do this?
 
    