Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get document root in sailsjs?

To read a file located in the document root of the sails project I currently use an absolute path.

/var/www/project/file.conf

How can I get the document root path in sails? Or how can I read the file in a controller by using relative path?

like image 360
UpCat Avatar asked Apr 14 '14 00:04

UpCat


2 Answers

in Sails the root path is: sails.config.appPath

like image 118
Maciej Maczor Kaczorowski Avatar answered Oct 04 '22 03:10

Maciej Maczor Kaczorowski


Since the main application file is app.js in the root folder, process.cwd() should work just fine for you.

like image 29
bredikhin Avatar answered Oct 04 '22 03:10

bredikhin