refactor: 💡 remove dependency on ember-get-config

This commit is contained in:
Randall Morey committed 2021-11-05 11:52:12 -04:00
1 parent ae50e27725
commit 9ad9bdbf5e
4 files changed
+23 -8

No files matched your search

+20 -3
View File
@@ -2,7 +2,7 @@ import RESTAdapter from '@ember-data/adapter/rest';
import { serializeIntoHash } from '@ember-data/adapter/-private';
/* eslint-disable-next-line ember/no-mixins */
import AdapterBuildURLMixin from '../mixins/adapter-build-url';
import config from 'ember-get-config';
import { getOwner } from '@ember/application';
import { get } from '@ember/object';
import { InvalidError } from '@ember-data/adapter/error';
import { dasherize } from '@ember/string';
@@ -44,19 +44,36 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
) {
// =attributes
#host;
#namespace;
/**
* Sets host to the `api.host` string in the application's config,
* if set.
* @type {string}
*/
host = get(config, 'api.host');
get host() {
const config = getOwner(this).resolveRegistration('config:environment');
return this.#host || get(config, 'api.host');
}
set host(value) {
// Setting this value is useful for testing purposes.
this.#host = value;
}
/**
* Sets namespace to the `api.namespace` string in the application's config,
* if set.
* @type {string}
*/
namespace = get(config, 'api.namespace');
get namespace() {
const config = getOwner(this).resolveRegistration('config:environment');
return this.#namespace || get(config, 'api.namespace');
}
set namespace(value) {
// Setting this value is useful for testing purposes.
this.#namespace = value;
}
// =methods
+1 -1
View File
@@ -8,7 +8,7 @@ import makeBooleanFilter from './helpers/bexpr-filter';
const isTesting = config.environment === 'test';
export default function () {
initializeMockIPC(this);
initializeMockIPC(this, config);
// make this `http://localhost:8080`, for example, if your API is on a different server
// this.urlPrefix = '';
+2 -3
View File
@@ -1,9 +1,8 @@
import config from 'ember-get-config';
import { datatype } from 'faker';
const isTesting = config.environment === 'test';
export default function initializeMockIPC(server, config) {
const isTesting = config.environment === 'test';
export default function initializeMockIPC(server) {
/**
* We strive to make this application runnable in a regular web browser, since
* it is a convenient environment for development and testing. But only an
-1
View File
@@ -51,7 +51,6 @@
"ember-copy": "^2.0.1",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-get-config": "^0.3.0",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^1.0.0",
"ember-page-title": "^6.2.2",