@@ -2,33 +2,41 @@ import { inject } from '@angular/core';
22import type { Environment } from '~core/tokens/environment.token' ;
33import { ENVIRONMENT } from '~core/tokens/environment.token' ;
44
5+ const getAuthEndpoints = ( baseUrl : string ) => ( {
6+ v1 : {
7+ authentication : `${ baseUrl } /v1/authentication` ,
8+ login : `${ baseUrl } /v1/authentication/login` ,
9+ refreshToken : `${ baseUrl } /v1/authentication/token/refresh` ,
10+ } ,
11+ } ) ;
12+
13+ const getUserEndpoints = ( baseUrl : string ) => ( {
14+ v1 : {
15+ user : `${ baseUrl } /v1/user` ,
16+ pokemonCatch : `${ baseUrl } /v1/user/pokemon/catch` ,
17+ } ,
18+ } ) ;
19+
20+ const getPokemonEndpoints = ( baseUrl : string , host : string ) => ( {
21+ v1 : {
22+ pokemon : ( pokemonIdOrName : string | number ) => `${ host } /v2/pokemon/${ pokemonIdOrName } ` ,
23+ lastUpdated : `${ baseUrl } /v1/pokemon/last-updated` ,
24+ } ,
25+ } ) ;
26+
27+ const getAnalyticsEndpoints = ( baseUrl : string ) => ( {
28+ v1 : {
29+ realtimeUsers : `${ baseUrl } /v1/analytics/realtime-users` ,
30+ } ,
31+ } ) ;
32+
533export const getEndpoints = ( ) => {
634 const environment = inject < Environment > ( ENVIRONMENT ) ;
735 const POKEMON_API_HOST = 'https://pokeapi.co/api' ;
836 return {
9- auth : {
10- v1 : {
11- authentication : `${ environment . apiBaseUrl } /v1/authentication` ,
12- login : `${ environment . apiBaseUrl } /v1/authentication/login` ,
13- refreshToken : `${ environment . apiBaseUrl } /v1/authentication/token/refresh` ,
14- } ,
15- } ,
16- user : {
17- v1 : {
18- user : `${ environment . apiBaseUrl } /v1/user` ,
19- pokemonCatch : `${ environment . apiBaseUrl } /v1/user/pokemon/catch` ,
20- } ,
21- } ,
22- pokemon : {
23- v1 : {
24- pokemon : ( pokemonIdOrName : string | number ) =>
25- `${ POKEMON_API_HOST } /v2/pokemon/${ pokemonIdOrName } ` ,
26- } ,
27- } ,
28- analytics : {
29- v1 : {
30- realtimeUsers : `${ environment . apiBaseUrl } /v1/analytics/realtime-users` ,
31- } ,
32- } ,
37+ auth : getAuthEndpoints ( environment . apiBaseUrl ) ,
38+ user : getUserEndpoints ( environment . apiBaseUrl ) ,
39+ pokemon : getPokemonEndpoints ( environment . apiBaseUrl , POKEMON_API_HOST ) ,
40+ analytics : getAnalyticsEndpoints ( environment . apiBaseUrl ) ,
3341 } as const ;
3442} ;
0 commit comments