Ghost/ghost/admin/mirage/config.js
Kevin Ansfield 5544389b80 Fixed "The routes only function has been deprecated" output in test runs
no issue

`ember-cli-mirage` replaced the use of a default function export with a `createServer` function that applies config and deprecated the older mirage config export style. It will also soon drop support of the separate `testConfig` export we used for defining our test routes.

- switched to the newer `return createServer(config);` server configuration approach
- extracted dev and test routes into separate files for a cleaner base config
2022-05-25 11:03:05 +01:00

27 lines
737 B
JavaScript

/* eslint-disable ghost/ember/no-test-import-export */
import {applyEmberDataSerializers, discoverEmberDataModels} from 'ember-cli-mirage';
import {createServer} from 'miragejs';
import {isTesting, macroCondition} from '@embroider/macros';
import devRoutes from './routes-dev';
import testRoutes from './routes-test';
export default function (config) {
let finalConfig = {
...config,
models: {...discoverEmberDataModels(), ...config.models},
serializers: applyEmberDataSerializers(config.serializers),
routes
};
return createServer(finalConfig);
}
function routes() {
if (macroCondition(isTesting())) {
testRoutes.call(this);
} else {
devRoutes.call(this);
}
}