Comments (7)
@mikedevita you can achieve the same behavior with default Sails setup. Just create config/local.js
file and it overrides any properties you declare there. There is no needs for implementing such kind of features.
http://sailsjs.com/documentation/concepts/configuration/the-local-js-file
from generator-sails-rest-api.
Does it override or does it merge?
from generator-sails-rest-api.
@mikedevita it overrides and merges. If property exists, it will be overridden, otherwise it will be merged.
from generator-sails-rest-api.
@ghaiklor that idea wont work as is because you call const config = require('../../config/services/mailer');
independently and don't hook into sails.config.services.*
so either there needs to be a change in the config to use sails.config.services
or use merge like i suggested.
which if going the route of sails.config.services then i don't think it works out of box because sails isn't accessible in the services files as is. Some minor refactoring will need to be redone..
each service should module.exports and then be wrapped in a function..
module.exports = {
jwt: function() {
return cipher('jwt', sails.config.services.cipher.jwt)
}
}
from generator-sails-rest-api.
@mikedevita yeah, I see, makes sense. It will be great to get rid of direct requiring of configuration files and use sails.config
.
from generator-sails-rest-api.
from generator-sails-rest-api.
a bit of an update, by making the services functions you can then obtain access to sails.config
e.g;
api/services/CipherService.js
module.exports = {
jwt: (config) => cipher('jwt', _.merge({}, sails.config.services.cipher.jwt, config))
}
doing this you can then change anywhere CipherService.jwt.encodeSync()
to be CipherService.jwt().encodeSync()
I am not sure how to modify the yo generators to include this new syntax though. So any help would be appreciated there.
from generator-sails-rest-api.
Related Issues (20)
- JWT decoding error should return unauthorized HOT 2
- application not start. HOT 3
- does the generator support sails@beta 1.0.0 yet? HOT 2
- how can i add autopopulate back in to the find and findOne blueprints? HOT 1
- self.defaults is not a function HOT 2
- self.defaults is not a function HOT 1
- Error running on windows machine HOT 1
- Elastichsearch is not supported HOT 1
- How to customize swagger docs for particular API route?
- miss more module depend ex. passport, ...
- unable to get the sails api project up and running after generating the api base using the sails-rest-api HOT 4
- Cannot find module 'passport' HOT 3
- i have to manually install all dependencies. is this a joke? HOT 5
- Upgrading to sails v1.0
- not able to run the api HOT 6
- Error when generating project using web storm
- Rethrow non-MySQL errors : Converting circular structure to JSON
- How I can use same action for api and web.
- Sails version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator-sails-rest-api.