Skip to content

Commit

Permalink
add config by environment
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalikKarpuk committed Jan 4, 2024
1 parent 21fa969 commit b6311ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
20 changes: 20 additions & 0 deletions apps/ui/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const environmentName = process.env.NODE_ENV;

export const getConfig = (): {
graphql: string;
} => {
switch (environmentName) {
case 'production':
return {
graphql: 'https://score.minascan.io',
};
case 'development':
return {
graphql: 'http://localhost:8080',
};
default:
return {
graphql: 'https://score.minascan.io',
};
}
};
3 changes: 2 additions & 1 deletion apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"start": "next start --port 3001",
"start-dev": "next start",
"lint": "next lint",
"ts-watch": "tsc --noEmit --incremental --watch",
"check": "npm run lint && npm run check:types"
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/store/chain/chainService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
import { getConfig } from '../../../config/config';

export const chainService = createApi({
reducerPath: 'chainService',
baseQuery: fetchBaseQuery({
baseUrl: 'http://localhost:8080',
baseUrl: getConfig().graphql,
fetchFn: fetch,
}),
endpoints: (builder) => ({
Expand Down

0 comments on commit b6311ef

Please sign in to comment.