Skip to content

Commit 48216c2

Browse files
committed
fix: fixed the discover functionality
1 parent 4ae6ec7 commit 48216c2

15 files changed

+48
-48
lines changed

templates/ords-remix-jwt-sample/app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
4141
const userProfile = await auth.isAuthenticated(request);
4242
const profile = userProfile?.profile || null;
4343
const USER_CREDENTIALS = userProfile === null
44-
? ''
44+
? null
4545
: `${userProfile.tokenType} ${userProfile.accessToken}`;
4646
const session = await getSession(request.headers.get('Cookie'));
4747
const error = session.get(auth.sessionErrorKey) as LoaderError;
4848

49-
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
49+
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
5050
if (cities.items.length === 0) {
5151
const errorMessage = 'The cities endpoint has no elements. Review your database configuration and try again.';
5252
throw new Response(errorMessage, {

templates/ords-remix-jwt-sample/app/routes/artists.$id.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,26 @@ export const loader = async ({
8686
const userProfile = await auth.isAuthenticated(request);
8787
const profile = userProfile?.profile || null;
8888
const USER_CREDENTIALS = userProfile === null
89-
? ''
89+
? null
9090
: `${userProfile.tokenType} ${userProfile.accessToken}`;
9191
const session = await getSession(request.headers.get('Cookie'));
9292
const error = session.get(auth.sessionErrorKey) as LoaderError;
9393
const { id: artistID } = params;
9494
let likedArtist = false;
95-
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS) as ORDSResponse<Artist>;
95+
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS!) as ORDSResponse<Artist>;
9696
if (artist.items.length === 0) {
9797
const errorMessage = 'The Artist you were looking for does not exist, might have been removed or had its id changed.';
9898
throw new Response(errorMessage, {
9999
status: 404,
100100
statusText: 'Not Found',
101101
} as ErrorResponse);
102102
}
103-
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS);
104-
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
105-
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
103+
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS!);
104+
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
105+
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
106106
if (profile) {
107107
const userID = profile.id;
108-
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS);
108+
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS!);
109109
likedArtist = userLikedArtist.likedartist === 1;
110110
}
111111
return json({

templates/ords-remix-jwt-sample/app/routes/concerts.$concertID.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export const loader = async ({
9292
const userProfile = await auth.isAuthenticated(request);
9393
const profile = userProfile?.profile || null;
9494
const USER_CREDENTIALS = userProfile === null
95-
? ''
95+
? null
9696
: `${userProfile.tokenType} ${userProfile.accessToken}`;
9797
const session = await getSession(request.headers.get('Cookie'));
9898
const error = session.get(auth.sessionErrorKey) as LoaderError;
9999
const { concertID } = params;
100-
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS) as ORDSResponse<Concert>;
100+
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS!) as ORDSResponse<Concert>;
101101
if (concert.items.length === 0) {
102102
const errorMessage = 'The Concert you were looking for does not exist, might have been removed or had its id changed.';
103103
throw new Response(errorMessage, {
@@ -108,7 +108,7 @@ export const loader = async ({
108108
let likedConcert = false;
109109
if (profile !== null) {
110110
const userID = profile.id;
111-
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS);
111+
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS!);
112112
likedConcert = userLikedConcert.likedevent === 1;
113113
}
114114

templates/ords-remix-jwt-sample/app/routes/home.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ import featureDescriptions from '../utils/ORDSFeaturesDescription';
4242
export const loader = async ({ request }: LoaderFunctionArgs) => {
4343
const userProfile = await auth.isAuthenticated(request);
4444
const USER_CREDENTIALS = userProfile === null
45-
? ''
45+
? null
4646
: `${userProfile.tokenType} ${userProfile.accessToken}`;
4747
const session = await getSession(request.headers.get('Cookie'));
4848
const error = session.get(auth.sessionErrorKey) as LoaderError;
4949
const { searchParams } = new URL(request.url);
5050
const hasCityName = searchParams.has('cityName');
5151
const cityName = searchParams.get('cityName');
5252
const eventsQuery = hasCityName ? `${CONCERTS_BY_CITY_ENDPOINT}/${cityName}` : EVENTS_ENDPOINT;
53-
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS);
54-
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS);
55-
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
53+
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS!);
54+
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS!);
55+
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
5656
return json({
5757
error,
5858
stats,

templates/ords-remix-jwt-sample/app/routes/resources.artists.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
2828
artistsURL.searchParams.append('limit', limit.toString());
2929
const userProfile = await auth.isAuthenticated(request);
3030
const USER_CREDENTIALS = userProfile === null
31-
? ''
31+
? null
3232
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3333
const session = await getSession(request.headers.get('Cookie'));
3434
const error = session.get(auth.sessionErrorKey) as LoaderError;
35-
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS);
35+
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS!);
3636
return json({
3737
error,
3838
artists,

templates/ords-remix-jwt-sample/app/routes/resources.cities.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
2828
citiesURL.searchParams.append('limit', limit.toString());
2929
const userProfile = await auth.isAuthenticated(request);
3030
const USER_CREDENTIALS = userProfile === null
31-
? ''
31+
? null
3232
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3333
const session = await getSession(request.headers.get('Cookie'));
3434
const error = session.get(auth.sessionErrorKey) as LoaderError;
35-
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS);
35+
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS!);
3636
return json({
3737
error,
3838
cities,

templates/ords-remix-jwt-sample/app/routes/resources.concerts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
3232
eventsURL.searchParams.append('limit', limit.toString());
3333
const userProfile = await auth.isAuthenticated(request);
3434
const USER_CREDENTIALS = userProfile === null
35-
? ''
35+
? null
3636
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3737
const session = await getSession(request.headers.get('Cookie'));
3838
const error = session.get(auth.sessionErrorKey) as LoaderError;
39-
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS);
39+
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS!);
4040
return json({
4141
error,
4242
events,

templates/ords-remix-jwt-sample/app/routes/resources.musicGenres.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
3030
musicGenresURL.searchParams.append('limit', limit.toString());
3131
const userProfile = await auth.isAuthenticated(request);
3232
const USER_CREDENTIALS = userProfile === null
33-
? ''
33+
? null
3434
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3535
const session = await getSession(request.headers.get('Cookie'));
3636
const error = session.get(auth.sessionErrorKey) as LoaderError;
3737
const musicGenres = await ORDSFetcher(
3838
musicGenresURL,
39-
USER_CREDENTIALS,
39+
USER_CREDENTIALS!,
4040
) as ORDSResponse<MusicGenre>;
4141
return json({
4242
error,

templates/ords-remix-jwt-sample/app/routes/resources.venues.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
3030
venuesURL.searchParams.append('limit', limit.toString());
3131
const userProfile = await auth.isAuthenticated(request);
3232
const USER_CREDENTIALS = userProfile === null
33-
? ''
33+
? null
3434
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3535
const session = await getSession(request.headers.get('Cookie'));
3636
const error = session.get(auth.sessionErrorKey) as LoaderError;
37-
const venues = await ORDSFetcher(venuesURL, USER_CREDENTIALS) as ORDSResponse<Venue>;
37+
const venues = await ORDSFetcher(venuesURL, USER_CREDENTIALS!) as ORDSResponse<Venue>;
3838
return json({
3939
error,
4040
venues,

templates/ords-remix-jwt-sample/app/routes/search.$searchKind.$searchParam.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ export const loader = async ({
2929
const { searchKind, searchParam } = params;
3030
const userProfile = await auth.isAuthenticated(request);
3131
const USER_CREDENTIALS = userProfile === null
32-
? ''
32+
? null
3333
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3434
// eslint-disable-next-line no-magic-numbers
3535
const FOLLOWERS = [69420, 99876, 45632, 32496, 98765, 12776, 100000, 88999, 99999];
3636

3737
switch (searchKind) {
3838
case 'Artists': {
39-
const artists = await ORDSFetcher(`${ARTISTS_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
39+
const artists = await ORDSFetcher(`${ARTISTS_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
4040
const SearchResult = artists.items.map((artist: Artist, index : number) => ({
4141
id: artist.artist_id,
4242
kind: 'artists',
@@ -49,7 +49,7 @@ export const loader = async ({
4949
});
5050
}
5151
case 'Events': {
52-
const events = await ORDSFetcher(`${EVENTS_BY_NAME_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
52+
const events = await ORDSFetcher(`${EVENTS_BY_NAME_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
5353
const SearchResult = events.items.map((event: Concert) => ({
5454
id: event.event_id,
5555
kind: 'concerts',
@@ -62,7 +62,7 @@ export const loader = async ({
6262
});
6363
}
6464
case 'Venues': {
65-
const venues = await ORDSFetcher(`${VENUES_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
65+
const venues = await ORDSFetcher(`${VENUES_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
6666
const SearchResult = venues.items.map((venue: Venue) => ({
6767
id: venue.venue_id,
6868
kind: 'venues',
@@ -78,7 +78,7 @@ export const loader = async ({
7878
headers: {
7979
'Content-Type': 'application/json',
8080
Accept: 'application/json',
81-
Authorization: USER_CREDENTIALS,
81+
Authorization: USER_CREDENTIALS!,
8282
},
8383
});
8484
const artists = await getArtist.json();

0 commit comments

Comments
 (0)