File tree Expand file tree Collapse file tree 5 files changed +72
-1
lines changed Expand file tree Collapse file tree 5 files changed +72
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { env , environment } from "../src/typeDefinitions/default.types" ;
2
+ import {
3
+ RDS_BASE_API_URL ,
4
+ RDS_BASE_STAGING_API_URL ,
5
+ RDS_BASE_DEVELOPMENT_API_URL ,
6
+ } from "../src/constants/urls" ;
7
+
8
+ const config = ( env : env ) => {
9
+ const environment : environment = {
10
+ production : {
11
+ RDS_BASE_API_URL : RDS_BASE_API_URL ,
12
+ } ,
13
+ staging : {
14
+ RDS_BASE_API_URL : RDS_BASE_STAGING_API_URL ,
15
+ } ,
16
+ default : {
17
+ RDS_BASE_API_URL : RDS_BASE_DEVELOPMENT_API_URL ,
18
+ } ,
19
+ } ;
20
+
21
+ return environment [ env . CURRENT_ENVIRONMENT ] || environment . default ;
22
+ } ;
23
+
24
+ export default config ;
Original file line number Diff line number Diff line change 1
- export const RDS_API_BASE_URL = "https://api.realdevsquad.com" ;
1
+ export const RDS_BASE_API_URL = "https://api.realdevsquad.com" ;
2
+ export const RDS_BASE_STAGING_API_URL = "https://staging-api.realdevsquad.com" ;
3
+ export const RDS_BASE_DEVELOPMENT_API_URL = "http://localhost:3000" ; // If needed, modify the URL to your local API server
4
+
2
5
export const DISCORD_BASE_URL = "https://discord.com/api/v10" ;
3
6
export const VERIFICATION_SITE_URL = "https://my.realdevsquad.com" ;
Original file line number Diff line number Diff line change @@ -2,6 +2,14 @@ export interface env {
2
2
[ key : string ] : string ;
3
3
}
4
4
5
+ export interface environment {
6
+ [ key : string ] : variables ;
7
+ }
8
+
9
+ export interface variables {
10
+ RDS_BASE_API_URL : string ;
11
+ }
12
+
5
13
export interface discordCommand {
6
14
name : string ;
7
15
description : string ;
Original file line number Diff line number Diff line change
1
+ export const environment = [
2
+ {
3
+ CURRENT_ENVIRONMENT : "production" ,
4
+ } ,
5
+ {
6
+ CURRENT_ENVIRONMENT : "staging" ,
7
+ } ,
8
+ {
9
+ CURRENT_ENVIRONMENT : "" ,
10
+ } ,
11
+ ] ;
Original file line number Diff line number Diff line change
1
+ import config from "../../../config/config" ;
2
+ import { environment } from "../../fixtures/config" ;
3
+ import {
4
+ RDS_BASE_API_URL ,
5
+ RDS_BASE_DEVELOPMENT_API_URL ,
6
+ RDS_BASE_STAGING_API_URL ,
7
+ } from "../../../src/constants/urls" ;
8
+
9
+ describe ( "Test config function" , ( ) => {
10
+ it ( "Should return production config environment" , ( ) => {
11
+ expect ( config ( environment [ 0 ] ) . RDS_BASE_API_URL ) . toBe ( RDS_BASE_API_URL ) ;
12
+ } ) ;
13
+
14
+ it ( "Should return staging config environment" , ( ) => {
15
+ expect ( config ( environment [ 1 ] ) . RDS_BASE_API_URL ) . toBe (
16
+ RDS_BASE_STAGING_API_URL
17
+ ) ;
18
+ } ) ;
19
+
20
+ it ( "Should return default config environment" , ( ) => {
21
+ expect ( config ( environment [ 2 ] ) . RDS_BASE_API_URL ) . toBe (
22
+ RDS_BASE_DEVELOPMENT_API_URL
23
+ ) ;
24
+ } ) ;
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments