Ghost/ghost/admin/mirage/config.js

27 lines
737 B
JavaScript
Raw Normal View History

/* 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);
}
}