简体   繁体   中英

Change configuration folder structure in sails.js

I just want to have another folder structure in sails.js. For example, something like:

/config
    /application
        routes.js
        policies.js
    /db
        connections.js
...

It seems like when lifting application sails look for each of that files ( console.log to /config/application/policies.js works when application getting lifted) anyway it does not work.

I try to add paths.config value to .sailsrc but it changes nothing. I an using sails version 0.10.5 now. Is there a way to do it?

I have found the solution. Actually, everything is very simple.

sails requires files from config folder recursively and tries to recognize them as configuration files. My problem was that I had copied most files as is:

// config/customfolder/connections.js
module.exports.connections = {
    ...
}

and here is the problem to require it. To make it work I just need to export config object as default export.

// config/customfolder/connections.js
module.exports = {
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM