Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ampatspell/ember-cli-fastboot-dotenv
Ember.js dotenv for FastBoot
https://github.com/ampatspell/ember-cli-fastboot-dotenv
dotenv ember-addon ember-cli-addon emberjs fastboot javascript
Last synced: about 1 month ago
JSON representation
Ember.js dotenv for FastBoot
- Host: GitHub
- URL: https://github.com/ampatspell/ember-cli-fastboot-dotenv
- Owner: ampatspell
- License: mit
- Created: 2017-10-05T12:03:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-05T23:57:55.000Z (over 7 years ago)
- Last Synced: 2024-05-01T15:53:53.466Z (8 months ago)
- Topics: dotenv, ember-addon, ember-cli-addon, emberjs, fastboot, javascript
- Language: JavaScript
- Size: 30.3 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-cli-fastboot-dotenv
`ember-cli-dotenv`-like addon for Ember.js for FastBoot which allows to use environment variables passed to FastBoot server in runtime.
Use `.env` file for development and production defaults.
See [Ohne Zeit](https://github.com/ampatspell/ohne-zeit) as an example from which the following info is extracted from.
```
// .env
COUCH_URL=http://127.0.0.1:5984
DATABASE_NAME=ohne-zeit
CHANGES_FEED=event-source
```Set allowed keys in `ember-cli-build`:
``` javascript
const EmberApp = require('ember-cli/lib/broccoli/ember-app');module.exports = function(defaults) {
let app = new EmberApp(defaults, {
'ember-cli-fastboot-dotenv': {
keys: [ 'COUCH_URL', 'DATABASE_NAME', 'CHANGES_FEED' ]
}
});
return app.toTree();
};
```Build your app without `.env` or keep it for defaults.
```
$ ember build -prod
$ cd dist
$ npm install
```Override `.env` defaults with environment variables when running in FastBoot:
``` javascript
// fastboot-server.js
const app = express();
app.get('/*', fastboot('./dist'));
app.listen(3000);
``````
$ COUCH_URL=http://server:5984 ./fastboot-server.js
```## Configuration lookup in the app (FastBoot and Browser)
``` javascript
// app/instance-initializers/store.jsexport default {
name: 'app:store',
after: 'ember-cli-fastboot-dotenv',
initialize(app) {
let dotenv = app.lookup('service:dotenv');let {
couchURL,
databaseName,
changesFeed
} = dotenv.getProperties('couchURL', 'databaseName', 'changesFeed');// ...
}
};
```