Skip to content

Commit

Permalink
Merge pull request #50 from ReAGEnT-WiSe2021-22/potential-party/ft/prod
Browse files Browse the repository at this point in the history
feat(production): show mock data in production
  • Loading branch information
sunanmau5 authored Feb 10, 2022
2 parents f388090 + 18a4ce7 commit 656cffe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 11 additions & 1 deletion packages/container/src/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createServer } from 'miragejs';

import { REAGENT_WIKI_ENDPOINT } from './const';
import { partyReputation } from './fixtures/party-reputation';
import { tweets } from './tweets/tweets';
Expand Down Expand Up @@ -34,6 +33,16 @@ export const initMockServer = () => {
});
};

export const initPotentialPartyMockServer = () => {
(window as any).server = createServer({
routes() {
this.get('/api/potential-party', () => ({
data: tweets,
}));
},
});
};

export const setup = (): Promise<void> => new Promise((resolve) => {
const env = process.env.REACT_APP_ENVIRONMENT as Environment ?? Environment.development;

Expand All @@ -44,6 +53,7 @@ export const setup = (): Promise<void> => new Promise((resolve) => {
initMockServer();
} else {
console.log('production mode');
initPotentialPartyMockServer();
(window as any).baseUrl = '';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { DireflowComponent } from 'direflow-component';
import { initMockServer } from '../../utils/mock-server';

import App from './App';

export default () => {
const isInProduction = process.env.REACT_APP_ENVIRONMENT === 'production';
if (!isInProduction) {
initMockServer();
}
// Will also show mock data in production
// to show the frontend functionality
initMockServer();

return DireflowComponent.create({
component: App,
Expand Down

0 comments on commit 656cffe

Please sign in to comment.